siyuan 0.8.1 → 0.8.2

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,13 @@
1
1
  # Changelog
2
2
 
3
- ## 0.8.2 2023-08
3
+ ## 0.8.3 2023-09
4
+
5
+ ## 0.8.2 2023-08-29
6
+
7
+ * [Improve IModel type definitions](https://github.com/siyuan-note/petal/pull/14)
8
+ * [Add plugin type `TProtyleAction`](https://github.com/siyuan-note/siyuan/issues/8988)
9
+ * [Add plugin event bus `destroy-protyle`](https://github.com/siyuan-note/siyuan/issues/9033)
10
+ * [Add plugin event bus `loaded-protyle-dynamic`](https://github.com/siyuan-note/siyuan/issues/9021)
4
11
 
5
12
  ## 0.8.1 2023-08-21
6
13
 
package/package.json CHANGED
@@ -2,6 +2,6 @@
2
2
  "name": "siyuan",
3
3
  "contributors": ["zuoez02", "Vanessa"],
4
4
  "types": "siyuan.d.ts",
5
- "version": "0.8.1",
5
+ "version": "0.8.2",
6
6
  "repository": "https://github.com/siyuan-note/petal"
7
7
  }
package/siyuan.d.ts CHANGED
@@ -5,10 +5,26 @@ type TEventBus = "ws-main" |
5
5
  "open-menu-av" | "open-menu-content" | "open-menu-breadcrumbmore" |
6
6
  "open-siyuan-url-plugin" | "open-siyuan-url-block" |
7
7
  "input-search" |
8
- "loaded-protyle"
8
+ "loaded-protyle" | "loaded-protyle-dynamic" |
9
+ "destroy-protyle"
9
10
 
10
11
  type TCardType = "doc" | "notebook" | "all"
11
12
 
13
+ type TProtyleAction = "cb-get-append" | // 向下滚动加载
14
+ "cb-get-before" | // 向上滚动加载
15
+ "cb-get-unchangeid" | // 上下滚动,定位时不修改 blockid
16
+ "cb-get-hl" | // 高亮
17
+ "cb-get-focus" | // 光标定位
18
+ "cb-get-focusfirst" | // 动态定位到第一个块
19
+ "cb-get-setid" | // 重置 blockid
20
+ "cb-get-all" | // 获取所有块
21
+ "cb-get-backlink" | // 悬浮窗为传递型需展示上下文
22
+ "cb-get-unundo" | // 不需要记录历史
23
+ "cb-get-scroll" | // 滚动到指定位置
24
+ "cb-get-context" | // 包含上下文
25
+ "cb-get-html" | // 直接渲染,不需要再 /api/block/getDocInfo,否则搜索表格无法定位
26
+ "cb-get-history" // 历史渲染
27
+
12
28
  declare global {
13
29
  interface Window {
14
30
  Lute: Lute
@@ -31,10 +47,29 @@ interface ITab {
31
47
  }
32
48
 
33
49
  interface IModel {
34
- element: Element;
50
+ ws: WebSocket;
51
+ app: App;
52
+ reqId: number;
53
+ parent: ITab | any;
54
+ send(cmd: string, param: Record<string, unknown>, process?: boolean): void;
55
+ }
56
+
57
+ interface ICustomModel extends IModel {
35
58
  tab: ITab;
36
59
  data: any;
37
60
  type: string;
61
+ element: HTMLElement;
62
+ init(): void;
63
+ update?(): void;
64
+ resize?(): void;
65
+ beforeDestroy?(): void;
66
+ destroy?(): void;
67
+ }
68
+
69
+ interface IDockModel extends Omit<ICustomModel, "beforeDestroy"> {
70
+ }
71
+
72
+ interface ITabModel extends ICustomModel {
38
73
  }
39
74
 
40
75
  interface IObject {
@@ -138,7 +173,7 @@ interface ICommandOption {
138
173
  }
139
174
 
140
175
  interface IProtyleOption {
141
- action?: string[],
176
+ action?: TProtyleAction[],
142
177
  mode?: "preview" | "wysiwyg",
143
178
  blockId: string
144
179
  key?: string
@@ -176,7 +211,7 @@ export function openTab(options: {
176
211
  app: App,
177
212
  doc?: {
178
213
  id: string, // 块 id
179
- action?: string [] // cb-get-all:获取所有内容;cb-get-focus:打开后光标定位在 id 所在的块;cb-get-hl: 打开后 id 块高亮
214
+ action?: string[] // cb-get-all:获取所有内容;cb-get-focus:打开后光标定位在 id 所在的块;cb-get-hl: 打开后 id 块高亮
180
215
  zoomIn?: boolean // 是否缩放
181
216
  },
182
217
  pdf?: {
@@ -197,7 +232,7 @@ export function openTab(options: {
197
232
  title: string,
198
233
  icon: string,
199
234
  data?: any
200
- id: string,
235
+ id: string, // 插件名称+页签类型:plugin.name + tab.type
201
236
  }
202
237
  position?: "right" | "bottom",
203
238
  keepCursor?: boolean // 是否跳转到新 tab 上
@@ -282,19 +317,19 @@ export abstract class Plugin {
282
317
 
283
318
  addIcons(svg: string): void;
284
319
 
285
- getOpenedTab(): { [key: string]: IModel[] } ;
320
+ getOpenedTab(): { [key: string]: ICustomModel[] };
286
321
 
287
322
  /**
288
323
  * Must be executed before the synchronous function.
289
324
  */
290
325
  addTab(options: {
291
326
  type: string,
292
- beforeDestroy?: () => void,
293
- destroy?: () => void,
294
- resize?: () => void,
295
- update?: () => void,
296
- init: () => void
297
- }): () => IModel
327
+ beforeDestroy?: (this: ITabModel) => void,
328
+ destroy?: (this: ITabModel) => void,
329
+ resize?: (this: ITabModel) => void,
330
+ update?: (this: ITabModel) => void,
331
+ init: (this: ITabModel) => void
332
+ }): () => ITabModel
298
333
 
299
334
  /**
300
335
  * Must be executed before the synchronous function.
@@ -303,11 +338,11 @@ export abstract class Plugin {
303
338
  config: IPluginDockTab,
304
339
  data: any,
305
340
  type: string,
306
- destroy?: () => void,
307
- resize?: () => void,
308
- update?: () => void,
309
- init: () => void
310
- }): { config: IPluginDockTab, model: IModel }
341
+ destroy?: (this: IDockModel) => void,
342
+ resize?: (this: IDockModel) => void,
343
+ update?: (this: IDockModel) => void,
344
+ init: (this: IDockModel) => void
345
+ }): { config: IPluginDockTab, model: IDockModel }
311
346
 
312
347
  addCommand(options: ICommandOption): void
313
348