siyuan 0.8.4 → 0.8.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,6 +1,14 @@
1
1
  # Changelog
2
2
 
3
- ## 0.8.5 2023-09
3
+ ## 0.8.7 2023-10
4
+
5
+ ## 0.8.6 2023-10-17
6
+
7
+ * [Update some definitions](https://github.com/siyuan-note/petal/pull/17)
8
+
9
+ ## 0.8.5 2023-10-10
10
+
11
+ * [Add plugin event bus `open-menu-doctree`](https://github.com/siyuan-note/siyuan/issues/9351)
4
12
 
5
13
  ## 0.8.4 2023-09-19
6
14
 
package/package.json CHANGED
@@ -12,6 +12,6 @@
12
12
  "README.md",
13
13
  "siyuan.d.ts"
14
14
  ],
15
- "version": "0.8.4",
15
+ "version": "0.8.6",
16
16
  "repository": "https://github.com/siyuan-note/petal"
17
17
  }
package/siyuan.d.ts CHANGED
@@ -1,16 +1,19 @@
1
- import type * as types from "./types";
2
- import {IProtyle} from "./types/protyle";
1
+ export * from "./types";
2
+
3
+ import {IProtyle, Lute, Protyle, Toolbar} from "./types/protyle";
4
+ import {IMenuBaseDetail} from "./types/events";
5
+ import {IGetDocInfo, IGetTreeStat} from "./types/response";
3
6
 
