siyuan 1.1.4 → 1.1.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,16 @@
1
1
  # Changelog
2
2
 
3
- ## v1.1.5
3
+ ## v1.1.6 2025-12-02
4
+
5
+ * [Synchronize config, constants, and protyle](https://github.com/siyuan-note/petal/issues/42)
6
+ * [Improve code block language selection](https://github.com/siyuan-note/siyuan/pull/15966)
7
+ * [Add onDataChanged method to handle data changes in the plugin](https://github.com/siyuan-note/siyuan/pull/16244)
8
+
9
+ ## v1.1.5 2025-09-09
10
+
11
+ * [Adjust imports to separate type and general](https://github.com/siyuan-note/petal/pull/41)
12
+ * [Supplement missing attributes](https://github.com/siyuan-note/petal/issues/40)
13
+ * [Add plugin function `expandDocTree`](https://github.com/siyuan-note/siyuan/issues/15639)
4
14
 
5
15
  ## v1.1.4 2025-09-02
6
16
 
package/package.json CHANGED
@@ -12,7 +12,7 @@
12
12
  "README.md",
13
13
  "siyuan.d.ts"
14
14
  ],
15
- "version": "1.1.4",
15
+ "version": "1.1.6",
16
16
  "repository": {
17
17
  "type": "git",
18
18
  "url": "git+https://github.com/siyuan-note/petal.git"
package/siyuan.d.ts CHANGED
@@ -1,26 +1,30 @@
1
- import {
1
+ import type {
2
2
  IGetDocInfo,
3
3
  IGetTreeStat,
4
4
  IMenuBaseDetail,
5
- Config,
6
- Custom,
7
- Dock,
8
5
  IMenu,
9
6
  IObject,
10
7
  IPosition,
11
8
  ISiyuan,
12
9
  IWebSocketData,
13
10
  IProtyle,
11
+ IProtyleOptions,
12
+ TProtyleAction,
13
+ IMenuItem,
14
+ IRefDefs,
15
+ } from "./types";
16
+ import {
17
+ Config,
18
+ Custom,
14
19
  Lute,
15
20
  Protyle,
16
21
  Toolbar,
17
- IProtyleOptions,
18
- TProtyleAction,
19
22
  subMenu,
20
23
  App,
21
24
  Files,
22
- Tab, Model,
23
- IMenuItem, IRefDefs, MobileCustom,
25
+ Tab,
26
+ Model,
27
+ MobileCustom,
24
28
  } from "./types";
25
29
 
26
30
  export * from "./types";
@@ -204,7 +208,7 @@ export interface IEventBusMap {
204
208
  "sync-fail": IWebSocketData;
205
209
  "mobile-keyboard-show": void;
206
210
  "mobile-keyboard-hide": void;
207
- "code-language-update": { languages: string[] };
211
+ "code-language-update": { languages: string[], type: "init" | "match", listElement: HTMLElement, value: string };
208
212
  "code-language-change": {
209
213
  language: string,
210
214
  languageElements: HTMLElement[],
@@ -296,6 +300,11 @@ export function getActiveTab(wndActive?: boolean): Tab;
296
300
  */
297
301
  export function getActiveEditor(wndActive?: boolean): Protyle;
298
302
 
303
+ export function expandDocTree(options: {
304
+ id: string,
305
+ isSetCurrent?: boolean
306
+ }): void;
307
+
299
308
  export function openMobileFileById(app: App, id: string, action?: TProtyleAction[]): void;
300
309
 
301
310
  export function openTab(options: {
@@ -419,6 +428,8 @@ export abstract class Plugin {
419
428
 
420
429
  onload(): void;
421
430
 
431
+ onDataChanged(): void
432
+
422
433
  onunload(): void;
423
434
 
424
435
  uninstall(): void;
package/types/config.d.ts CHANGED
@@ -67,7 +67,7 @@ export namespace Config {
67
67
  */
68
68
  openHelp: boolean;
69
69
  /**
70
- * Publishing service
70
+ * Publish service
71
71
  * 发布服务
72
72
  */
73
73
  publish: IPublish;
@@ -263,6 +263,14 @@ export namespace Config {
263
263
  * The version number of the theme currently in use
264
264
  */
265
265
  themeVer: string;
266
+ statusBar: IAppearanceStatusBar;
267
+ }
268
+
269
+ export interface IAppearanceStatusBar {
270
+ msgTaskDatabaseIndexCommitDisabled: boolean;
271
+ msgTaskHistoryDatabaseIndexCommitDisabled: boolean;
272
+ msgTaskAssetDatabaseIndexCommitDisabled: boolean;
273
+ msgTaskHistoryGenerateFileDisabled: boolean;
266
274
  }
267
275
 
268
276
  /**
@@ -365,6 +373,14 @@ export namespace Config {
365
373
  * Whether the backlink contains children
366
374
  */
367
375
  backlinkContainChildren: boolean;
376
+ /**
377
+ * Backlink sort mode
378
+ */
379
+ backlinkSort: number;
380
+ /**
381
+ * Backmention sort mode
382
+ */
383
+ backmentionSort: number;
368
384
  /**
369
385
  * The maximum length of the dynamic anchor text for block references
370
386
  */
@@ -402,6 +418,13 @@ export namespace Config {
402
418
  * Whether the embedded block displays breadcrumbs
403
419
  */
404
420
  embedBlockBreadcrumb: boolean;
421
+ /**
422
+ * Heading embed mode for embedded blocks
423
+ * - `0`: Show title with blocks below (default)
424
+ * - `1`: Show only title
425
+ * - `2`: Show only blocks below title
426
+ */
427
+ headingEmbedMode: number;
405
428
  /**
406
429
  * Common emoji icons
407
430
  */
@@ -646,6 +669,14 @@ export namespace Config {
646
669
  * Whether to save the content of the .sy file as a single-line JSON object
647
670
  */
648
671
  useSingleLineSave: boolean;
672
+ /**
673
+ * The .sy and database .json files larger than this value will prompt a warning (unit: MB)
674
+ */
675
+ largeFileWarningSize: number;
676
+ /**
677
+ * Whether to create new documents at the top of the document tree
678
+ */
679
+ createDocAtTop: boolean;
649
680
  }
650
681
 
651
682
  /**
@@ -992,29 +1023,35 @@ export namespace Config {
992
1023
  * SiYuan general shortcut keys
993
1024
  */
994
1025
  export interface IKeymapGeneral extends IKeys {
995
- addToDatabase: IKey;
996
- backlinks: IKey;
997
- bookmark: IKey;
998
- closeAll: IKey;
999
- closeLeft: IKey;
1000
- closeOthers: IKey;
1001
- closeRight: IKey;
1002
- closeTab: IKey;
1003
- closeUnmodified: IKey;
1026
+ mainMenu: IKey;
1004
1027
  commandPanel: IKey;
1005
- config: IKey;
1006
- dailyNote: IKey;
1007
- dataHistory: IKey;
1008
1028
  editReadonly: IKey;
1009
- enter: IKey;
1029
+ syncNow: IKey;
1010
1030
  enterBack: IKey;
1031
+ enter: IKey;
1032
+ goForward: IKey;
1033
+ goBack: IKey;
1034
+ newFile: IKey;
1035
+ search: IKey;
1036
+ globalSearch: IKey;
1037
+ stickSearch: IKey;
1038
+ replace: IKey;
1039
+ closeTab: IKey;
1011
1040
  fileTree: IKey;
1041
+ outline: IKey;
1042
+ bookmark: IKey;
1043
+ tag: IKey;
1044
+ dailyNote: IKey;
1045
+ inbox: IKey;
1046
+ backlinks: IKey;
1047
+ graphView: IKey;
1012
1048
  globalGraph: IKey;
1013
- globalSearch: IKey;
1014
- goBack: IKey;
1015
- goForward: IKey;
1016
- goToEditTabNext: IKey;
1017
- goToEditTabPrev: IKey;
1049
+ riffCard: IKey;
1050
+ config: IKey;
1051
+ dataHistory: IKey;
1052
+ toggleWin: IKey;
1053
+ lockScreen: IKey;
1054
+ recentDocs: IKey;
1018
1055
  goToTab1: IKey;
1019
1056
  goToTab2: IKey;
1020
1057
  goToTab3: IKey;
@@ -1026,28 +1063,25 @@ export namespace Config {
1026
1063
  goToTab9: IKey;
1027
1064
  goToTabNext: IKey;
1028
1065
  goToTabPrev: IKey;
1029
- graphView: IKey;
1030
- inbox: IKey;
1031
- lockScreen: IKey;
1032
- mainMenu: IKey;
1066
+ goToEditTabNext: IKey;
1067
+ goToEditTabPrev: IKey;
1068
+ recentClosed: IKey;
1033
1069
  move: IKey;
1034
- newFile: IKey;
1035
- outline: IKey;
1036
- recentDocs: IKey;
1037
- replace: IKey;
1038
- riffCard: IKey;
1039
- search: IKey;
1040
1070
  selectOpen1: IKey;
1071
+ toggleDock: IKey;
1041
1072
  splitLR: IKey;
1042
- splitMoveB: IKey;
1043
1073
  splitMoveR: IKey;
1044
1074
  splitTB: IKey;
1045
- stickSearch: IKey;
1046
- syncNow: IKey;
1075
+ splitMoveB: IKey;
1076
+ closeOthers: IKey;
1077
+ closeAll: IKey;
1078
+ closeUnmodified: IKey;
1079
+ closeLeft: IKey;
1080
+ closeRight: IKey;
1047
1081
  tabToWindow: IKey;
1048
- tag: IKey;
1049
- toggleDock: IKey;
1050
- toggleWin: IKey;
1082
+ addToDatabase: IKey;
1083
+ unsplit: IKey;
1084
+ unsplitAll: IKey;
1051
1085
  }
1052
1086
 
1053
1087
  /**
@@ -1077,29 +1111,29 @@ export namespace Config {
1077
1111
  export type TLogLevel = "off" | "trace" | "debug" | "info" | "warn" | "error" | "fatal";
1078
1112
 
1079
1113
  /**
1080
- * Publishing service
1114
+ * Publish service
1081
1115
  */
1082
1116
  export interface IPublish {
1083
1117
  /**
1084
- * Whether to open the publishing service
1118
+ * Whether to open the publish service
1085
1119
  */
1086
1120
  enable: boolean;
1087
1121
  /**
1088
- * The basic authentication settings of publishing service
1122
+ * The basic authentication settings of publish service
1089
1123
  */
1090
1124
  auth: IPublishAuth;
1091
1125
  /**
1092
- * Port on which the publishing service listens
1126
+ * Port on which the publish service listens
1093
1127
  */
1094
1128
  port: number;
1095
1129
  }
1096
1130
 
1097
1131
  /**
1098
- * Publishing service authentication settings
1132
+ * Publish service authentication settings
1099
1133
  */
1100
1134
  export interface IPublishAuth {
1101
1135
  /**
1102
- * Whether to enable basic authentication for publishing services
1136
+ * Whether to enable basic authentication for publish services
1103
1137
  */
1104
1138
  enable: boolean;
1105
1139
  /**
@@ -1,4 +1,4 @@
1
- import {IObject, Config} from "../siyuan";
1
+ import type {IObject, Config} from "../siyuan";
2
2
 
3
3
  const altNumber = navigator.platform.toUpperCase().indexOf("MAC") > -1 ? "⌃" : "⌥";
4
4
 
@@ -150,6 +150,7 @@ export abstract class Constants {
150
150
  public static readonly LOCAL_IMAGES = "local-images";
151
151
  public static readonly LOCAL_EMOJIS = "local-emojis";
152
152
  public static readonly LOCAL_MOVE_PATH = "local-move-path";
153
+ public static readonly LOCAL_RECENT_DOCS = "local-recent-docs";
153
154
 
154
155
  // dialog
155
156
  public static readonly DIALOG_CONFIRM = "dialog-confirm";
@@ -209,6 +210,69 @@ export abstract class Constants {
209
210
  public static readonly DIALOG_OPENWORKSPACE = "dialog-openworkspace"; // 打开工作空间
210
211
  public static readonly DIALOG_SAVEWORKSPACE = "dialog-saveworkspace"; // 保存工作空间
211
212
 
213
+ // menu
214
+ public static readonly MENU_BAR_WORKSPACE = "barWorkspace"; // 顶栏主菜单
215
+ public static readonly MENU_BAR_PLUGIN = "topBarPlugin"; // 顶栏插件菜单
216
+ public static readonly MENU_BAR_ZOOM = "barZoom"; // 顶栏缩放菜单
217
+ public static readonly MENU_BAR_MODE = "barmode"; // 顶栏外观菜单
218
+ public static readonly MENU_BAR_MORE = "barmore"; // 顶栏更多菜单
219
+ public static readonly MENU_STATUS_HELP = "statusHelp"; // 状态栏帮助菜单
220
+ public static readonly MENU_STATUS_BACKGROUND_TASK = "statusBackgroundTask"; // 状态栏后台任务菜单
221
+ public static readonly MENU_DOCK_MOBILE = "dockMobileMenu"; // 移动端侧栏插件选项菜单
222
+
223
+ public static readonly MENU_BLOCK_SINGLE = "block-single"; // 单选块菜单
224
+ public static readonly MENU_BLOCK_MULTI = "block-multi"; // 多选块菜单
225
+ public static readonly MENU_TITLE = "titleMenu"; // 文档块菜单
226
+ public static readonly MENU_FROM_TITLE_PROTYLE = "title-protyle"; // 在 Protyle 触发的文档块菜单
227
+ public static readonly MENU_FROM_TITLE_BREADCRUMB = "title-breadcrumb"; // 在面包屑触发的文档块菜单
228
+ public static readonly MENU_BREADCRUMB_MORE = "breadcrumbMore"; // 面包屑更多菜单
229
+ public static readonly MENU_BREADCRUMB_MOBILE_PATH = "breadcrumb-mobile-path"; // 移动端面包屑菜单
230
+
231
+ public static readonly MENU_DOC_TREE_MORE = "docTreeMore"; // 侧栏文档树右键菜单
232
+ public static readonly MENU_FROM_DOC_TREE_MORE_NOTEBOOK = "tree-notebook"; // 侧栏文档树右键菜单,单个笔记本
233
+ public static readonly MENU_FROM_DOC_TREE_MORE_DOC = "tree-doc"; // 侧栏文档树右键菜单,单个文档
234
+ public static readonly MENU_FROM_DOC_TREE_MORE_ITEMS = "tree-items"; // 侧栏文档树右键菜单,多个文档或笔记本
235
+ public static readonly MENU_TAG = "tagMenu"; // 侧栏标签菜单
236
+ public static readonly MENU_BOOKMARK = "bookmarkMenu"; // 侧栏书签菜单
237
+ public static readonly MENU_OUTLINE_CONTEXT = "outline-context"; // 大纲标题右键菜单
238
+ public static readonly MENU_OUTLINE_EXPAND_LEVEL = "outline-expand-level"; // 大纲展开层级菜单
239
+
240
+ public static readonly MENU_AV_VIEW = "av-view"; // 数据库视图标题菜单
241
+ public static readonly MENU_AV_HEADER_CELL = "av-header-cell"; // 数据库字段标题菜单
242
+ public static readonly MENU_AV_HEADER_ADD = "av-header-add"; // 数据库添加字段菜单
243
+ public static readonly MENU_AV_ADD_FILTER = "av-add-filter"; // 数据库添加筛选条件菜单
244
+ public static readonly MENU_AV_ADD_SORT = "av-add-sort"; // 数据库添加排序条件菜单
245
+ public static readonly MENU_AV_COL_OPTION = "av-col-option"; // 数据库单选多选字段的选项编辑菜单
246
+ public static readonly MENU_AV_COL_FORMAT_NUMBER = "av-col-format-number"; // 数据库数字字段格式化菜单
247
+ public static readonly MENU_AV_GROUP_DATE = "avGroupDate"; // 数据库日期字段分组菜单的日期菜单
248
+ public static readonly MENU_AV_GROUP_SORT = "avGroupSort"; // 数据库日期字段分组菜单的排序菜单
249
+ public static readonly MENU_AV_ASSET_EDIT = "av-asset-edit"; // 数据库资源字段链接或资源文件菜单
250
+ public static readonly MENU_AV_CALC = "av-calc"; // 数据库计算菜单
251
+ public static readonly MENU_AV_PAGE_SIZE = "av-page-size"; // 数据库条目数菜单
252
+
253
+ public static readonly MENU_SEARCH_MORE = "searchMore"; // 搜索更多菜单
254
+ public static readonly MENU_SEARCH_METHOD = "searchMethod"; // 搜索方式菜单
255
+ public static readonly MENU_SEARCH_ASSET_MORE = "searchAssetMore"; // 资源文件搜索更多菜单
256
+ public static readonly MENU_SEARCH_ASSET_METHOD = "searchAssetMethod"; // 资源文件搜索方式菜单
257
+ public static readonly MENU_SEARCH_UNREF_MORE = "searchUnRefMore"; // 列出引用失效的块的更多菜单
258
+ public static readonly MENU_SEARCH_HISTORY = "search-history"; // 搜索历史菜单
259
+ public static readonly MENU_SEARCH_REPLACE_HISTORY = "search-replace-history"; // 替换历史菜单
260
+ public static readonly MENU_SEARCH_ASSET_HISTORY = "search-asset-history"; // 资源文件搜索历史菜单
261
+ public static readonly MENU_MOVE_PATH_HISTORY = "move-path-history"; // 移动文档窗口搜索历史菜单
262
+
263
+ public static readonly MENU_BACKGROUND_ASSET = "background-asset"; // 资源文件选择器菜单
264
+ public static readonly MENU_AI = "ai"; // 块 AI 菜单
265
+ public static readonly MENU_TAB = "tab"; // 页签右键菜单
266
+ public static readonly MENU_TAB_LIST = "tabList"; // 页签切换菜单
267
+
268
+ public static readonly MENU_INLINE_CONTEXT = "inline-context"; // 文本右键菜单
269
+ public static readonly MENU_INLINE_IMG = "inline-img"; // 图片元素菜单
270
+ public static readonly MENU_INLINE_FILE_ANNOTATION_REF = "inline-file-annotation-ref"; // PDF 标注元素菜单
271
+ public static readonly MENU_INLINE_REF = "inline-block-ref"; // 块引用元素菜单
272
+ public static readonly MENU_INLINE_A = "inline-a"; // 超链接元素菜单
273
+ public static readonly MENU_INLINE_TAG = "inline-tag"; // 行级标签元素菜单
274
+ public static readonly MENU_INLINE_MATH = "inline-math"; // 行级公式元素菜单
275
+
212
276
  // timeout
213
277
  public static readonly TIMEOUT_OPENDIALOG = 50;
214
278
  public static readonly TIMEOUT_DBLCLICK = 190;
@@ -408,6 +472,7 @@ export abstract class Constants {
408
472
  goToTabPrev: {default: "⇧⌘[", custom: "⇧⌘["},
409
473
  goToEditTabNext: {default: "⌃⇥", custom: "⌃⇥"},
410
474
  goToEditTabPrev: {default: "⌃⇧⇥", custom: "⌃⇧⇥"},
475
+ recentClosed: {default: "⇧⌘T", custom: "⇧⌘T"},
411
476
  move: {default: "", custom: ""},
412
477
  selectOpen1: {default: "", custom: ""},
413
478
  toggleDock: {default: "", custom: ""},
@@ -527,10 +592,10 @@ export abstract class Constants {
527
592
  checkToggle: {default: "⌘↩", custom: "⌘↩"},
528
593
  },
529
594
  table: {
530
- insertRowAbove: {default: "⇧⌘T", custom: "⇧⌘T"},
531
- insertRowBelow: {default: "⇧⌘D", custom: "⇧⌘D"},
532
- insertColumnLeft: {default: "⇧⌘L", custom: "⇧⌘L"},
533
- insertColumnRight: {default: "⇧⌘R", custom: "⇧⌘R"},
595
+ insertRowAbove: {default: "", custom: ""},
596
+ insertRowBelow: {default: "", custom: ""},
597
+ insertColumnLeft: {default: "", custom: ""},
598
+ insertColumnRight: {default: "", custom: ""},
534
599
  moveToUp: {default: "⌥⌘T", custom: "⌥⌘T"},
535
600
  moveToDown: {default: "⌥⌘B", custom: "⌥⌘B"},
536
601
  moveToLeft: {default: "⌥⌘L", custom: "⌥⌘L"},
@@ -715,7 +780,7 @@ export abstract class Constants {
715
780
  </svg>`;
716
781
 
717
782
  // assets
718
- public static readonly SIYUAN_ASSETS_IMAGE: string[] = [".apng", ".ico", ".cur", ".jpg", ".jpe", ".jpeg", ".jfif", ".pjp", ".pjpeg", ".png", ".gif", ".webp", ".bmp", ".svg", ".avif"];
783
+ public static readonly SIYUAN_ASSETS_IMAGE: string[] = [".apng", ".ico", ".cur", ".jpg", ".jpe", ".jpeg", ".jfif", ".pjp", ".pjpeg", ".png", ".gif", ".webp", ".bmp", ".svg", ".avif", ".tiff", ".tif"];
719
784
  public static readonly SIYUAN_ASSETS_AUDIO: string[] = [".mp3", ".wav", ".ogg", ".m4a", ".aac", ".flac"];
720
785
  public static readonly SIYUAN_ASSETS_VIDEO: string[] = [".mov", ".weba", ".mkv", ".mp4", ".webm"];
721
786
  public static readonly SIYUAN_ASSETS_EXTS: string[] = [".pdf"].concat(Constants.SIYUAN_ASSETS_IMAGE).concat(Constants.SIYUAN_ASSETS_AUDIO).concat(Constants.SIYUAN_ASSETS_VIDEO);
package/types/index.d.ts CHANGED
@@ -211,7 +211,7 @@ export interface ISiyuan {
211
211
  }[]
212
212
  },
213
213
  dragElement?: HTMLElement,
214
- currentDragOverTabHeadersElement?: HTMLElement,
214
+ currentDragOverTabHeadersElement?: HTMLElement
215
215
  layout?: {
216
216
  layout?: Layout,
217
217
  centerLayout?: Layout,
@@ -240,6 +240,10 @@ export interface ISiyuan {
240
240
  blockPanels: BlockPanel[],
241
241
  dialogs: Dialog[],
242
242
  viewer?: Viewer
243
+ /**
244
+ * 是否在发布服务下访问
245
+ */
246
+ isPublish?: boolean;
243
247
  }
244
248
 
245
249
  export interface IMenu {
@@ -5,217 +5,6 @@ import {
5
5
  } from "./../siyuan";
6
6
  import {Model} from "./layout/Model";
7
7
 
8
- type TTurnIntoOne = "BlocksMergeSuperBlock" | "Blocks2ULs" | "Blocks2OLs" | "Blocks2TLs" | "Blocks2Blockquote"
9
-
10
- type TTurnIntoOneSub = "row" | "col"
11
-
12
- type TTurnInto = "Blocks2Ps" | "Blocks2Hs"
13
-
14
- type THintSource = "search" | "av" | "hint";
15
-
16
- export type TProtyleAction = "cb-get-append" | // 向下滚动加载
17
- "cb-get-before" | // 向上滚动加载
18
- "cb-get-unchangeid" | // 上下滚动,定位时不修改 blockid
19
- "cb-get-hl" | // 高亮
20
- "cb-get-focus" | // 光标定位
21
- "cb-get-focusfirst" | // 动态定位到第一个块
22
- "cb-get-setid" | // 无折叠大纲点击 重置 blockid
23
- "cb-get-outline" | // 大纲点击
24
- "cb-get-all" | // 获取所有块
25
- "cb-get-backlink" | // 悬浮窗为传递型需展示上下文
26
- "cb-get-unundo" | // 不需要记录历史
27
- "cb-get-scroll" | // 滚动到指定位置,用于直接打开文档,必有 rootID
28
- "cb-get-context" | // 包含上下文
29
- "cb-get-rootscroll" | // 如果为 rootID 就滚动到指定位置,必有 rootID
30
- "cb-get-html" | // 直接渲染,不需要再 /api/block/getDocInfo,否则搜索表格无法定位
31
- "cb-get-history" | // 历史渲染
32
- "cb-get-opennew" // 编辑器只读后新建文件需为临时解锁状态 & https://github.com/siyuan-note/siyuan/issues/12197
33
-
34
- export type TEditorMode = "preview" | "wysiwyg"
35
-
36
- interface ILuteNode {
37
- TokensStr: () => string;
38
- __internal_object__: {
39
- Parent: {
40
- Type: number,
41
- },
42
- HeadingLevel: string,
43
- };
44
- }
45
-
46
- /** @link https://ld246.com/article/1549638745630#options-toolbar */
47
- interface IMenuItem {
48
- /** 唯一标示 */
49
- name: string;
50
- /** 提示 */
51
- tip?: string;
52
- /** 语言 key */
53
- lang?: string;
54
- /** svg 图标 */
55
- icon?: string;
56
- /** 快捷键 */
57
- hotkey?: string;
58
- /** 提示的位置 */
59
- tipPosition?: string;
60
-
61
- click?(protyle: Protyle): void;
62
- }
63
-
64
- interface IBreadcrumb {
65
- id: string,
66
- name: string,
67
- type: string,
68
- subType: string,
69
- children: []
70
- }
71
-
72
- interface IOperations {
73
- doOperations: IOperation[],
74
- undoOperations: IOperation[]
75
- }
76
-
77
- interface IHintData {
78
- id?: string;
79
- html: string;
80
- value: string;
81
- filter?: string[];
82
- focus?: boolean;
83
- }
84
-
85
- export interface IProtyleOptions {
86
- history?: {
87
- created?: string
88
- snapshot?: string
89
- },
90
- backlinkData?: {
91
- blockPaths: IBreadcrumb[],
92
- dom: string
93
- expand: boolean
94
- }[],
95
- action?: TProtyleAction[],
96
- mode?: TEditorMode,
97
- blockId?: string
98
- rootId?: string
99
- originalRefBlockIDs?: IObject
100
- key?: string
101
- defId?: string
102
- render?: {
103
- background?: boolean
104
- title?: boolean
105
- gutter?: boolean
106
- scroll?: boolean
107
- breadcrumb?: boolean
108
- breadcrumbDocName?: boolean
109
- }
110
- /** 内部调试时使用 */
111
- _lutePath?: string;
112
- /** 是否显示日志。默认值: false */
113
- debugger?: boolean;
114
- /** 是否启用打字机模式。默认值: false */
115
- typewriterMode?: boolean;
116
- /** 多语言。默认值: 'zh_CN' */
117
- lang?: string;
118
- /** @link https://ld246.com/article/1549638745630#options-toolbar */
119
- toolbar?: Array<string | IMenuItem>;
120
- /** @link https://ld246.com/article/1549638745630#options-classes */
121
- classes?: {
122
- preview?: string;
123
- };
124
- click?: {
125
- /** 点击末尾是否阻止插入新块 */
126
- preventInsetEmptyBlock?: boolean
127
- }
128
-
129
- handleEmptyContent?(): void
130
-
131
- /** 编辑器异步渲染完成后的回调方法 */
132
- after?(protyle: Protyle): void;
133
- }
134
-
135
- // REF: https://github.com/siyuan-note/siyuan/blob/dev/app/src/types/protyle.d.ts
136
- export interface IProtyle {
137
- getInstance: () => Protyle,
138
- observerLoad?: ResizeObserver,
139
- observer?: ResizeObserver,
140
- app: App,
141
- transactionTime: number,
142
- id: string,
143
- query?: {
144
- key: string,
145
- method: number
146
- types: Config.IUILayoutTabSearchConfigTypes
147
- },
148
- block: {
149
- id?: string,
150
- scroll?: boolean
151
- parentID?: string,
152
- parent2ID?: string,
153
- rootID?: string,
154
- showAll?: boolean
155
- mode?: number
156
- blockCount?: number
157
- action?: string[]
158
- },
159
- disabled: boolean,
160
- selectElement?: HTMLElement,
161
- ws?: Model,
162
- notebookId?: string
163
- path?: string
164
- model?: Editor,
165
- updated: boolean;
166
- element: HTMLElement;
167
- scroll?: Scroll,
168
- gutter?: Gutter,
169
- breadcrumb?: Breadcrumb,
170
- title?: Title,
171
- background?: Background,
172
- contentElement?: HTMLElement,
173
- options: IProtyleOptions;
174
- lute?: Lute;
175
- toolbar?: Toolbar,
176
- preview?: Preview;
177
- hint?: Hint;
178
- upload?: Upload;
179
- undo?: Undo;
180
- wysiwyg?: WYSIWYG
181
- }
182
-
183
- declare class Viz {
184
- public static instance(): Promise<Viz>;
185
-
186
- renderSVGElement: (code: string) => SVGElement;
187
- }
188
-
189
- declare class Viewer {
190
- public destroyed: boolean;
191
-
192
- constructor(element: Element, options: {
193
- title: [number, (image: HTMLImageElement, imageData: IObject) => string],
194
- button: boolean,
195
- initialViewIndex?: number,
196
- transition: boolean,
197
- hidden: () => void,
198
- toolbar: {
199
- zoomIn: boolean,
200
- zoomOut: boolean,
201
- oneToOne: boolean,
202
- reset: boolean,
203
- prev: boolean,
204
- play: boolean,
205
- next: boolean,
206
- rotateLeft: boolean,
207
- rotateRight: boolean,
208
- flipHorizontal: boolean,
209
- flipVertical: boolean,
210
- close: () => void
211
- }
212
- })
213
-
214
- public destroy(): void
215
-
216
- public show(): void
217
- }
218
-
219
8
  declare class Breadcrumb {
220
9
  element: HTMLElement;
221
10
 
@@ -342,6 +131,11 @@ declare class Preview {
342
131
  private processZHTable;
343
132
  }
344
133
 
134
+ interface IOperations {
135
+ doOperations: IOperation[],
136
+ undoOperations: IOperation[]
137
+ }
138
+
345
139
  declare class Undo {
346
140
  private hasUndo;
347
141
  redoStack: IOperations[];
@@ -431,36 +225,264 @@ export declare class Toolbar {
431
225
  public showContent(protyle: IProtyle, range: Range, nodeElement: Element): void
432
226
  }
433
227
 
434
- export class Lute {
435
- public static WalkStop: number;
436
- public static WalkSkipChildren: number;
437
- public static WalkContinue: number;
438
- public static Version: string;
439
- public static Caret: string;
440
-
441
- public static New(): Lute;
228
+ export class Protyle {
442
229
 
443
- public static EChartsMindmapStr(text: string): string;
230
+ public readonly version: string;
231
+ public protyle: IProtyle;
444
232
 
445
- public static NewNodeID(): string;
233
+ constructor(app: App, element: HTMLElement, options?: IProtyleOptions)
446
234
 
447
- public static Sanitize(html: string): string;
235
+ /** 聚焦到编辑器 */
236
+ public focus(): void
448
237
 
449
- public static EscapeHTMLStr(str: string): string;
238
+ /** 上传是否还在进行中 */
239
+ public isUploading(): boolean
450
240
 
451
- public static UnEscapeHTMLStr(str: string): string;
241
+ /** 清空 undo & redo 栈 */
242
+ public clearStack(): void
452
243
 
453
- public static GetHeadingID(node: ILuteNode): string;
244
+ /** 销毁编辑器 */
245
+ public destroy(): void
454
246
 
455
- public static BlockDOM2Content(html: string): string;
247
+ public resize(): void
456
248
 
457
- private constructor();
249
+ public reload(focus: boolean): void
458
250
 
459
- public BlockDOM2Content(text: string): string;
251
+ /**
252
+ * @param {boolean} [isBlock=false]
253
+ * @param {boolean} [useProtyleRange=false]
254
+ */
255
+ public insert(html: string, isBlock?: boolean, useProtyleRange?: boolean): void
460
256
 
461
- public BlockDOM2EscapeMarkerContent(text: string): string;
257
+ public transaction(doOperations: IOperation[], undoOperations?: IOperation[]): void;
462
258
 
463
- public SetSpin(enable: boolean): void;
259
+ /**
260
+ * 多个块转换为一个块
261
+ * @param {TTurnIntoOneSub} [subType] type 为 "BlocksMergeSuperBlock" 时必传
262
+ */
263
+ public turnIntoOneTransaction(selectsElement: Element[], type: TTurnIntoOne, subType?: TTurnIntoOneSub): void
264
+
265
+ /**
266
+ * 多个块转换
267
+ * @param {Element} [nodeElement] 优先使用包含 protyle-wysiwyg--select 的块,否则使用 nodeElement 单块
268
+ * @param type
269
+ * @param {number} [subType] type 为 "Blocks2Hs" 时必传
270
+ */
271
+ public turnIntoTransaction(nodeElement: Element, type: TTurnInto, subType?: number): void
272
+
273
+ public updateTransaction(id: string, newHTML: string, html: string): void
274
+
275
+ public updateBatchTransaction(nodeElements: Element[], cb: (e: HTMLElement) => void): void
276
+
277
+ public getRange(element: Element): Range
278
+
279
+ public hasClosestBlock(element: Node): false | HTMLElement
280
+
281
+ /**
282
+ * @param {boolean} [toStart=true]
283
+ */
284
+ public focusBlock(element: Element, toStart?: boolean): false | Range
285
+
286
+ public disable(): void
287
+
288
+ public enable(): void
289
+
290
+ public renderAVAttribute(element: HTMLElement, id: string, cb?: (element: HTMLElement) => void): void
291
+ }
292
+
293
+ interface ILuteNode {
294
+ TokensStr: () => string;
295
+ __internal_object__: {
296
+ Parent: {
297
+ Type: number,
298
+ },
299
+ HeadingLevel: string,
300
+ };
301
+ }
302
+
303
+ type THintSource = "search" | "av" | "hint";
304
+
305
+ type TTurnIntoOne = "BlocksMergeSuperBlock" | "Blocks2ULs" | "Blocks2OLs" | "Blocks2TLs" | "Blocks2Blockquote"
306
+
307
+ type TTurnIntoOneSub = "row" | "col"
308
+
309
+ type TTurnInto = "Blocks2Ps" | "Blocks2Hs"
310
+
311
+ type TEditorMode = "preview" | "wysiwyg"
312
+
313
+ type ILuteRenderCallback = (node: ILuteNode, entering: boolean) => [string, number];
314
+
315
+ export type TProtyleAction = "cb-get-append" | // 向下滚动加载
316
+ "cb-get-before" | // 向上滚动加载
317
+ "cb-get-unchangeid" | // 上下滚动,定位时不修改 blockid
318
+ "cb-get-hl" | // 高亮
319
+ "cb-get-focus" | // 光标定位
320
+ "cb-get-focusfirst" | // 动态定位到第一个块
321
+ "cb-get-setid" | // 无折叠大纲点击 重置 blockid
322
+ "cb-get-outline" | // 大纲点击
323
+ "cb-get-all" | // 获取所有块
324
+ "cb-get-backlink" | // 悬浮窗为传递型需展示上下文
325
+ "cb-get-unundo" | // 不需要记录历史
326
+ "cb-get-scroll" | // 滚动到指定位置,用于直接打开文档,必有 rootID
327
+ "cb-get-context" | // 包含上下文
328
+ "cb-get-rootscroll" | // 如果为 rootID 就滚动到指定位置,必有 rootID
329
+ "cb-get-html" | // 直接渲染,不需要再 /api/block/getDocInfo,否则搜索表格无法定位
330
+ "cb-get-history" | // 历史渲染
331
+ "cb-get-opennew" // 编辑器只读后新建文件需为临时解锁状态 & https://github.com/siyuan-note/siyuan/issues/12197
332
+
333
+ /** @link https://ld246.com/article/1588412297062 */
334
+ interface ILuteRender {
335
+ renderDocument?: ILuteRenderCallback;
336
+ renderParagraph?: ILuteRenderCallback;
337
+ renderText?: ILuteRenderCallback;
338
+ renderCodeBlock?: ILuteRenderCallback;
339
+ renderCodeBlockOpenMarker?: ILuteRenderCallback;
340
+ renderCodeBlockInfoMarker?: ILuteRenderCallback;
341
+ renderCodeBlockCode?: ILuteRenderCallback;
342
+ renderCodeBlockCloseMarker?: ILuteRenderCallback;
343
+ renderMathBlock?: ILuteRenderCallback;
344
+ renderMathBlockOpenMarker?: ILuteRenderCallback;
345
+ renderMathBlockContent?: ILuteRenderCallback;
346
+ renderMathBlockCloseMarker?: ILuteRenderCallback;
347
+ renderBlockquote?: ILuteRenderCallback;
348
+ renderBlockquoteMarker?: ILuteRenderCallback;
349
+ renderHeading?: ILuteRenderCallback;
350
+ renderHeadingC8hMarker?: ILuteRenderCallback;
351
+ renderList?: ILuteRenderCallback;
352
+ renderListItem?: ILuteRenderCallback;
353
+ renderTaskListItemMarker?: ILuteRenderCallback;
354
+ renderThematicBreak?: ILuteRenderCallback;
355
+ renderHTML?: ILuteRenderCallback;
356
+ renderTable?: ILuteRenderCallback;
357
+ renderTableHead?: ILuteRenderCallback;
358
+ renderTableRow?: ILuteRenderCallback;
359
+ renderTableCell?: ILuteRenderCallback;
360
+ renderCodeSpan?: ILuteRenderCallback;
361
+ renderCodeSpanOpenMarker?: ILuteRenderCallback;
362
+ renderCodeSpanContent?: ILuteRenderCallback;
363
+ renderCodeSpanCloseMarker?: ILuteRenderCallback;
364
+ renderInlineMath?: ILuteRenderCallback;
365
+ renderInlineMathOpenMarker?: ILuteRenderCallback;
366
+ renderInlineMathContent?: ILuteRenderCallback;
367
+ renderInlineMathCloseMarker?: ILuteRenderCallback;
368
+ renderEmphasis?: ILuteRenderCallback;
369
+ renderEmAsteriskOpenMarker?: ILuteRenderCallback;
370
+ renderEmAsteriskCloseMarker?: ILuteRenderCallback;
371
+ renderEmUnderscoreOpenMarker?: ILuteRenderCallback;
372
+ renderEmUnderscoreCloseMarker?: ILuteRenderCallback;
373
+ renderStrong?: ILuteRenderCallback;
374
+ renderStrongA6kOpenMarker?: ILuteRenderCallback;
375
+ renderStrongA6kCloseMarker?: ILuteRenderCallback;
376
+ renderStrongU8eOpenMarker?: ILuteRenderCallback;
377
+ renderStrongU8eCloseMarker?: ILuteRenderCallback;
378
+ renderStrikethrough?: ILuteRenderCallback;
379
+ renderStrikethrough1OpenMarker?: ILuteRenderCallback;
380
+ renderStrikethrough1CloseMarker?: ILuteRenderCallback;
381
+ renderStrikethrough2OpenMarker?: ILuteRenderCallback;
382
+ renderStrikethrough2CloseMarker?: ILuteRenderCallback;
383
+ renderHardBreak?: ILuteRenderCallback;
384
+ renderSoftBreak?: ILuteRenderCallback;
385
+ renderInlineHTML?: ILuteRenderCallback;
386
+ renderLink?: ILuteRenderCallback;
387
+ renderOpenBracket?: ILuteRenderCallback;
388
+ renderCloseBracket?: ILuteRenderCallback;
389
+ renderOpenParen?: ILuteRenderCallback;
390
+ renderCloseParen?: ILuteRenderCallback;
391
+ renderLinkText?: ILuteRenderCallback;
392
+ renderLinkSpace?: ILuteRenderCallback;
393
+ renderLinkDest?: ILuteRenderCallback;
394
+ renderLinkTitle?: ILuteRenderCallback;
395
+ renderImage?: ILuteRenderCallback;
396
+ renderBang?: ILuteRenderCallback;
397
+ renderEmoji?: ILuteRenderCallback;
398
+ renderEmojiUnicode?: ILuteRenderCallback;
399
+ renderEmojiImg?: ILuteRenderCallback;
400
+ renderEmojiAlias?: ILuteRenderCallback;
401
+ renderBackslash?: ILuteRenderCallback;
402
+ renderBackslashContent?: ILuteRenderCallback;
403
+ }
404
+
405
+ interface IBreadcrumb {
406
+ id: string,
407
+ name: string,
408
+ type: string,
409
+ subType: string,
410
+ children: []
411
+ }
412
+
413
+ interface ILuteOptions extends IMarkdownConfig {
414
+ emojis: IObject;
415
+ emojiSite: string;
416
+ headingAnchor: boolean;
417
+ lazyLoadImage?: string;
418
+ }
419
+
420
+ declare class Viz {
421
+ public static instance(): Promise<Viz>;
422
+
423
+ renderSVGElement: (code: string) => SVGElement;
424
+ }
425
+
426
+ declare class Viewer {
427
+ public destroyed: boolean;
428
+
429
+ constructor(element: Element, options: {
430
+ title: [number, (image: HTMLImageElement, imageData: IObject) => string],
431
+ button: boolean,
432
+ initialViewIndex?: number,
433
+ transition: boolean,
434
+ hidden: () => void,
435
+ toolbar: {
436
+ zoomIn: boolean,
437
+ zoomOut: boolean,
438
+ oneToOne: boolean,
439
+ reset: boolean,
440
+ prev: boolean,
441
+ play: boolean,
442
+ next: boolean,
443
+ rotateLeft: boolean,
444
+ rotateRight: boolean,
445
+ flipHorizontal: boolean,
446
+ flipVertical: boolean,
447
+ close: () => void
448
+ }
449
+ })
450
+
451
+ public destroy(): void
452
+
453
+ public show(): void
454
+ }
455
+
456
+ export class Lute {
457
+ public static WalkStop: number;
458
+ public static WalkSkipChildren: number;
459
+ public static WalkContinue: number;
460
+ public static Version: string;
461
+ public static Caret: string;
462
+
463
+ public static New(): Lute;
464
+
465
+ public static EChartsMindmapStr(text: string): string;
466
+
467
+ public static NewNodeID(): string;
468
+
469
+ public static Sanitize(html: string): string;
470
+
471
+ public static EscapeHTMLStr(str: string): string;
472
+
473
+ public static UnEscapeHTMLStr(str: string): string;
474
+
475
+ public static GetHeadingID(node: ILuteNode): string;
476
+
477
+ public static BlockDOM2Content(html: string): string;
478
+
479
+ private constructor();
480
+
481
+ public BlockDOM2Content(text: string): string;
482
+
483
+ public BlockDOM2EscapeMarkerContent(text: string): string;
484
+
485
+ public SetSpin(enable: boolean): void;
464
486
 
465
487
  public SetTextMark(enable: boolean): void;
466
488
 
@@ -551,69 +573,268 @@ export class Lute {
551
573
  public HTML2Md(html: string): string;
552
574
 
553
575
  public HTML2BlockDOM(html: string): string;
554
- }
555
-
556
- export class Protyle {
557
-
558
- public readonly version: string;
559
- public protyle: IProtyle;
560
-
561
- constructor(app: App, element: HTMLElement, options?: IProtyleOptions)
562
-
563
- /** 聚焦到编辑器 */
564
- public focus(): void
565
-
566
- /** 上传是否还在进行中 */
567
- public isUploading(): boolean
568
576
 
569
- /** 清空 undo & redo 栈 */
570
- public clearStack(): void
577
+ public SetUnorderedListMarker(marker: string): void;
578
+ }
571
579
 
572
- /** 销毁编辑器 */
573
- public destroy(): void
580
+ declare const webkitAudioContext: {
581
+ prototype: AudioContext
582
+ new(contextOptions?: AudioContextOptions): AudioContext,
583
+ };
584
+
585
+ /** @link https://ld246.com/article/1549638745630#options-upload */
586
+ interface IUpload {
587
+ /** 上传 url */
588
+ url?: string;
589
+ /** 上传文件最大 Byte */
590
+ max?: number;
591
+ /** 剪切板中包含图片地址时,使用此 url 重新上传 */
592
+ linkToImgUrl?: string;
593
+ /** CORS 上传验证,头为 X-Upload-Token */
594
+ token?: string;
595
+ /** 文件上传类型,同 [input accept](https://www.w3schools.com/tags/att_input_accept.asp) */
596
+ accept?: string;
597
+ /** 跨站点访问控制。默认值: false */
598
+ withCredentials?: boolean;
599
+ /** 请求头设置 */
600
+ headers?: IObject;
601
+ /** 额外请求参数 */
602
+ extraData?: { [key: string]: string | Blob };
603
+ /** 上传字段名。默认值:file[] */
604
+ fieldName?: string;
605
+
606
+ /** 每次上传前都会重新设置请求头 */
607
+ setHeaders?(): IObject;
608
+
609
+ /** 上传成功回调 */
610
+ success?(editor: HTMLDivElement, msg: string): void;
611
+
612
+ /** 上传失败回调 */
613
+ error?(msg: string): void;
614
+
615
+ /** 文件名安全处理。 默认值: name => name.replace(/\W/g, '') */
616
+ filename?(name: string): string;
617
+
618
+ /** 校验,成功时返回 true 否则返回错误信息 */
619
+ validate?(files: File[]): string | boolean;
620
+
621
+ /** 自定义上传,当发生错误时返回错误信息 */
622
+ handler?(files: File[]): string | null;
623
+
624
+ /** 对服务端返回的数据进行转换,以满足内置的数据结构 */
625
+ format?(files: File[], responseText: string): string;
626
+
627
+ /** 将上传的文件处理后再返回 */
628
+ file?(files: File[]): File[];
629
+
630
+ /** 图片地址上传后的回调 */
631
+ linkToImgCallback?(responseText: string): void;
632
+ }
574
633
 
575
- public resize(): void
634
+ interface IScrollAttr {
635
+ rootId: string,
636
+ startId: string,
637
+ endId: string
638
+ scrollTop: number,
639
+ focusId?: string,
640
+ focusStart?: number
641
+ focusEnd?: number
642
+ zoomInId?: string
643
+ }
576
644
 
577
- public reload(focus: boolean): void
645
+ /** @link https://ld246.com/article/1549638745630#options-toolbar */
646
+ interface IMenuItem {
647
+ /** 唯一标示 */
648
+ name: string;
649
+ /** 提示 */
650
+ tip?: string;
651
+ /** 语言 key */
652
+ lang?: string;
653
+ /** svg 图标 */
654
+ icon?: string;
655
+ /** 快捷键 */
656
+ hotkey?: string;
657
+ /** 提示的位置 */
658
+ tipPosition?: string;
578
659
 
579
- /**
580
- * @param {boolean} [isBlock=false]
581
- * @param {boolean} [useProtyleRange=false]
582
- */
583
- public insert(html: string, isBlock?: boolean, useProtyleRange?: boolean): void
660
+ click?(protyle: Protyle): void;
661
+ }
584
662
 
585
- public transaction(doOperations: IOperation[], undoOperations?: IOperation[]): void;
663
+ /** @link https://ld246.com/article/1549638745630#options-preview-markdown */
664
+ interface IMarkdownConfig {
665
+ /** 段落开头是否空两格。默认值: false */
666
+ paragraphBeginningSpace?: boolean;
667
+ /** 是否启用过滤 XSS。默认值: true */
668
+ sanitize?: boolean;
669
+ /** 为列表添加标记,以便[自定义列表样式](https://github.com/Vanessa219/vditor/issues/390) 默认值:false */
670
+ listStyle?: boolean;
671
+ }
586
672
 
587
- /**
588
- * 多个块转换为一个块
589
- * @param {TTurnIntoOneSub} [subType] type 为 "BlocksMergeSuperBlock" 时必传
590
- */
591
- public turnIntoOneTransaction(selectsElement: Element[], type: TTurnIntoOne, subType?: TTurnIntoOneSub): void
673
+ /** @link https://ld246.com/article/1549638745630#options-preview */
674
+ interface IPreview {
675
+ /** 预览 debounce 毫秒间隔。默认值: 1000 */
676
+ delay?: number;
677
+ /** 显示模式。默认值: 'both' */
678
+ mode?: "both" | "editor";
679
+ /** md 解析请求 */
680
+ url?: string;
681
+ /** @link https://ld246.com/article/1549638745630#options-preview-markdown */
682
+ markdown?: IMarkdownConfig;
683
+ /** @link https://ld246.com/article/1549638745630#options-preview-actions */
684
+ actions?: Array<IPreviewAction | IPreviewActionCustom>;
685
+
686
+ /** 渲染之前回调 */
687
+ transform?(html: string): string;
688
+ }
592
689
 
593
- /**
594
- * 多个块转换
595
- * @param {Element} [nodeElement] 优先使用包含 protyle-wysiwyg--select 的块,否则使用 nodeElement 单块
596
- * @param type
597
- * @param {number} [subType] type 为 "Blocks2Hs" 时必传
598
- */
599
- public turnIntoTransaction(nodeElement: Element, type: TTurnInto, subType?: number): void
690
+ type IPreviewAction = "desktop" | "tablet" | "mobile" | "mp-wechat" | "zhihu" | "yuque";
691
+
692
+ interface IPreviewActionCustom {
693
+ /** 键名 */
694
+ key: string;
695
+ /** 按钮文本 */
696
+ text: string;
697
+ /** 按钮 className 值 */
698
+ className?: string;
699
+ /** 点击回调 */
700
+ click: (key: string) => void;
701
+ }
600
702
 
601
- public updateTransaction(id: string, newHTML: string, html: string): void
703
+ interface IHintData {
704
+ id?: string;
705
+ html: string;
706
+ value: string;
707
+ filter?: string[];
708
+ focus?: boolean;
709
+ }
602
710
 
603
- public updateBatchTransaction(nodeElements: Element[], cb: (e: HTMLElement) => void): void
711
+ interface IHintExtend {
712
+ key: string;
604
713
 
605
- public getRange(element: Element): Range
714
+ hint?(value: string, protyle: IProtyle, source: THintSource): IHintData[];
715
+ }
606
716
 
607
- public hasClosestBlock(element: Node): false | HTMLElement
717
+ /** @link https://ld246.com/article/1549638745630#options-hint */
718
+ interface IHint {
719
+ /** 常用表情提示 HTML */
720
+ emojiTail?: string;
721
+ /** 提示 debounce 毫秒间隔。默认值: 200 */
722
+ delay?: number;
723
+ /** 默认表情,可从 [lute/emoji_map](https://github.com/88250/lute/blob/master/parse/emoji_map.go#L32) 中选取,也可自定义 */
724
+ emoji?: IObject;
725
+ emojiPath?: string;
726
+ extend?: IHintExtend[];
727
+ }
608
728
 
609
- /**
610
- * @param {boolean} [toStart=true]
611
- */
612
- public focusBlock(element: Element, toStart?: boolean): false | Range
729
+ /** @link https://ld246.com/article/1549638745630#options */
730
+ export interface IProtyleOptions {
731
+ history?: {
732
+ created?: string
733
+ snapshot?: string
734
+ },
735
+ backlinkData?: {
736
+ blockPaths: IBreadcrumb[],
737
+ dom: string
738
+ expand: boolean
739
+ }[],
740
+ action?: TProtyleAction[],
741
+ scrollPosition?: ScrollLogicalPosition,
742
+ mode?: TEditorMode,
743
+ blockId?: string
744
+ rootId?: string
745
+ originalRefBlockIDs?: IObject
746
+ key?: string
747
+ defIds?: string[]
748
+ render?: {
749
+ background?: boolean
750
+ title?: boolean
751
+ titleShowTop?: boolean
752
+ gutter?: boolean
753
+ scroll?: boolean
754
+ breadcrumb?: boolean
755
+ breadcrumbDocName?: boolean
756
+ hideTitleOnZoom?: boolean
757
+ }
758
+ /** 内部调试时使用 */
759
+ _lutePath?: string;
760
+ /** 是否启用打字机模式。默认值: false */
761
+ typewriterMode?: boolean;
762
+ /** 多语言。默认值: 'zh_CN' */
763
+ lang?: string;
764
+ /** @link https://ld246.com/article/1549638745630#options-toolbar */
765
+ toolbar?: Array<string | IMenuItem>;
766
+ /** @link https://ld246.com/article/1549638745630#options-preview */
767
+ preview?: IPreview;
768
+ /** @link https://ld246.com/article/1549638745630#options-hint */
769
+ hint?: IHint;
770
+ /** @link https://ld246.com/article/1549638745630#options-upload */
771
+ upload?: IUpload;
772
+ /** @link https://ld246.com/article/1549638745630#options-classes */
773
+ classes?: {
774
+ preview?: string;
775
+ };
776
+ click?: {
777
+ /** 点击末尾是否阻止插入新块 */
778
+ preventInsetEmptyBlock?: boolean
779
+ }
613
780
 
614
- public disable(): void
781
+ handleEmptyContent?(): void
615
782
 
616
- public enable(): void
783
+ /** 编辑器异步渲染完成后的回调方法 */
784
+ after?(protyle: Protyle): void;
785
+ }
617
786
 
618
- public renderAVAttribute(element: HTMLElement, id: string, cb?: (element: HTMLElement) => void): void
787
+ // REF: https://github.com/siyuan-note/siyuan/blob/dev/app/src/types/protyle.d.ts
788
+ export interface IProtyle {
789
+ highlight: {
790
+ mark: Highlight
791
+ markHL: Highlight
792
+ ranges: Range[]
793
+ rangeIndex: number
794
+ styleElement: HTMLStyleElement
795
+ }
796
+ getInstance: () => Protyle,
797
+ observerLoad?: ResizeObserver,
798
+ observer?: ResizeObserver,
799
+ app: App,
800
+ transactionTime: number,
801
+ id: string,
802
+ query?: {
803
+ key: string,
804
+ method: number
805
+ types: Config.IUILayoutTabSearchConfigTypes
806
+ },
807
+ block: {
808
+ id?: string,
809
+ scroll?: boolean
810
+ parentID?: string,
811
+ parent2ID?: string,
812
+ rootID?: string,
813
+ showAll?: boolean
814
+ mode?: number
815
+ blockCount?: number
816
+ action?: string[]
817
+ },
818
+ disabled: boolean,
819
+ selectElement?: HTMLElement,
820
+ ws?: Model,
821
+ notebookId?: string
822
+ path?: string
823
+ model?: Editor,
824
+ updated: boolean;
825
+ element: HTMLElement;
826
+ scroll?: Scroll,
827
+ gutter?: Gutter,
828
+ breadcrumb?: Breadcrumb,
829
+ title?: Title,
830
+ background?: Background,
831
+ contentElement?: HTMLElement,
832
+ options: IProtyleOptions;
833
+ lute?: Lute;
834
+ toolbar?: Toolbar,
835
+ preview?: Preview;
836
+ hint?: Hint;
837
+ upload?: Upload;
838
+ undo?: Undo;
839
+ wysiwyg?: WYSIWYG
619
840
  }