Merge pull request #14 from siyuan-note/dev

add @types
This commit is contained in:
Frostime 2023-06-04 13:53:02 +08:00 committed by GitHub
commit 14479d3d14
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 66 additions and 74 deletions

View file

@ -6,10 +6,6 @@
* API [API_zh_CN.md](https://github.com/siyuan-note/siyuan/blob/master/API_zh_CN.md) * 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"; import { fetchSyncPost, IWebSocketData } from "siyuan";

70
src/sy-dtype.d.ts vendored
View file

@ -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;
}
}

66
src/types/index.d.ts vendored Normal file
View file

@ -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;
}