4
7
  declare global {
5
- interface Window extends Global {
8
+ export interface Window extends Global {
6
9
  }
7
10
  }
8
11
 
9
- type TEventBus = keyof IEventBusMap
12
+ export type TEventBus = keyof IEventBusMap
10
13
 
11
- type TCardType = "doc" | "notebook" | "all"
14
+ export type TCardType = "doc" | "notebook" | "all"
12
15
 
13
- type TProtyleAction = "cb-get-append" | // 向下滚动加载
16
+ export type TProtyleAction = "cb-get-append" | // 向下滚动加载
14
17
  "cb-get-before" | // 向上滚动加载
15
18
  "cb-get-unchangeid" | // 上下滚动,定位时不修改 blockid
16
19
  "cb-get-hl" | // 高亮
@@ -25,7 +28,7 @@ type TProtyleAction = "cb-get-append" | // 向下滚动加载
25
28
  "cb-get-html" | // 直接渲染,不需要再 /api/block/getDocInfo,否则搜索表格无法定位
26
29
  "cb-get-history" // 历史渲染
27
30
 
28
- type TOperation =
31
+ export type TOperation =
29
32
  "insert"
30
33
  | "update"
31
34
  | "delete"
@@ -57,7 +60,7 @@ type TOperation =
57
60
  | "setAttrViewColCalc"
58
61
  | "updateAttrViewColNumberFormat"
59
62
 
60
- type TAVCol =
63
+ export type TAVCol =
61
64
  "text"
62
65
  | "date"
63
66
  | "number"
@@ -70,34 +73,85 @@ type TAVCol =
70
73
  | "email"
71
74
  | "phone"
72
75
 
73
- interface Global {
76
+ export interface Global {
74
77
  Lute: Lute;
75
78
  }
76
79
 
77
- interface IEventBusMap {
78
- "click-blockicon": types.events.IClickBlockIconDetail;
79
- "click-editorcontent": types.events.IClickEditorContentDetail;
80
- "click-editortitleicon": types.events.IClickEditorTitleIconDetail;
81
- "click-pdf": types.events.IClickPdfDetail;
82
- "destroy-protyle": types.events.IDestroyProtyleDetail;
83
- "input-search": types.events.IInputSearchDetail;
84
- "loaded-protyle-dynamic": types.events.ILoadedProtyleDynamicDetail;
85
- "loaded-protyle": types.events.ILoadedProtyleDetail;
86
- "open-menu-av": any;
87
- "open-menu-blockref": types.events.IOpenMenuBlockRefDetail;
88
- "open-menu-breadcrumbmore": types.events.IOpenMenuBreadcrumbMoreDetail;
89
- "open-menu-content": types.events.IOpenMenuContentDetail;
90
- "open-menu-fileannotationref": types.events.IOpenMenuFileAnnotationRefDetail;
91
- "open-menu-image": types.events.IOpenMenuImageDetail;
92
- "open-menu-link": types.events.IOpenMenuLinkDetail;
93
- "open-menu-tag": types.events.IOpenMenuTagDetail;
94
- "open-noneditableblock": types.events.IOpenNonEditableBlockDetail;
95
- "open-siyuan-url-block": types.events.IOpenSiyuanUrlBlockDetail;
96
- "open-siyuan-url-plugin": types.events.IOpenSiyuanUrlPluginDetail;
97
- "ws-main": types.events.IWebSocketMainDetail;
80
+ export interface IEventBusMap {
81
+ "click-blockicon": {
82
+ menu: EventMenu,
83
+ protyle: IProtyle,
84
+ blockElements: HTMLElement[],
85
+ };
86
+ "click-editorcontent": {
87
+ protyle: IProtyle,
88
+ event: MouseEvent,
89
+ };
90
+ "click-editortitleicon": {
91
+ menu: EventMenu,
92
+ protyle: IProtyle,
93
+ data: IGetDocInfo,
94
+ };
95
+ "click-pdf": {
96
+ event: MouseEvent,
97
+ };
98
+ "destroy-protyle": {
99
+ protyle: IProtyle,
100
+ };
101
+ "input-search": {
102
+ protyle: Protyle,
103
+ config: ISearchOption,
104
+ searchElement: HTMLInputElement,
105
+ };
106
+ "loaded-protyle-dynamic": {
107
+ protyle: IProtyle,
108
+ positon: "afterend" | "beforebegin",
109
+ };
110
+ "loaded-protyle": {
111
+ protyle: IProtyle,
112
+ };
113
+ "open-menu-av": IMenuBaseDetail & { selectRowElements: HTMLElement[] };
114
+ "open-menu-blockref": IMenuBaseDetail;
115
+ "open-menu-breadcrumbmore": {
116
+ menu: EventMenu,
117
+ protyle: IProtyle,
118
+ data: IGetTreeStat,
119
+ };
120
+ "open-menu-content": IMenuBaseDetail & { range: Range };
121
+ "open-menu-fileannotationref": IMenuBaseDetail;
122
+ "open-menu-image": IMenuBaseDetail;
123
+ "open-menu-link": IMenuBaseDetail;
124
+ "open-menu-tag": IMenuBaseDetail;
125
+ "open-menu-doctree": {
126
+ menu: EventMenu,
127
+ elements: NodeListOf<HTMLElement>,
128
+ type: "doc" | "docs" | "notebook",
129
+ };
130
+ "open-noneditableblock": {
131
+ protyle: IProtyle,
132
+ toolbar: Toolbar,
133
+ };
134
+ "open-siyuan-url-block": {
135
+ url: string,
136
+ id: string,
137
+ focus: boolean,
138
+ exist: boolean,
139
+ };
140
+ "open-siyuan-url-plugin": {
141
+ url: string,
142
+ };
143
+ "ws-main": IWebSocketData;
144
+ }
145
+
146
+ export interface IPosition {
147
+ x: number;
148
+ y: number;
149
+ w?: number;
150
+ h?: number;
151
+ isLeft?: boolean;
98
152
  }
99
153
 
100
- interface ITab {
154
+ export interface ITab {
101
155
  id: string;
102
156
  headElement: HTMLElement;
103
157
  panelElement: HTMLElement;
@@ -112,7 +166,7 @@ interface ITab {
112
166
  close: () => void;
113
167
  }
114
168
 
115
- interface IModel {
169
+ export interface IModel {
116
170
  ws: WebSocket;
117
171
  app: App;
118
172
  reqId: number;
@@ -121,7 +175,7 @@ interface IModel {
121
175
  send(cmd: string, param: Record<string, unknown>, process?: boolean): void;
122
176
  }
123
177
 
124
- interface ICustomModel extends IModel {
178
+ export interface ICustomModel extends IModel {
125
179
  tab: ITab;
126
180
  data: any;
127
181
  type: string;
@@ -138,21 +192,21 @@ interface ICustomModel extends IModel {
138
192
  destroy?(): void;
139
193
  }
140
194
 
141
- interface IDockModel extends Omit<ICustomModel, "beforeDestroy"> {
195
+ export interface IDockModel extends Omit<ICustomModel, "beforeDestroy"> {
142
196
  }
143
197
 
144
- interface ITabModel extends ICustomModel {
198
+ export interface ITabModel extends ICustomModel {
145
199
  }
146
200
 
147
- interface IObject {
201
+ export interface IObject {
148
202
  [key: string]: string;
149
203
  }
150
204
 
151
- interface I18N {
205
+ export interface I18N {
152
206
  [key: string]: any;
153
207
  }
154
208
 
155
- interface ILuteNode {
209
+ export interface ILuteNode {
156
210
  TokensStr: () => string;
157
211
  __internal_object__: {
158
212
  Parent: {
@@ -162,70 +216,78 @@ interface ILuteNode {
162
216
  };
163
217
  }
164
218
 
165
- interface ISearchOption {
166
- page?: number
167
- group?: number, // 0:不分组,1:按文档分组
168
- hasReplace?: boolean,
169
- method?: number // 0:文本,1:查询语法,2:SQL,3:正则表达式
170
- hPath?: string
171
- idPath?: string[]
172
- k: string
173
- r?: string
219
+ export interface ISearchOption {
220
+ page?: number;
221
+ removed?: boolean; // 移除后需记录搜索内容 https://github.com/siyuan-note/siyuan/issues/7745
222
+ name?: string;
223
+ sort?: number; // 0:按块类型(默认),1:按创建时间升序,2:按创建时间降序,3:按更新时间升序,4:按更新时间降序,5:按内容顺序(仅在按文档分组时),6:按相关度升序,7:按相关度降序
224
+ group?: number; // 0:不分组,1:按文档分组
225
+ hasReplace?: boolean;
226
+ method?: number; // 0:文本,1:查询语法,2:SQL,3:正则表达式
227
+ hPath?: string;
228
+ idPath?: string[];
229
+ k: string;
230
+ r?: string;
174
231
  types?: {
175
- mathBlock: boolean
176
- table: boolean
177
- blockquote: boolean
178
- superBlock: boolean
179
- paragraph: boolean
180
- document: boolean
181
- heading: boolean
182
- list: boolean
183
- listItem: boolean
184
- codeBlock: boolean
185
- htmlBlock: boolean
186
- embedBlock: boolean
187
- }
232
+ mathBlock: boolean,
233
+ table: boolean,
234
+ blockquote: boolean,
235
+ superBlock: boolean,
236
+ paragraph: boolean,
237
+ document: boolean,
238
+ heading: boolean,
239
+ list: boolean,
240
+ listItem: boolean,
241
+ codeBlock: boolean,
242
+ htmlBlock: boolean,
243
+ embedBlock: boolean,
244
+ databaseBlock: boolean,
245
+ };
188
246
  }
189
247
 
190
- interface IWebSocketData {
191
- cmd: string
192
- callback?: string
193
- data: any
194
- msg: string
195
- code: number
196
- sid: string
248
+ export interface IWebSocketData {
249
+ cmd: string;
250
+ callback?: string;
251
+ data: any;
252
+ msg: string;
253
+ code: number;
254
+ sid: string;
197
255
  }
198
256
 
199
- interface IPluginDockTab {
200
- position: "LeftTop" | "LeftBottom" | "RightTop" | "RightBottom" | "BottomLeft" | "BottomRight",
201
- size: { width: number, height: number },
202
- icon: string,
203
- hotkey?: string,
204
- title: string,
205
- index?: number,
206
- show?: boolean
257
+ export interface IPluginDockTab {
258
+ position: "LeftTop" | "LeftBottom" | "RightTop" | "RightBottom" | "BottomLeft" | "BottomRight";
259
+ size: {
260
+ width: number,
261
+ height: number,
262
+ };
263
+ icon: string;
264
+ hotkey?: string;
265
+ title: string;
266
+ index?: number;
267
+ show?: boolean;
207
268
  }
208
269
 
209
- interface IMenuItemOption {
210
- label?: string,
211
- click?: (element: HTMLElement) => void,
212
- type?: "separator" | "submenu" | "readonly",
213
- accelerator?: string,
214
- action?: string,
215
- id?: string,
216
- submenu?: IMenuItemOption[]
217
- disabled?: boolean
218
- icon?: string
219
- iconHTML?: string
220
- current?: boolean
221
- bind?: (element: HTMLElement) => void
222
- index?: number
223
- element?: HTMLElement
270
+ export interface IMenuItemOption {
271
+ iconClass?: string;
272
+ label?: string;
273
+ click?: (element: HTMLElement, event: MouseEvent) => boolean | void | Promise<boolean | void>;
274
+ type?: "separator" | "submenu" | "readonly";
275
+ accelerator?: string;
276
+ action?: string;
277
+ id?: string;
278
+ submenu?: IMenuItemOption[];
279
+ disabled?: boolean;
280
+ icon?: string;
281
+ iconHTML?: string;
282
+ current?: boolean;
283
+ bind?: (element: HTMLElement) => void;
284
+ index?: number;
285
+ element?: HTMLElement;
224
286
  }
225
287
 
226
- interface ICommandOption {
227
- langKey: string, // 用于区分不同快捷键的 key
228
- langText?: string, // 快捷键功能描述文本
288
+ export interface ICommandOption {
289
+ langKey: string // 用于区分不同快捷键的 key
290
+ langText?: string // 快捷键功能描述文本
229
291
  /**
230
292
  * 目前需使用 MacOS 符号标识,顺序按照 ⌥⇧⌘,入 ⌥⇧⌘A
231
293
  * "Ctrl": "⌘",
@@ -238,59 +300,59 @@ interface ICommandOption {
238
300
  */
239
301
  hotkey: string,
240
302
  customHotkey?: string,
241
- callback?: () => void // 其余回调存在时将不会触
303
+ callback?: () => void // 其余回调存在时将不会触
242
304
  globalCallback?: () => void // 焦点不在应用内时执行的回调
243
305
  fileTreeCallback?: (file: any) => void // 焦点在文档树上时执行的回调
244
- editorCallback?: (protyle: any) => void // 焦点在编辑器上时执行的回调
245
- dockCallback?: (element: HTMLElement) => void // 焦点在 dock 上时执行的回调
306
+ editorCallback?: (protyle: any) => void // 焦点在编辑器上时执行的回调
307
+ dockCallback?: (element: HTMLElement) => void // 焦点在 dock 上时执行的回调
246
308
  }
247
309
 
248
- interface IProtyleOption {
249
- action?: TProtyleAction[],
250
- mode?: "preview" | "wysiwyg",
251
- blockId: string
252
- key?: string
310
+ export interface IProtyleOption {
311
+ action?: TProtyleAction[];
312
+ mode?: "preview" | "wysiwyg";
313
+ blockId: string;
314
+ key?: string;
253
315
  scrollAttr?: {
254
316
  rootId: string,
255
317
  startId: string,
256
- endId: string
318
+ endId: string,
257
319
  scrollTop: number,
258
320
  focusId?: string,
259
- focusStart?: number
260
- focusEnd?: number
261
- zoomInId?: string
262
- }
263
- defId?: string
321
+ focusStart?: number,
322
+ focusEnd?: number,
323
+ zoomInId?: string,
324
+ };
325
+ defId?: string;
264
326
  render?: {
265
- background?: boolean
266
- title?: boolean
267
- gutter?: boolean
268
- scroll?: boolean
269
- breadcrumb?: boolean
270
- breadcrumbDocName?: boolean
271
- }
327
+ background?: boolean,
328
+ title?: boolean,
329
+ gutter?: boolean,
330
+ scroll?: boolean,
331
+ breadcrumb?: boolean,
332
+ breadcrumbDocName?: boolean,
333
+ };
272
334
  typewriterMode?: boolean;
273
335
 
274
336
  after?(protyle: Protyle): void;
275
337
  }
276
338
 
277
- interface IOperation {
278
- action: TOperation, // move, delete 不需要传 data
279
- id?: string,
280
- avID?: string, // av
281
- format?: string // updateAttrViewColNumberFormat 专享
282
- keyID?: string // updateAttrViewCell 专享
283
- rowID?: string // updateAttrViewCell 专享
284
- data?: any, // updateAttr 时为 { old: IObject, new: IObject }, updateAttrViewCell 时为 {TAVCol: {content: string}}
285
- parentID?: string
286
- previousID?: string
287
- retData?: any
288
- nextID?: string // insert 专享
289
- srcIDs?: string[] // insertAttrViewBlock 专享
290
- name?: string // addAttrViewCol 专享
291
- type?: TAVCol // addAttrViewCol 专享
292
- deckID?: string // add/removeFlashcards 专享
293
- blockIDs?: string[] // add/removeFlashcards 专享
339
+ export interface IOperation {
340
+ action: TOperation; // move, delete 不需要传 data
341
+ id?: string;
342
+ avID?: string; // av
343
+ format?: string; // updateAttrViewColNumberFormat 专享
344
+ keyID?: string; // updateAttrViewCell 专享
345
+ rowID?: string; // updateAttrViewCell 专享
346
+ data?: any; // updateAttr 时为 { old: IObject, new: IObject }, updateAttrViewCell 时为 {TAVCol: {content: string}}
347
+ parentID?: string;
348
+ previousID?: string;
349
+ retData?: any;
350
+ nextID?: string; // insert 专享
351
+ srcIDs?: string[]; // insertAttrViewBlock 专享
352
+ name?: string; // addAttrViewCol 专享
353
+ type?: TAVCol; // addAttrViewCol 专享
354
+ deckID?: string; // add/removeFlashcards 专享
355
+ blockIDs?: string[]; // add/removeFlashcards 专享
294
356
  }
295
357
 
296
358
  export function fetchPost(url: string, data?: any, callback?: (response: IWebSocketData) => void, headers?: IObject): void;
@@ -308,46 +370,46 @@ export function openWindow(options: {
308
370
  width?: number,
309
371
  tab?: ITab,
310
372
  doc?: {
311
- id: string, // 块 id
373
+ id: string; // 块 id
312
374
  },
313
375
  }): void;
314
376
 
315
377
  export function openTab(options: {
316
378
  app: App,
317
379
  doc?: {
318
- id: string, // 块 id
319
- action?: string[] // cb-get-all:获取所有内容;cb-get-focus:打开后光标定位在 id 所在的块;cb-get-hl: 打开后 id 块高亮
320
- zoomIn?: boolean // 是否缩放
321
- },
380
+ id: string, // 块 id
381
+ action?: string[], // cb-get-all:获取所有内容;cb-get-focus:打开后光标定位在 id 所在的块;cb-get-hl: 打开后 id 块高亮
382
+ zoomIn?: boolean, // 是否缩放
383
+ };
322
384
  pdf?: {
323
385
  path: string,
324
386
  page?: number, // pdf 页码
325
387
  id?: string, // File Annotation id
326
- },
388
+ };
327
389
  asset?: {
328
390
  path: string,
329
- },
330
- search?: ISearchOption
391
+ };
392
+ search?: ISearchOption;
331
393
  card?: {
332
394
  type: TCardType,
333
395
  id?: string, // cardType 为 all 时不传,否则传文档或笔记本 id
334
- title?: string // cardType 为 all 时不传,否则传文档或笔记本名称
335
- },
396
+ title?: string, // cardType 为 all 时不传,否则传文档或笔记本名称
397
+ };
336
398
  custom?: {
337
- title: string,
338
- icon: string,
339
- data?: any
340
399
  id: string, // 插件名称+页签类型:plugin.name + tab.type
341
- }
342
- position?: "right" | "bottom",
343
- keepCursor?: boolean // 是否跳转到新 tab 上
344
- removeCurrentTab?: boolean // 在当前页签打开时需移除原有页签
345
- afterOpen?: () => void // 打开后回调
400
+ icon: string,
401
+ title: string,
402
+ data?: any,
403
+ };
404
+ position?: "right" | "bottom";
405
+ keepCursor?: boolean; // 是否跳转到新 tab 上
406
+ removeCurrentTab?: boolean; // 在当前页签打开时需移除原有页签
407
+ afterOpen?: () => void; // 打开后回调
346
408
  }): ITab
347
409
 
348
410
  export function getFrontend(): "desktop" | "desktop-window" | "mobile" | "browser-desktop" | "browser-mobile";
349
411
 
350
- export function getBackend(): "windows" | "linux" | "darwin" | "docker" | "android" | "ios"
412
+ export function getBackend(): "windows" | "linux" | "darwin" | "docker" | "android" | "ios";
351
413
 
352
414
  export function adaptHotkey(hotkey: string): string;
353
415
 
@@ -375,15 +437,15 @@ export abstract class Plugin {
375
437
  protyleSlash: {
376
438
  filter: string[],
377
439
  html: string,
378
- id: string
379
- callback(protyle: Protyle): void
440
+ id: string,
441
+ callback(protyle: Protyle): void,
380
442
  }[];
381
443
 
382
444
  constructor(options: {
383
445
  app: App,
384
446
  name: string,
385
- i18n: I18N
386
- })
447
+ i18n: I18N,
448
+ });
387
449
 
388
450
  onload(): void;
389
451
 
@@ -409,10 +471,10 @@ export abstract class Plugin {
409
471
  */
410
472
  addStatusBar(options: {
411
473
  element: HTMLElement,
412
- position?: "right" | "left"
413
- }): HTMLElement
474
+ position?: "right" | "left",
475
+ }): HTMLElement;
414
476
 
415
- openSetting(): void
477
+ openSetting(): void;
416
478
 
417
479
  loadData(storageName: string): Promise<any>;
418
480
 
@@ -433,8 +495,8 @@ export abstract class Plugin {
433
495
  destroy?: (this: ITabModel) => void,
434
496
  resize?: (this: ITabModel) => void,
435
497
  update?: (this: ITabModel) => void,
436
- init: (this: ITabModel) => void
437
- }): () => ITabModel
498
+ init: (this: ITabModel) => void,
499
+ }): () => ITabModel;
438
500
 
439
501
  /**
440
502
  * Must be executed before the synchronous function.
@@ -446,10 +508,10 @@ export abstract class Plugin {
446
508
  destroy?: (this: IDockModel) => void,
447
509
  resize?: (this: IDockModel) => void,
448
510
  update?: (this: IDockModel) => void,
449
- init: (this: IDockModel) => void
450
- }): { config: IPluginDockTab, model: IDockModel }
511
+ init: (this: IDockModel) => void,
512
+ }): { config: IPluginDockTab, model: IDockModel };
451
513
 
452
- addCommand(options: ICommandOption): void
514
+ addCommand(options: ICommandOption): void;
453
515
 
454
516
  addFloatLayer(options: {
455
517
  ids: string[],
@@ -457,45 +519,22 @@ export abstract class Plugin {
457
519
  x?: number,
458
520
  y?: number,
459
521
  targetElement?: HTMLElement
460
- }): void
461
- }
462
-
463
- export class Protyle {
464
-
465
- public protyle: any;
466
-
467
- constructor(app: App, element: HTMLElement, options?: IProtyleOption)
468
-
469
- isUploading(): boolean
470
-
471
- destroy(): void
472
-
473
- resize(): void
474
-
475
- reload(focus: boolean): void
476
-
477
- /**
478
- * @param {boolean} [isBlock=false]
479
- * @param {boolean} [useProtyleRange=false]
480
- */
481
- insert(html: string, isBlock?: boolean, useProtyleRange?: boolean): void
482
-
483
- transaction(doOperations: IOperation[], undoOperations?: IOperation[]): void;
522
+ }): void;
484
523
  }
485
524
 
486
525
  export class Setting {
487
526
  constructor(options: {
488
527
  height?: string,
489
528
  width?: string,
490
- destroyCallback?: () => void
491
- confirmCallback?: () => void
492
- })
529
+ destroyCallback?: () => void,
530
+ confirmCallback?: () => void,
531
+ });
493
532
 
494
533
  addItem(options: {
495
- title: string
496
- description?: string
497
- actionElement?: HTMLElement
498
- createActionElement?(): HTMLElement
534
+ title: string,
535
+ description?: string,
536
+ actionElement?: HTMLElement,
537
+ createActionElement?(): HTMLElement,
499
538
  }): void;
500
539
 
501
540
  open(name: string): void;
@@ -533,9 +572,9 @@ export class Dialog {
533
572
  content: string,
534
573
  width?: string
535
574
  height?: string,
536
- destroyCallback?: (options?: IObject) => void
537
- disableClose?: boolean
538
- disableAnimation?: boolean
575
+ destroyCallback?: (options?: IObject) => void,
576
+ disableClose?: boolean,
577
+ disableAnimation?: boolean,
539
578
  });
540
579
 
541
580
  destroy(options?: IObject): void;
@@ -564,108 +603,12 @@ export class Menu {
564
603
  close(): void;
565
604
  }
566
605
 
567
- export class Lute {
568
- public static WalkStop: number;
569
- public static WalkSkipChildren: number;
570
- public static WalkContinue: number;
571
- public static Version: string;
572
- public static Caret: string;
573
-
574
- public static New(): Lute;
575
-
576
- public static EChartsMindmapStr(text: string): string;
577
-
578
- public static NewNodeID(): string;
579
-
580
- public static Sanitize(html: string): string;
581
-
582
- public static EscapeHTMLStr(str: string): string;
583
-
584
- public static UnEscapeHTMLStr(str: string): string;
585
-
586
- public static GetHeadingID(node: ILuteNode): string;
587
-
588
- public static BlockDOM2Content(html: string): string;
589
-
590
- private constructor();
591
-
592
- public BlockDOM2Content(text: string): string;
593
-
594
- public BlockDOM2EscapeMarkerContent(text: string): string;
595
-
596
- public SetTextMark(enable: boolean): void;
597
-
598
- public SetHeadingID(enable: boolean): void;
599
-
600
- public SetProtyleMarkNetImg(enable: boolean): void;
601
-
602
- public SetSpellcheck(enable: boolean): void;
603
-
604
- public SetFileAnnotationRef(enable: boolean): void;
605
-
606
- public SetSetext(enable: boolean): void;
607
-
608
- public SetYamlFrontMatter(enable: boolean): void;
609
-
610
- public SetChineseParagraphBeginningSpace(enable: boolean): void;
611
-
612
- public SetRenderListStyle(enable: boolean): void;
613
-
614
- public SetImgPathAllowSpace(enable: boolean): void;
615
-
616
- public SetKramdownIAL(enable: boolean): void;
617
-
618
- public BlockDOM2Md(html: string): string;
619
-
620
- public BlockDOM2StdMd(html: string): string;
621
-
622
- public SetGitConflict(enable: boolean): void;
623
-
624
- public SetSuperBlock(enable: boolean): void;
625
-
626
- public SetTag(enable: boolean): void;
627
-
628
- public SetMark(enable: boolean): void;
629
-
630
- public SetSub(enable: boolean): void;
631
-
632
- public SetSup(enable: boolean): void;
633
-
634
- public SetBlockRef(enable: boolean): void;
635
-
636
- public SetSanitize(enable: boolean): void;
637
-
638
- public SetHeadingAnchor(enable: boolean): void;
639
-
640
- public SetImageLazyLoading(imagePath: string): void;
641
-
642
- public SetInlineMathAllowDigitAfterOpenMarker(enable: boolean): void;
643
-
644
- public SetToC(enable: boolean): void;
645
-
646
- public SetIndentCodeBlock(enable: boolean): void;
647
-
648
- public SetParagraphBeginningSpace(enable: boolean): void;
649
-
650
- public SetFootnotes(enable: boolean): void;
651
-
652
- public SetLinkRef(enalbe: boolean): void;
653
-
654
- public SetEmojiSite(emojiSite: string): void;
655
-
656
- public PutEmojis(emojis: IObject): void;
657
-
658
- public SpinBlockDOM(html: string): string;
659
-
660
- public Md2BlockDOM(html: string): string;
661
-
662
- public SetProtyleWYSIWYG(wysiwyg: boolean): void;
663
-
664
- public MarkdownStr(name: string, md: string): string;
606
+ export class EventMenu {
607
+ public menus: IMenuItemOption[];
665
608
 
666
- public IsValidLinkDest(text: string): boolean;
609
+ constructor();
667
610
 
668
- public BlockDOM2InlineBlockDOM(html: string): string;
611
+ public addSeparator(index?: number): void;
669
612
 
670
- public BlockDOM2HTML(html: string): string;
613
+ public addItem(menu: IMenuItemOption): void;
671
614
  }
package/types/events.d.ts CHANGED
@@ -1,237 +1,8 @@
1
- import type { IProtyle } from "./protyle";
2
- import {Menu} from "./../siyuan";
1
+ import type {IProtyle} from "./protyle";
2
+ import {EventMenu} from "./../siyuan";
3
3
 
4
- //#region click-block-icon
5
- interface IBlockIconDetail {
6
- menu: InstanceType<typeof Menu>;
4
+ export interface IMenuBaseDetail {
5
+ menu: EventMenu;
7
6
  protyle: IProtyle;
8
- data?: IDocumentData;
9
- blockElements?: HTMLElement[];
7
+ element: HTMLElement;
10
8
  }
11
-
12
- interface IDocumentData {
13
- id: string;
14
- ial: Record<string, string>;
15
- icon: string;
16
- name: string;
17
- rootID: string;
18
- refIDs: string[];
19
- refCount: number;
20
- subFileCount: number;
21
- }
22
-
23
- /**
24
- * `click-blockicon`
25
- */
26
- export interface IClickBlockIconDetail extends IBlockIconDetail {
27
- blockElements: HTMLElement[];
28
- }
29
-
30
- /**
31
- * `click-editortitleicon`
32
- */
33
- export interface IClickEditorTitleIconDetail extends IBlockIconDetail {
34
- data: IDocumentData;
35
- }
36
- //#endregion click-block-icon
37
-
38
- //#region click-editor-content
39
- /**
40
- * `click-editorcontent`
41
- */
42
- export interface IClickEditorContentDetail {
43
- event: PointerEvent;
44
- protyle: IProtyle;
45
- }
46
- //#endregion click-editor-content
47
-
48
- //#region click-pdf
49
- /**
50
- * `click-pdf`
51
- */
52
- export interface IClickPdfDetail {
53
- event: PointerEvent;
54
- }
55
- //#endregion click-pdf
56
-
57
- //#region protyle
58
- /**
59
- * `loaded-protyle`
60
- */
61
- export interface ILoadedProtyleDetail extends IProtyle {
62
- }
63
-
64
- /**
65
- * `loaded-protyle-dynamic`
66
- */
67
- export interface ILoadedProtyleDynamicDetail {
68
- protyle: IProtyle;
69
- positon: string;
70
- }
71
-
72
- /**
73
- * `destroy-protyle`
74
- */
75
- export interface IDestroyProtyleDetail {
76
- protyle: IProtyle;
77
- }
78
- //#endregion protyle
79
-
80
- //#region input-search
81
- interface IInputSearchConfig {
82
- removed: boolean;
83
- k: string;
84
- r: string;
85
- hasReplace: boolean;
86
- method: number;
87
- hPath: string;
88
- idPath: string[];
89
- group: number;
90
- sort: number;
91
- types: {
92
- blockquote: boolean;
93
- codeBlock: boolean;
94
- document: boolean;
95
- embedBlock: boolean;
96
- heading: boolean;
97
- htmlBlock: boolean;
98
- list: boolean;
99
- listItem: boolean;
100
- mathBlock: boolean;
101
- paragraph: boolean;
102
- superBlock: boolean;
103
- table: boolean;
104
- };
105
- page: number;
106
- }
107
-
108
- interface IInputSearchProtyle {
109
- protyle: IProtyle;
110
- }
111
-
112
- /**
113
- * `input-search`
114
- */
115
- export interface IInputSearchDetail {
116
- config: IInputSearchConfig;
117
- protyle: IInputSearchProtyle;
118
- searchElement: HTMLInputElement;
119
- }
120
- //#endregion input-search
121
-
122
- //#region open-menu
123
- interface IMenuBaseDetail {
124
- menu: InstanceType<typeof Menu>;
125
- protyle: IProtyle;
126
- }
127
-
128
- interface IMenuInlineDetail extends IMenuBaseDetail {
129
- element: HTMLSpanElement,
130
- }
131
-
132
- interface IBreadcrumbData {
133
- imageCount: number;
134
- linkCount: number;
135
- refCount: number;
136
- runeCount: number;
137
- wordCount: number;
138
- }
139
-
140
- /**
141
- * `open-menu-breadcrumbmore`
142
- */
143
- export interface IOpenMenuBreadcrumbMoreDetail extends IMenuBaseDetail {
144
- data: IBreadcrumbData;
145
- }
146
-
147
- /**
148
- * `open-menu-content`
149
- */
150
- export interface IOpenMenuContentDetail extends IMenuBaseDetail {
151
- element: HTMLDivElement,
152
- range: Range;
153
- }
154
-
155
- /**
156
- * `open-menu-blockref`
157
- */
158
- export interface IOpenMenuBlockRefDetail extends IMenuInlineDetail {
159
- }
160
-
161
- /**
162
- * `open-menu-fileannotationref`
163
- */
164
- export interface IOpenMenuFileAnnotationRefDetail extends IMenuInlineDetail {
165
- }
166
-
167
- /**
168
- * `open-menu-image`
169
- */
170
- export interface IOpenMenuImageDetail extends IMenuInlineDetail {
171
- }
172
-
173
- /**
174
- * `open-menu-link`
175
- */
176
- export interface IOpenMenuLinkDetail extends IMenuInlineDetail {
177
- }
178
-
179
- /**
180
- * `open-menu-tag`
181
- */
182
- export interface IOpenMenuTagDetail extends IMenuInlineDetail {
183
- }
184
- //#endregion open-menu
185
-
186
- //#region open-noneditableblock
187
- interface INonEditableBlockToolbar {
188
- element: HTMLDivElement;
189
- range: Range;
190
- subElement: HTMLDivElement;
191
- subElementCloseCB: () => any;
192
- toolbarHeight: number;
193
- }
194
-
195
- /**
196
- * `open-noneditableblock`
197
- */
198
- export interface IOpenNonEditableBlockDetail {
199
- protyle: IProtyle;
200
- toolbar: INonEditableBlockToolbar;
201
- }
202
- //#endregion open-noneditableblock
203
-
204
- //#region open-siyuan-url
205
- interface IOpenSiyuanUrlDetail {
206
- url: string;
207
- }
208
-
209
- /**
210
- * `open-siyuan-url-block`
211
- */
212
- export interface IOpenSiyuanUrlBlockDetail extends IOpenSiyuanUrlDetail {
213
- id: string;
214
- focus: boolean;
215
- exist: boolean;
216
- }
217
-
218
- /**
219
- * `open-siyuan-url-plugin`
220
- */
221
- export interface IOpenSiyuanUrlPluginDetail extends IOpenSiyuanUrlDetail {
222
- }
223
- //#endregion open-siyuan-url
224
-
225
- //#region ws-main
226
- /**
227
- * `ws-main`
228
- */
229
- export interface IWebSocketMainDetail {
230
- cmd?: string
231
- callback?: string
232
- data?: any
233
- msg: string
234
- code: number
235
- sid?: string
236
- }
237
- //#endregion ws-main
package/types/index.d.ts CHANGED
@@ -1,2 +1,3 @@
1
- export * as events from "./events";
2
- export * as protyle from "./protyle";
1
+ export * from "./events";
2
+ export * from "./protyle";
3
+ export * from "./response";
@@ -1,4 +1,4 @@
1
- import {App, Lute} from "./../siyuan";
1
+ import {App, ILuteNode, IObject, IOperation, IPosition, IProtyleOption} from "./../siyuan";
2
2
 
3
3
  // REF: https://github.com/siyuan-note/siyuan/blob/dev/app/src/types/protyle.d.ts
4
4
  export interface IProtyle {
@@ -52,3 +52,162 @@ export interface IProtyle {
52
52
  undo?: any;
53
53
  wysiwyg?: any;
54
54
  }
55
+
56
+ export class Protyle {
57
+
58
+ public protyle: IProtyle;
59
+
60
+ constructor(app: App, element: HTMLElement, options?: IProtyleOption)
61
+
62
+ isUploading(): boolean
63
+
64
+ destroy(): void
65
+
66
+ resize(): void
67
+
68
+ reload(focus: boolean): void
69
+
70
+ /**
71
+ * @param {boolean} [isBlock=false]
72
+ * @param {boolean} [useProtyleRange=false]
73
+ */
74
+ insert(html: string, isBlock?: boolean, useProtyleRange?: boolean): void
75
+
76
+ transaction(doOperations: IOperation[], undoOperations?: IOperation[]): void;
77
+ }
78
+
79
+ export class Toolbar {
80
+ public element: HTMLElement;
81
+ public subElement: HTMLElement;
82
+ public subElementCloseCB: () => void;
83
+ public range: Range;
84
+
85
+ constructor(protyle: IProtyle)
86
+
87
+ public render(protyle: IProtyle, range: Range, event?: KeyboardEvent)
88
+
89
+ public showContent(protyle: IProtyle, range: Range, nodeElement: Element)
90
+
91
+ public showWidget(protyle: IProtyle, nodeElement: HTMLElement, range: Range)
92
+
93
+ public showTpl(protyle: IProtyle, nodeElement: HTMLElement, range: Range)
94
+
95
+ public showCodeLanguage(protyle: IProtyle, languageElement: HTMLElement)
96
+
97
+ public showRender(protyle: IProtyle, renderElement: Element, updateElements?: Element[], oldHTML?: string)
98
+
99
+ public setInlineMark(protyle: IProtyle, type: string, action: "range" | "toolbar", textObj?: {
100
+ color?: string,
101
+ type: string
102
+ })
103
+
104
+ public getCurrentType(range: Range): string[]
105
+
106
+ public showAssets(protyle: IProtyle, position: IPosition, avCB?: (url: string) => void)
107
+ }
108
+
109
+ export class Lute {
110
+ public static WalkStop: number;
111
+ public static WalkSkipChildren: number;
112
+ public static WalkContinue: number;
113
+ public static Version: string;
114
+ public static Caret: string;
115
+
116
+ public static New(): Lute;
117
+
118
+ public static EChartsMindmapStr(text: string): string;
119
+
120
+ public static NewNodeID(): string;
121
+
122
+ public static Sanitize(html: string): string;
123
+
124
+ public static EscapeHTMLStr(str: string): string;
125
+
126
+ public static UnEscapeHTMLStr(str: string): string;
127
+
128
+ public static GetHeadingID(node: ILuteNode): string;
129
+
130
+ public static BlockDOM2Content(html: string): string;
131
+
132
+ private constructor();
133
+
134
+ public BlockDOM2Content(text: string): string;
135
+
136
+ public BlockDOM2EscapeMarkerContent(text: string): string;
137
+
138
+ public SetTextMark(enable: boolean): void;
139
+
140
+ public SetHeadingID(enable: boolean): void;
141
+
142
+ public SetProtyleMarkNetImg(enable: boolean): void;
143
+
144
+ public SetSpellcheck(enable: boolean): void;
145
+
146
+ public SetFileAnnotationRef(enable: boolean): void;
147
+
148
+ public SetSetext(enable: boolean): void;
149
+
150
+ public SetYamlFrontMatter(enable: boolean): void;
151
+
152
+ public SetChineseParagraphBeginningSpace(enable: boolean): void;
153
+
154
+ public SetRenderListStyle(enable: boolean): void;
155
+
156
+ public SetImgPathAllowSpace(enable: boolean): void;
157
+
158
+ public SetKramdownIAL(enable: boolean): void;
159
+
160
+ public BlockDOM2Md(html: string): string;
161
+
162
+ public BlockDOM2StdMd(html: string): string;
163
+
164
+ public SetGitConflict(enable: boolean): void;
165
+
166
+ public SetSuperBlock(enable: boolean): void;
167
+
168
+ public SetTag(enable: boolean): void;
169
+
170
+ public SetMark(enable: boolean): void;
171
+
172
+ public SetSub(enable: boolean): void;
173
+
174
+ public SetSup(enable: boolean): void;
175
+
176
+ public SetBlockRef(enable: boolean): void;
177
+
178
+ public SetSanitize(enable: boolean): void;
179
+
180
+ public SetHeadingAnchor(enable: boolean): void;
181
+
182
+ public SetImageLazyLoading(imagePath: string): void;
183
+
184
+ public SetInlineMathAllowDigitAfterOpenMarker(enable: boolean): void;
185
+
186
+ public SetToC(enable: boolean): void;
187
+
188
+ public SetIndentCodeBlock(enable: boolean): void;
189
+
190
+ public SetParagraphBeginningSpace(enable: boolean): void;
191
+
192
+ public SetFootnotes(enable: boolean): void;
193
+
194
+ public SetLinkRef(enalbe: boolean): void;
195
+
196
+ public SetEmojiSite(emojiSite: string): void;
197
+
198
+ public PutEmojis(emojis: IObject): void;
199
+
200
+ public SpinBlockDOM(html: string): string;
201
+
202
+ public Md2BlockDOM(html: string): string;
203
+
204
+ public SetProtyleWYSIWYG(wysiwyg: boolean): void;
205
+
206
+ public MarkdownStr(name: string, md: string): string;
207
+
208
+ public IsValidLinkDest(text: string): boolean;
209
+
210
+ public BlockDOM2InlineBlockDOM(html: string): string;
211
+
212
+ public BlockDOM2HTML(html: string): string;
213
+ }
@@ -0,0 +1,20 @@
1
+ import {IObject} from "../siyuan";
2
+
3
+ export interface IGetDocInfo {
4
+ ial: IObject;
5
+ icon: string;
6
+ id: string;
7
+ name: string;
8
+ refCount: number;
9
+ refIDs: string[];
10
+ rootID: string;
11
+ subFileCount: number;
12
+ }
13
+
14
+ export interface IGetTreeStat {
15
+ imageCount: number;
16
+ linkCount: number;
17
+ refCount: number;
18
+ runeCount: number;
19
+ wordCount: number;
20
+ }