From 57e008870efafa438c4c89bcdb6ec5ed82071f85 Mon Sep 17 00:00:00 2001 From: frostime Date: Sun, 4 Jun 2023 13:49:30 +0800 Subject: [PATCH] add @types --- src/api.ts | 4 --- src/sy-dtype.d.ts | 70 -------------------------------------------- src/types/index.d.ts | 66 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 66 insertions(+), 74 deletions(-) delete mode 100644 src/sy-dtype.d.ts create mode 100644 src/types/index.d.ts diff --git a/src/api.ts b/src/api.ts index 0fa2013..87cf22d 100644 --- a/src/api.ts +++ b/src/api.ts @@ -6,10 +6,6 @@ * API 文档见 [API_zh_CN.md](https://github.com/siyuan-note/siyuan/blob/master/API_zh_CN.md) */ -import { - Block, Notebook, NotebookConf, NotebookId, DocumentId, BlockId, - doOperation, PreviousID, ParentID, BlockType, BlockSubType -} from "sy-dtype"; import { fetchSyncPost, IWebSocketData } from "siyuan"; diff --git a/src/sy-dtype.d.ts b/src/sy-dtype.d.ts deleted file mode 100644 index 0c3b465..0000000 --- a/src/sy-dtype.d.ts +++ /dev/null @@ -1,70 +0,0 @@ -/** - * Copyright (c) 2023 frostime. All rights reserved. - * https://github.com/frostime/sy-plugin-template-vite - */ - -/** - * Frequently used data structures in SiYuan - */ -declare module "sy-dtype" { - - export type DocumentId = string; - export type BlockId = string; - export type NotebookId = string; - export type PreviousID = BlockId; - export type ParentID = BlockId | DocumentId; - - export type Notebook = { - id: NotebookId; - name: string; - icon: string; - sort: number; - closed: boolean; - } - - export type NotebookConf = { - name: string; - closed: boolean; - refCreateSavePath: string; - createDocNameTemplate: string; - dailyNoteSavePath: string; - dailyNoteTemplatePath: string; - } - - export type BlockType = "d" | "s" | "h" | "t" | "i" | "p" | "f" | "audio" | "video" | "other"; - - export type BlockSubType = "d1" | "d2" | "s1" | "s2" | "s3" | "t1" | "t2" | "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "table" | "task" | "toggle" | "latex" | "quote" | "html" | "code" | "footnote" | "cite" | "collection" | "bookmark" | "attachment" | "comment" | "mindmap" | "spreadsheet" | "calendar" | "image" | "audio" | "video" | "other"; - - export type Block = { - id: BlockId; - parent_id?: BlockId; - root_id: DocumentId; - hash: string; - box: string; - path: string; - hpath: string; - name: string; - alias: string; - memo: string; - tag: string; - content: string; - fcontent?: string; - markdown: string; - length: number; - type: BlockType; - subtype: BlockSubType; - ial?: { [key: string]: string }; - sort: number; - created: string; - updated: string; - } - - export type doOperation = { - action: string; - data: string; - id: BlockId; - parentID: BlockId | DocumentId; - previousID: BlockId; - retData: null; - } -} \ No newline at end of file diff --git a/src/types/index.d.ts b/src/types/index.d.ts new file mode 100644 index 0000000..96110dc --- /dev/null +++ b/src/types/index.d.ts @@ -0,0 +1,66 @@ +/** + * Copyright (c) 2023 frostime. All rights reserved. + */ + +/** + * Frequently used data structures in SiYuan + */ +type DocumentId = string; +type BlockId = string; +type NotebookId = string; +type PreviousID = BlockId; +type ParentID = BlockId | DocumentId; + +type Notebook = { + id: NotebookId; + name: string; + icon: string; + sort: number; + closed: boolean; +} + +type NotebookConf = { + name: string; + closed: boolean; + refCreateSavePath: string; + createDocNameTemplate: string; + dailyNoteSavePath: string; + dailyNoteTemplatePath: string; +} + +type BlockType = "d" | "s" | "h" | "t" | "i" | "p" | "f" | "audio" | "video" | "other"; + +type BlockSubType = "d1" | "d2" | "s1" | "s2" | "s3" | "t1" | "t2" | "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "table" | "task" | "toggle" | "latex" | "quote" | "html" | "code" | "footnote" | "cite" | "collection" | "bookmark" | "attachment" | "comment" | "mindmap" | "spreadsheet" | "calendar" | "image" | "audio" | "video" | "other"; + +type Block = { + id: BlockId; + parent_id?: BlockId; + root_id: DocumentId; + hash: string; + box: string; + path: string; + hpath: string; + name: string; + alias: string; + memo: string; + tag: string; + content: string; + fcontent?: string; + markdown: string; + length: number; + type: BlockType; + subtype: BlockSubType; + ial?: { [key: string]: string }; + sort: number; + created: string; + updated: string; +} + +type doOperation = { + action: string; + data: string; + id: BlockId; + parentID: BlockId | DocumentId; + previousID: BlockId; + retData: null; +} \ No newline at end of file