siyuan 0.7.4 → 0.7.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,5 +1,16 @@
1
1
  # Changelog
2
2
 
3
+ ## v0.7.6
4
+
5
+ * [Add plugin name to command palette](https://github.com/siyuan-note/siyuan/issues/8644)
6
+ * [Add `open-menu-xxx` event bus for plugins](https://github.com/siyuan-note/siyuan/issues/8617)
7
+
8
+ ## v0.7.5
9
+
10
+ * [Add protyleSlash to the plugin](https://github.com/siyuan-note/siyuan/issues/8599)
11
+ * [Add plugin API protyle ](https://github.com/siyuan-note/siyuan/issues/8445)
12
+ * [Add ICommand.langText and change the type of i18n](https://github.com/siyuan-note/petal/pull/11)
13
+
3
14
  ## v0.7.4 2023-06-13
4
15
  1. [Add `beforeDestroy`](https://github.com/siyuan-note/siyuan/issues/8467)
5
16
 
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.7.4",
5
+ "version": "0.7.6",
6
6
  "repository": "https://github.com/siyuan-note/petal"
7
7
  }
package/siyuan.d.ts CHANGED
@@ -1,5 +1,9 @@
1
- type TEventBus = "ws-main" | "click-blockicon" | "click-editorcontent" | "click-pdf" |
2
- "click-editortitleicon" | "open-noneditableblock" | "loaded-protyle"
1
+ type TEventBus = "ws-main" |
2
+ "click-blockicon" | "click-editorcontent" | "click-pdf" | "click-editortitleicon" |
3
+ "open-noneditableblock" |
4
+ "open-menu-blockref" | "open-menu-fileannotationref" | "open-menu-tag" | "open-menu-link" | "open-menu-image" |
5
+ "open-menu-av" | "open-menu-content" |
6
+ "loaded-protyle"
3
7
 
4
8
  type TCardType = "doc" | "notebook" | "all"
5
9
 
@@ -35,6 +39,10 @@ interface IObject {
35
39
  [key: string]: string;
36
40
  }
37
41
 
42
+ interface I18N {
43
+ [key: string]: any;
44
+ }
45
+
38
46
  interface ILuteNode {
39
47
  TokensStr: () => string;
40
48
  __internal_object__: {
@@ -107,7 +115,8 @@ interface IMenuItemOption {
107
115
  }
108
116
 
109
117
  interface ICommandOption {
110
- langKey: string, // 多语言 key
118
+ langKey: string, // 用于区分不同快捷键的 key
119
+ langText?: string, // 快捷键功能描述文本
111
120
  /**
112
121
  * 目前需使用 MacOS 符号标识,顺序按照 ⌥⇧⌘,入 ⌥⇧⌘A
113
122
  * "Ctrl": "⌘",
@@ -126,6 +135,35 @@ interface ICommandOption {
126
135
  dockCallback?: (element: HTMLElement) => void
127
136
  }
128
137
 
138
+ interface IProtyleOption {
139
+ action?: string[],
140
+ mode?: "preview" | "wysiwyg",
141
+ blockId: string
142
+ key?: string
143
+ scrollAttr?: {
144
+ rootId: string,
145
+ startId: string,
146
+ endId: string
147
+ scrollTop: number,
148
+ focusId?: string,
149
+ focusStart?: number
150
+ focusEnd?: number
151
+ zoomInId?: string
152
+ }
153
+ defId?: string
154
+ render?: {
155
+ background?: boolean
156
+ title?: boolean
157
+ gutter?: boolean
158
+ scroll?: boolean
159
+ breadcrumb?: boolean
160
+ breadcrumbDocName?: boolean
161
+ }
162
+ typewriterMode?: boolean;
163
+
164
+ after?(protyle: Protyle): void;
165
+ }
166
+
129
167
  export function fetchPost(url: string, data?: any, callback?: (response: IWebSocketData) => void, headers?: IObject): void;
130
168
 
131
169
  export function fetchSyncPost(url: string, data?: any): Promise<IWebSocketData>;
@@ -185,17 +223,24 @@ export class App {
185
223
 
186
224
  export abstract class Plugin {
187
225
  eventBus: EventBus;
188
- i18n: IObject;
226
+ i18n: I18N;
189
227
  data: any;
228
+ displayName: string;
190
229
  name: string;
191
230
  app: App;
192
231
  commands: ICommandOption[];
193
232
  setting: Setting;
233
+ protyleSlash: {
234
+ filter: string[],
235
+ html: string,
236
+ id: string
237
+ callback(protyle: Protyle): void
238
+ }[];
194
239
 
195
240
  constructor(options: {
196
241
  app: App,
197
242
  name: string,
198
- i18n: IObject
243
+ i18n: I18N
199
244
  })
200
245
 
201
246
  onload(): void;
@@ -271,6 +316,24 @@ export abstract class Plugin {
271
316
  }): void
272
317
  }
273
318
 
319
+ export class Protyle {
320
+ constructor(app: App, element: HTMLElement, options?: IProtyleOption)
321
+
322
+ isUploading(): boolean
323
+
324
+ destroy(): void
325
+
326
+ resize(): void
327
+
328
+ reload(focus: boolean): void
329
+
330
+ /**
331
+ * @param {boolean} [isBlock=false]
332
+ * @param {boolean} [useProtyleRange=false]
333
+ */
334
+ insert(html: string, isBlock?: boolean, useProtyleRange?: boolean): void
335
+ }
336
+
274
337
  export class Setting {
275
338
  constructor(options: {
276
339
  height?: string,