siyuan 1.2.1 → 1.2.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/types/index.d.ts CHANGED
@@ -14,6 +14,7 @@ import {Wnd} from "./layout/Wnd";
14
14
  import {Tab} from "./layout/Tab";
15
15
  import {BlockPanel} from "./block/Panel";
16
16
  import {Inbox} from "./layout/dock/Inbox";
17
+ import {Files} from "./layout/dock/Files";
17
18
  import {MobileOutline} from "./mobile/dock/MobileOutline";
18
19
  import {MobileFiles} from "./mobile/dock/MobileFiles";
19
20
  import {MobileBookmarks} from "./mobile/dock/MobileBookmarks";
@@ -22,6 +23,7 @@ import {MobileBacklinks} from "./mobile/dock/MobileBacklinks";
22
23
 
23
24
  export * from "./config";
24
25
  export * from "./events";
26
+ export * from "./kernel";
25
27
  export * from "./protyle";
26
28
  export * from "./response";
27
29
  export * from "./constants";
@@ -40,6 +42,9 @@ export * as platformUtils from "./platformUtils";
40
42
 
41
43
 
42
44
  type TDockPosition = "Left" | "Right" | "Bottom"
45
+ type TBazaarType = "templates" | "icons" | "widgets" | "themes" | "plugins"
46
+ type TRecentDocsSort = "viewedAt" | "closedAt" | "openAt" | "updated"
47
+ type TPublishAccessLevel = "public" | "protected" | "hidden" | "private" | "forbidden"
43
48
  type TAVView = "table" | "gallery" | "kanban"
44
49
  type TAVFilterOperator =
45
50
  "="
@@ -86,6 +91,7 @@ interface ILayoutOptions {
86
91
  }
87
92
 
