类型与接口定义
- 类型与接口定义模块 siyuan - npm
type IEventBusMap
typescript
interface IEventBusMap {
"click-blockicon": {
menu: EventMenu;
protyle: IProtyle;
blockElements: HTMLElement[];
};
"click-editorcontent": {
protyle: IProtyle;
event: MouseEvent;
};
"click-editortitleicon": {
menu: EventMenu;
protyle: IProtyle;
data: IGetDocInfo;
};
"click-flashcard-action": {
card: ICard;
type: string;
};
"click-pdf": {
event: MouseEvent;
};
"destroy-protyle": {
protyle: IProtyle;
};
"input-search": {
protyle: Protyle;
config: ISearchOption;
searchElement: HTMLInputElement;
};
"loaded-protyle-dynamic": {
protyle: IProtyle;
position: "afterend" | "beforebegin";
};
"loaded-protyle-static": {
protyle: IProtyle;
};
"lock-screen": void;
"mobile-keyboard-show": void;
"mobile-keyboard-hide": void;
"open-menu-av": IMenuBaseDetail & { selectRowElements: HTMLElement[] };
"open-menu-blockref": IMenuBaseDetail;
"open-menu-breadcrumbmore": {
menu: EventMenu;
protyle: IProtyle;
data: IGetTreeStat;
};
"open-menu-content": IMenuBaseDetail & { range: Range };
"open-menu-fileannotationref": IMenuBaseDetail;
"open-menu-image": IMenuBaseDetail;
"open-menu-link": IMenuBaseDetail;
"open-menu-tag": IMenuBaseDetail;
"open-menu-doctree": {
menu: EventMenu;
elements: NodeListOf<HTMLElement>;
type: "doc" | "docs" | "notebook";
};
"open-menu-inbox": {
menu: EventMenu;
element: HTMLElement;
ids: string[];
};
"open-noneditableblock": {
protyle: IProtyle;
toolbar: Toolbar;
};
"open-siyuan-url-block": {
url: string;
id: string;
focus: boolean;
exist: boolean;
};
"open-siyuan-url-plugin": {
url: string;
};
"paste": {
protyle: IProtyle;
resolve: new<T>(value: PromiseLike<T> | T) => void;
textHTML: string;
textPlain: string;
siyuanHTML: string;
files: DataTransferItemList | FileList;
};
"switch-protyle": {
protyle: IProtyle;
};
"sync-end": IWebSocketData;
"sync-fail": IWebSocketData;
"sync-start": IWebSocketData;
"ws-main": IWebSocketData;
}表示不同的事件名称与事件对应的 detail 属性。这些事件将作为 EventBus 类的输入参数,以实现思源和插件之间的通信。
详情请参考 事件总线。
type TCardType
typescript
type TCardType = "all" | "doc" | "notebook";| Name | Explanation |
|---|---|
"doc" | 文档目录下的闪卡 |
"notebook" | 笔记本目录下的闪卡 |
"all" | 所有闪卡 |
interface ITab
typescript
interface ITab {
id: string;
headElement: HTMLElement;
panelElement: HTMLElement;
model: IModel;
title: string;
icon: string;
docIcon: string;
updateTitle: (title: string) => void;
pin: () => void;
unpin: () => void;
setDocIcon: (icon: string) => void;
close: () => void;
}id:string, TODOheadElement:HTMLElement, TODOpanelElement:HTMLElement, TODOmodel:IModel, TODOtitle:string, TODOicon:string, TODOdocIcon:string, TODOupdateTitle:(title: string) => void, TODOpin:() => void, TODOunpin:() => void, TODOsetDocIcon:(icon: string) => void, TODOclose:() => void, TODO
interface IModel
typescript
interface IModel {
element: Element;
tab: ITab;
data: any;
type: string;
}element:Element, TODOtab:ITab, TODOdata:any, TODOtype:string, TODO
(以下接口的文档模板省略,您可以按照上面的示例继续生成相应的文档模板)
interface IObject
typescript
interface IObject {
[key: string]: string;
}interface I18N
typescript
interface I18N {
[key: string]: any;
}interface ILuteNode
typescript
interface ILuteNode {
TokensStr: () => string;
__internal_object__: {
Parent: {
Type: number;
};
HeadingLevel: string;
};
}interface ISearchOption
typescript
interface ISearchOption {
page?: number;
group?: number;
hasReplace?: boolean;
method?: number;
hPath?: string;
idPath?: string[];
k: string;
r?: string;
types?: {
mathBlock: boolean;
table: boolean;
blockquote: boolean;
superBlock: boolean;
paragraph: boolean;
document: boolean;
heading: boolean;
list: boolean;
listItem: boolean;
codeBlock: boolean;
htmlBlock: boolean;
embedBlock: boolean;
};
}page:number, TODOgroup:number, TODOhasReplace:boolean, TODOmethod:number, TODOhPath:string, TODOidPath:string[], TODOk:string, TODOr:string, TODOtypes: TODOmathBlock:boolean, TODOtable:boolean, TODOblockquote:boolean, TODOsuperBlock:boolean, TODOparagraph:boolean, TODOdocument:boolean, TODOheading:boolean, TODOlist:boolean, TODOlistItem:boolean, TODOcodeBlock:boolean, TODOhtmlBlock:boolean, TODOembedBlock:boolean, TODO
interface IWebSocketData
typescript
interface IWebSocketData {
cmd: string;
callback?: string;
data: any;
msg: string;
code: number;
sid: string;
}cmd:string, TODOcallback:string | undefined, TODOdata:any, TODOmsg:string, TODOcode:number, TODOsid:string, TODO
interface IPluginDockTab
typescript
interface IPluginDockTab {
position: "BottomLeft" | "BottomRight" | "LeftBottom" | "LeftTop" | "RightBottom" | "RightTop";
size: { width: number; height: number };
icon: string;
hotkey?: string;
title: string;
index?: number;
show?: boolean;
}position:"LeftTop" | "LeftBottom" | "RightTop" | "RightBottom" | "BottomLeft" | "BottomRight", TODOsize:{ width: number; height: number }, TODOicon:string, TODOhotkey:string | undefined, TODOtitle:string, TODOindex:number | undefined, TODOshow:boolean | undefined, TODO
interface IMenuItemOption
typescript
interface IMenuItemOption {
label?: string;
click?: (element: HTMLElement) => void;
type?: "readonly" | "separator" | "submenu";
accelerator?: string;
action?: string;
id?: string;
submenu?: IMenuItemOption[];
disabled?: boolean;
icon?: string;
iconHTML?: string;
current?: boolean;
bind?: (element: HTMLElement) => void;
index?: number;
element?: HTMLElement;
}label:string | undefined, TODOclick:(element: HTMLElement) => void | undefined, TODOtype:"separator" | "submenu" | "readonly" | undefined, TODOaccelerator:string | undefined, TODOaction:string | undefined, TODOid:string | undefined, TODOsubmenu:IMenuItemOption[] | undefined, TODO (nested list)disabled:boolean | undefined, TODOicon:string | undefined, TODOiconHTML:string | undefined, TODOcurrent:boolean | undefined, TODObind:(element: HTMLElement) => void | undefined, TODOindex:number | undefined, TODOelement:HTMLElement | undefined, TODO
interface ICommandOption
typescript
interface ICommandOption {
langKey: string;
langText?: string;
hotkey: string;
customHotkey?: string;
callback?: () => void;
fileTreeCallback?: (file: any) => void;
editorCallback?: (protyle: any) => void;
dockCallback?: (element: HTMLElement) => void;
}langKey:string, TODOlangText:string | undefined, TODOhotkey:string, TODOcustomHotkey:string | undefined, TODOcallback:() => void | undefined, TODOfileTreeCallback:(file: any) => void | undefined, TODOeditorCallback:(protyle: any) => void | undefined, TODOdockCallback:(element: HTMLElement) => void | undefined, TODO
interface IProtyleOption
typescript
interface IProtyleOption {
action?: string[];
mode?: "preview" | "wysiwyg";
blockId: string;
key?: string;
scrollAttr?: {
rootId: string;
startId: string;
endId: string;
scrollTop: number;
focusId?: string;
focusStart?: number;
focusEnd?: number;
zoomInId?: string;
};
defId?: string;
render?: {
background?: boolean;
title?: boolean;
gutter?: boolean;
scroll?: boolean;
breadcrumb?: boolean;
breadcrumbDocName?: boolean;
};
typewriterMode?: boolean;
after?: (protyle: Protyle) => void;
}action:string[] | undefined, TODOmode:"preview" | "wysiwyg" | undefined, TODOblockId:string, TODOkey:string | undefined, TODOscrollAttr: TODOrootId:string, TODOstartId:string, TODOendId:string, TODOscrollTop:number, TODOfocusId:string | undefined, TODOfocusStart:number | undefined, TODOfocusEnd:number | undefined, TODOzoomInId:string | undefined, TODO
defId:string | undefined, TODOrender: TODObackground:boolean | undefined, TODOtitle:boolean | undefined, TODOgutter:boolean | undefined, TODOscroll:boolean | undefined, TODObreadcrumb:boolean | undefined, TODObreadcrumbDocName:boolean | undefined, TODO
typewriterMode:boolean | undefined, TODOafter:(protyle: Protyle) => void | undefined, TODO