88
93
  interface IOperationSrcs {
94
+ itemID: string,
89
95
  id: string,
90
96
  content?: string,
91
97
  isDetached: boolean
@@ -175,6 +181,12 @@ interface IAVTable extends IAVView {
175
181
  rowCount: number,
176
182
  }
177
183
 
184
+ interface IAVVirtualData {
185
+ renderedStart: number;
186
+ renderedEnd: number;
187
+ topSpacerHeight: number;
188
+ }
189
+
178
190
  interface IAVGallery extends IAVView {
179
191
  coverFrom: number; // 0:无,1:内容图,2:资源字段,3:内容块
180
192
  coverFromAssetKeyID?: string;
@@ -188,13 +200,29 @@ interface IAVGallery extends IAVView {
188
200
  cardCount: number,
189
201
  }
190
202
 
203
+ interface IAVKanban extends IAVView {
204
+ coverFrom: number; // 0:无,1:内容图,2:资源字段,3:内容块
205
+ coverFromAssetKeyID?: string;
206
+ cardSize: number; // 0:小卡片,1:中卡片,2:大卡片
207
+ cardAspectRatio: number;
208
+ displayFieldName: boolean;
209
+ fitImage: boolean;
210
+ cards: IAVGalleryItem[],
211
+ desc: string
212
+ fields: IAVColumn[]
213
+ cardCount: number,
214
+ fillColBackgroundColor: boolean
215
+ }
216
+
191
217
  interface IAVFilter {
192
- column: string,
193
- operator: TAVFilterOperator,
194
- quantifier?: string,
195
- value: IAVCellValue,
196
- relativeDate?: IAVRelativeDate
197
- relativeDate2?: IAVRelativeDate
218
+ column?: string, // 叶子节点:字段(列)ID
219
+ operator?: TAVFilterOperator, // 叶子节点:操作符
220
+ quantifier?: string, // 叶子节点:量词
221
+ value?: IAVCellValue, // 叶子节点:过滤值
222
+ relativeDate?: IAVRelativeDate, // 叶子节点:相对时间
223
+ relativeDate2?: IAVRelativeDate, // 叶子节点:第二个相对时间
224
+ combination?: "and" | "or", // 分组节点:子条件组合方式
225
+ filters?: IAVFilter[], // 分组节点:子节点(递归)
198
226
  }
199
227
 
200
228
  interface IAVRelativeDate {
@@ -360,12 +388,14 @@ interface IAVCellRollupValue {
360
388
 
361
389
  interface IAVCalc {
362
390
  operator?: string,
391
+ template?: string,
363
392
  result?: IAVCellValue
364
393
  }
365
394
 
366
395
  export interface IOperation {
367
396
  action: TOperation, // move, delete 不需要传 data
368
397
  id?: string,
398
+ context?: IObject, // focusId, message, ignoreProcess, setRange
369
399
  blockID?: string,
370
400
  isTwoWay?: boolean, // 是否双向关联
371
401
  backRelationKeyID?: string, // 双向关联的目标关联列 ID
@@ -379,14 +409,18 @@ export interface IOperation {
379
409
  retData?: any
380
410
  nextID?: string // insert 专享
381
411
  isDetached?: boolean // insertAttrViewBlock 专享
382
- ignoreFillFilter?: boolean // insertAttrViewBlock 专享
383
412
  srcIDs?: string[] // removeAttrViewBlock 专享
384
413
  srcs?: IOperationSrcs[] // insertAttrViewBlock 专享
414
+ ignoreDefaultFill?: boolean // insertAttrViewBlock 专享
415
+ viewID?: string // 多个属性视图操作使用,用于推送时不影响其他视图
385
416
  name?: string // addAttrViewCol 专享
386
417
  type?: TAVCol // addAttrViewCol 专享
387
418
  deckID?: string // add/removeFlashcards 专享
388
419
  blockIDs?: string[] // add/removeFlashcards 专享
389
420
  removeDest?: boolean // removeAttrViewCol 专享
421
+ layout?: string // addAttrViewView 专享
422
+ groupID?: string // insertAttrViewBlock, sortAttrViewRow 专享
423
+ targetGroupID?: string // sortAttrViewRow 专享
390
424
  }
391
425
 
392
426
  export interface IRefDefs {
@@ -407,11 +441,7 @@ export interface ISiyuan {
407
441
  storage?: {
408
442
  [key: string]: any
409
443
  },
410
- transactions?: {
411
- protyle: IProtyle,
412
- doOperations: IOperation[],
413
- undoOperations: IOperation[]
414
- }[]
444
+ closedTabs?: ILayoutJSON[]
415
445
  reqIds: {
416
446
  [key: string]: number
417
447
  },
@@ -421,6 +451,18 @@ export interface ISiyuan {
421
451
  emojis?: IEmoji[],
422
452
  backStack?: IBackStack[],
423
453
  mobile?: {
454
+ touchRange?: Range
455
+ size: {
456
+ isLandscape?: boolean,
457
+ landscape?: {
458
+ height1: number,
459
+ height2: number, // 键盘弹起时的高度
460
+ }, // 横屏
461
+ portrait?: {
462
+ height1: number,
463
+ height2: number,
464
+ }
465
+ }
424
466
  editor?: Protyle
425
467
  popEditor?: Protyle
426
468
  docks?: {
@@ -439,11 +481,31 @@ export interface ISiyuan {
439
481
  userHomeBImgURL: string
440
482
  userIntro: string
441
483
  userNickname: string
442
- userSiYuanOneTimePayStatus: number // 0 未付费;1 已付费
443
- userSiYuanProExpireTime: number // -1 终身会员;0 普通用户;> 0 过期时间
444
- userSiYuanSubscriptionPlan: number // 0 年付订阅/终生;1 教育优惠;2 订阅试用
445
- userSiYuanSubscriptionType: number // 0 年付;1 终生;2 月付
446
- userSiYuanSubscriptionStatus: number // -1:未订阅,0:订阅可用,1:订阅封禁,2:订阅过期
484
+ /**
485
+ * 功能特性付费状态
486
+ * 0 未付费,1 已付费
487
+ */
488
+ userSiYuanOneTimePayStatus: number
489
+ /**
490
+ * 会员过期时间
491
+ * -1 终身会员;0 未订阅或订阅已过期;>0 订阅到期时间(时间戳,毫秒)
492
+ */
493
+ userSiYuanProExpireTime: number
494
+ /**
495
+ * 订阅计划类型
496
+ * 0 年付订阅/终生;1 教育优惠;2 订阅试用
497
+ */
498
+ userSiYuanSubscriptionPlan: number
499
+ /**
500
+ * 订阅类型
501
+ * 0 年付;1 终生;2 月付
502
+ */
503
+ userSiYuanSubscriptionType: number
504
+ /**
505
+ * 订阅状态
506
+ * -1 未订阅,0 订阅可用,1 订阅封禁,2 订阅过期(包括付费订阅过期和试用订阅过期)
507
+ */
508
+ userSiYuanSubscriptionStatus: number
447
509
  userToken: string
448
510
  userTitles: {
449
511
  name: string,
@@ -452,7 +514,10 @@ export interface ISiyuan {
452
514
  }[]
453
515
  },
454
516
  dragElement?: HTMLElement,
517
+ dragTitle?: string,
455
518
  currentDragOverTabHeadersElement?: HTMLElement
519
+ touchDragActive?: boolean,
520
+ touchDragGhost?: HTMLElement | null,
456
521
  layout?: {
457
522
  layout?: Layout,
458
523
  centerLayout?: Layout,
@@ -505,24 +570,64 @@ export interface IMenu {
505
570
  index?: number
506
571
  element?: HTMLElement
507
572
  ignore?: boolean
508
- waring?: boolean
509
- }
510
-
511
- export interface IPosition {
512
- x: number,
513
- y: number,
514
- w?: number,
515
- h?: number,
516
- isLeft?: boolean
573
+ warning?: boolean
574
+ }
575
+
576
+ interface ILayoutJSON extends ILayoutOptions {
577
+ scrollAttr?: {
578
+ rootId: string,
579
+ startId?: string,
580
+ endId?: string
581
+ scrollTop?: number,
582
+ focusId?: string,
583
+ focusStart?: number
584
+ focusEnd?: number
585
+ zoomInId?: string
586
+ },
587
+ instance?: string,
588
+ width?: string,
589
+ height?: string,
590
+ title?: string,
591
+ lang?: string
592
+ docIcon?: string
593
+ page?: string
594
+ path?: string
595
+ blockId?: string
596
+ mode?: TEditorMode
597
+ action?: TProtyleAction
598
+ icon?: string
599
+ rootId?: string
600
+ active?: boolean
601
+ pin?: boolean
602
+ isPreview?: boolean
603
+ customModelData?: any
604
+ customModelType?: string
605
+ config?: Config.IUILayoutTabSearchConfig
606
+ children?: ILayoutJSON[] | ILayoutJSON
607
+ }
608
+
609
+ export interface IModels {
610
+ editor: Editor[],
611
+ graph: Model[],
612
+ outline: Model[],
613
+ backlink: Model[],
614
+ inbox: Inbox[],
615
+ files: Files[],
616
+ bookmark: Model[],
617
+ tag: Model[],
618
+ asset: Model[],
619
+ search: Model[],
620
+ custom: Custom[],
517
621
  }
518
622
 
519
623
  export interface IWebSocketData {
520
- cmd: string;
624
+ cmd?: string;
521
625
  callback?: string;
522
- data: any;
626
+ data?: any;
523
627
  msg: string;
524
628
  code: number;
525
- sid: string;
629
+ sid?: string;
630
+ context?: any;
526
631
  }
527
632
 
528
633
  export interface IObject {
@@ -587,7 +692,7 @@ export declare class Editor extends Model {
587
692
  blockId: string;
588
693
  rootId: string;
589
694
  mode?: TEditorMode;
590
- action?: string[];
695
+ action?: TProtyleAction[];
591
696
  });
592
697
 
593
698
  private initProtyle;
@@ -0,0 +1,120 @@
1
+ /**
2
+ * 内核插件状态
3
+ * - `-1`: inactive 内核插件未安装或不可用
4
+ * - `0`: ready 内核插件已安装但未启动
5
+ * - `1`: loading 内核插件正在启动
6
+ * - `2`: running 内核插件正在运行, 可正常使用
7
+ * - `3`: stopping 内核插件正在停止
8
+ * - `4`: stopped 内核插件已停止
9
+ * - `5`: error 内核插件出现不可恢复的错误
10
+ */
11
+ export type TKernelPluginState = -1 | 0 | 1 | 2 | 3 | 4 | 5
12
+
13
+ export type TJsonRpcId = string | number;
14
+ export type TJsonRpcMethod = string;
15
+ export type TJsonRpcPositionalParams = any[];
16
+ export type TJsonRpcNamedParams = Record<string, any>;
17
+ export type TJsonRpcParams = TJsonRpcPositionalParams | TJsonRpcNamedParams | undefined;
18
+ export type TJsonRpcMethodParams = TJsonRpcPositionalParams | [TJsonRpcNamedParams] | [];
19
+ export type TJsonRpcHandler<T = any> = (...args: TJsonRpcMethodParams) => Promise<T> | T;
20
+
21
+
22
+ export interface IKernelPlugin {
23
+ /**
24
+ * 内核插件的状态管理接口
25
+ */
26
+ state: IKernelPluginState;
27
+
28
+ /**
29
+ * 内核插件的 JSON-RPC 调用接口
30
+ */
31
+ rpc: IKernelPluginRpc;
32
+ }
33
+
34
+ export interface IKernelPluginState {
35
+ /**
36
+ * 内核插件的当前状态
37
+ */
38
+ code: TKernelPluginState;
39
+
40
+ /**
41
+ * 内核插件状态的描述信息
42
+ */
43
+ description: string;
44
+ }
45
+
46
+ export interface IKernelPluginRpcCall {
47
+ /**
48
+ * JSON-RPC 2.0 中 method 必须是 string,且插件开发者需要保证传入的方法名与内核插件绑定的方法名一致,否则可能会导致调用失败
49
+ */
50
+ method: TJsonRpcMethod;
51
+
52
+ /**
53
+ * JSON-RPC 2.0 中 id 可以是 string、number 或 null,但为了兼容性和实用性,插件系统中不允许使用 null 作为 id
54
+ *
55
+ * 不设置时且 notification 不为 true 时会自动生成一个唯一的 id,设置时必须保证 id 的唯一性,否则可能会导致响应错误或混乱
56
+ */
57
+ id?: TJsonRpcId;
58
+
59
+ /**
60
+ * JSON-RPC 2.0 中 params 可以是 array 或 object,插件开发者需要自行保证传入参数与内核插件绑定的方法参数一致
61
+ */
62
+ params?: any[] | Record<string, any>;
63
+
64
+ /**
65
+ * 是否为通知,通知不会有响应,且不应传入 id
66
+ * @defaultValue false
67
+ */
68
+ notification?: boolean;
69
+ }
70
+
71
+ export interface IKernelPluginRpcRequest extends IKernelPluginRpcCall {
72
+ jsonrpc: "2.0";
73
+ }
74
+
75
+ export interface IKernelPluginRpcBaseResponse {
76
+ jsonrpc: "2.0";
77
+ }
78
+
79
+ export interface IKernelPluginRpcResultResponse extends IKernelPluginRpcBaseResponse {
80
+ id: TJsonRpcId;
81
+ result?: any;
82
+ }
83
+
84
+ export interface IKernelPluginRpcErrorResponse extends IKernelPluginRpcBaseResponse {
85
+ id: TJsonRpcId | null;
86
+ error?: any;
87
+ }
88
+
89
+ export interface IKernelPluginRpcError {
90
+ code: number;
91
+ message: string;
92
+ data?: any;
93
+ }
94
+
95
+ export interface IKernelPluginRpc {
96
+ /**
97
+ * 通过 {@link Proxy} 实现的动态方法调用,插件开发者可以直接调用 `call.方法名(params)` 来调用内核插件暴露的方法,无需关心 JSON-RPC 的细节
98
+ */
99
+ call: Record<TJsonRpcMethod, (...args: TJsonRpcMethodParams) => Promise<any>>;
100
+
101
+ /**
102
+ * 通过 {@link Proxy} 实现的动态方法调用,插件开发者可以直接调用 `notify.方法名(...args)` 来发送通知给内核插件,无需关心 JSON-RPC 的细节
103
+ */
104
+ notify: Record<TJsonRpcMethod, (...args: TJsonRpcMethodParams) => void>;
105
+
106
+ /**
107
+ * 批量调用方法,接受一个方法调用数组,返回一个结果数组,结果数组中的每一项对应方法调用数组中非通知的每一项,包含成功的结果或错误信息
108
+ */
109
+ batch: (...calls: IKernelPluginRpcCall[]) => Promise<IKernelPluginRpcError | (IKernelPluginRpcResultResponse | IKernelPluginRpcErrorResponse)[]>;
110
+
111
+ /**
112
+ * 绑定内核插件调用时的事件处理函数,插件开发者可以通过 `bind("方法名", handler)` 来监听内核插件通过 JSON-RPC 推送到客户端插件的通知
113
+ */
114
+ bind: (method: TJsonRpcMethod, handler: TJsonRpcHandler<void>) => void;
115
+
116
+ /**
117
+ * 解绑事件处理函数,插件开发者可以通过 `unbind("方法名", handler)` 来停止监听内核插件通过 JSON-RPC 推送到客户端插件的通知
118
+ */
119
+ unbind: (method: TJsonRpcMethod, handler: TJsonRpcHandler<void>) => void;
120
+ }
@@ -1,6 +1,6 @@
1
1
  import {App, IWebSocketData, Tab} from "../../siyuan";
2
2
 
3
- type TWS = "main" | "filetree" | "protyle"
3
+ type TWS = "main" | "filetree" | "protyle" | "backlink" | "bookmark" | "graph" | "outline" | "tag" | "agentChat"
4
4
 
5
5
  export declare class Model {
6
6
  public ws: WebSocket;
@@ -10,6 +10,7 @@ interface IFile {
10
10
  bookmark: string;
11
11
  path: string;
12
12
  name: string;
13
+ titleEmpty?: boolean;
13
14
  hMtime: string;
14
15
  hCtime: string;
15
16
  hSize: string;
@@ -15,6 +15,8 @@ export declare const updateHotkeyTip: (hotkey: string) => string;
15
15
  export declare const getLocalStorage: (cb: () => void) => void;
16
16
  export declare const setStorageVal: (key: string, val: any, cb?: () => void) => void;
17
17
 
18
+ export declare const getStorageVal: (key: string) => any;
19
+
18
20
  /**
19
21
  * @param {string} [options.timeoutType="defalut"] 仅在 Windows 和 Linux 有效,"default" 表示使用默认的超时机制,"never" 表示通知将一直显示,直到用户手动关闭它。
20
22
  * @returns 通知 id
@@ -26,4 +28,5 @@ export declare const sendNotification: (options: {
26
28
  channel?: string,
27
29
  timeoutType?: "default" | "never"
28
30
  }) => Promise<number>;
31
+
29
32
  export declare const cancelNotification: (id: number) => void;
@@ -276,8 +276,13 @@ export class Protyle {
276
276
  */
277
277
  public turnIntoTransaction(nodeElement: Element, type: TTurnInto, subType?: number): void
278
278
 
279
+ /**
280
+ * @deprecated 将在 3.7.1 版本中移除。请改用 {@link updateTransactionElement}。
281
+ */
279
282
  public updateTransaction(id: string, newHTML: string, html: string): void
280
283
 
284
+ public updateTransactionElement(element: Element, oldHTML: string): void;
285
+
281
286
  public updateBatchTransaction(nodeElements: Element[], cb: (e: HTMLElement) => void): void
282
287
 
283
288
  public getRange(element: Element): Range
@@ -379,7 +384,7 @@ interface ILuteNode {
379
384
 
380
385
  type THintSource = "search" | "av" | "hint";
381
386
 
382
- type TTurnIntoOne = "BlocksMergeSuperBlock" | "Blocks2ULs" | "Blocks2OLs" | "Blocks2TLs" | "Blocks2Blockquote"
387
+ type TTurnIntoOne = "BlocksMergeSuperBlock" | "Blocks2ULs" | "Blocks2OLs" | "Blocks2TLs" | "Blocks2Blockquote" | "Blocks2Callout"
383
388
 
384
389
  type TTurnIntoOneSub = "row" | "col"
385
390
 
@@ -406,7 +411,8 @@ export type TProtyleAction = "cb-get-append" | // 向下滚动加载
406
411
  "cb-get-rootscroll" | // 如果为 rootID 就滚动到指定位置,必有 rootID
407
412
  "cb-get-html" | // 直接渲染,不需要再 /api/block/getDocInfo,否则搜索表格无法定位
408
413
  "cb-get-history" | // 历史渲染
409
- "cb-get-opennew" // 编辑器只读后新建文件需为临时解锁状态 & https://github.com/siyuan-note/siyuan/issues/12197
414
+ "cb-get-opennew" | // 编辑器只读后新建文件需为临时解锁状态 & https://github.com/siyuan-note/siyuan/issues/12197
415
+ "cb-get-av-no-create" // 属性视图不自动创建
410
416
 
411
417
  /** @link https://ld246.com/article/1588412297062 */
412
418
  interface ILuteRender {
@@ -592,6 +598,8 @@ export class Lute {
592
598
 
593
599
  public SetSuperBlock(enable: boolean): void;
594
600
 
601
+ public SetCallout(enable: boolean): void;
602
+
595
603
  public SetTag(enable: boolean): void;
596
604
 
597
605
  public SetInlineMath(enable: boolean): void;
@@ -638,6 +646,8 @@ export class Lute {
638
646
 
639
647
  public Md2BlockDOM(html: string): string;
640
648
 
649
+ public Md2BlockDOMWithAutoLink(html: string): string;
650
+
641
651
  public SetProtyleWYSIWYG(wysiwyg: boolean): void;
642
652
 
643
653
  public MarkdownStr(name: string, md: string): string;
@@ -653,6 +663,14 @@ export class Lute {
653
663
  public HTML2BlockDOM(html: string): string;
654
664
 
655
665
  public SetUnorderedListMarker(marker: string): void;
666
+
667
+ public SetDataTask(marker: boolean): void;
668
+
669
+ public SetExportNormalizeTaskListMarker(marker: boolean): void;
670
+
671
+ public SetArbitraryTaskListItemMarker(marker: boolean): void;
672
+
673
+ public SetEnsureListItemParagraph(enable: boolean): void;
656
674
  }
657
675
 
658
676
  declare const webkitAudioContext: {
@@ -711,9 +729,9 @@ interface IUpload {
711
729
 
712
730
  interface IScrollAttr {
713
731
  rootId: string,
714
- startId: string,
715
- endId: string
716
- scrollTop: number,
732
+ startId?: string,
733
+ endId?: string
734
+ scrollTop?: number,
717
735
  focusId?: string,
718
736
  focusStart?: number
719
737
  focusEnd?: number
@@ -872,12 +890,12 @@ export interface IProtyle {
872
890
  observerLoad?: ResizeObserver,
873
891
  observer?: ResizeObserver,
874
892
  app: App,
875
- transactionTime: number,
876
893
  id: string,
877
894
  query?: {
878
895
  key: string,
879
896
  method: number
880
897
  types: Config.IUILayoutTabSearchConfigTypes
898
+ subTypes: Config.IUILayoutTabSearchConfigSubTypes
881
899
  },
882
900
  block: {
883
901
  id?: string,
@@ -888,7 +906,7 @@ export interface IProtyle {
888
906
  showAll?: boolean
889
907
  mode?: number
890
908
  blockCount?: number
891
- action?: string[]
909
+ action?: TProtyleAction[]
892
910
  },
893
911
  disabled: boolean,
894
912
  selectElement?: HTMLElement,