siyuan 1.1.6 → 1.1.7

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,11 @@
1
1
  # Changelog
2
2
 
3
+ ## v1.1.8 2026
4
+
5
+ ## v1.1.7 2025-12-23
6
+
7
+ * [Provide plugins rendering interfaces for code blocks, formula blocks, etc](https://github.com/siyuan-note/siyuan/issues/16586)
8
+
3
9
  ## v1.1.6 2025-12-02
4
10
 
5
11
  * [Synchronize config, constants, and protyle](https://github.com/siyuan-note/petal/issues/42)
package/package.json CHANGED
@@ -12,7 +12,7 @@
12
12
  "README.md",
13
13
  "siyuan.d.ts"
14
14
  ],
15
- "version": "1.1.6",
15
+ "version": "1.1.7",
16
16
  "repository": {
17
17
  "type": "git",
18
18
  "url": "git+https://github.com/siyuan-note/petal.git"
package/types/index.d.ts CHANGED
@@ -40,7 +40,24 @@ export * as platformUtils from "./protyle/util/compatibility";
40
40
 
41
41
 
42
42
  type TDockPosition = "Left" | "Right" | "Bottom"
43
-
43
+ type TAVView = "table" | "gallery" | "kanban"
44
+ type TAVFilterOperator =
45
+ "="
46
+ | "!="
47
+ | ">"
48
+ | ">="
49
+ | "<"
50
+ | "<="
51
+ | "Contains"
52
+ | "Does not contains"
53
+ | "Is empty"
54
+ | "Is not empty"
55
+ | "Starts with"
56
+ | "Ends with"
57
+ | "Is between"
58
+ | "Is relative to today"
59
+ | "Is true"
60
+ | "Is false"
44
61
  export type TAVCol =
45
62
  "text"
46
63
  | "date"
@@ -61,11 +78,11 @@ export type TAVCol =
61
78
  | "lineNumber"
62
79
 
63
80
  interface ILayoutOptions {
64
- direction?: Config.TUILayoutDirection
65
- size?: string
66
- resize?: Config.TUILayoutDirection
67
- type?: Config.TUILayoutType
68
- element?: HTMLElement
81
+ direction?: Config.TUILayoutDirection;
82
+ size?: string;
83
+ resize?: Config.TUILayoutDirection;
84
+ type?: Config.TUILayoutType;
85
+ element?: HTMLElement;
69
86
  }
70
87
 
71
88
  interface IOperationSrcs {
@@ -75,15 +92,15 @@ interface IOperationSrcs {
75
92
  }
76
93
 
77
94
  interface INotebook {
78
- name: string
79
- id: string
80
- closed: boolean
81
- icon: string
82
- sort: number
95
+ name: string;
96
+ id: string;
97
+ closed: boolean;
98
+ icon: string;
99
+ sort: number;
83
100
  dueFlashcardCount?: string;
84
101
  newFlashcardCount?: string;
85
102
  flashcardCount?: string;
86
- sortMode: number
103
+ sortMode: number;
87
104
  }
88
105
 
89
106
  interface IEmojiItem {
@@ -122,6 +139,230 @@ interface IBackStack {
122
139
  zoomId?: string
123
140
  }
124
141
 
142
+ export interface IAV {
143
+ id: string;
144
+ name: string;
145
+ view: IAVTable | IAVGallery;
146
+ viewID: string;
147
+ viewType: TAVView;
148
+ views: IAVView[];
149
+ isMirror?: boolean;
150
+ }
151
+
152
+ interface IAVView {
153
+ name: string;
154
+ desc: string;
155
+ id: string;
156
+ type: TAVView;
157
+ icon: string;
158
+ hideAttrViewName: boolean;
159
+ pageSize: number;
160
+ showIcon: boolean;
161
+ wrapField: boolean;
162
+ groupHidden?: number, // 0:显示,1:空白隐藏,2:手动隐藏
163
+ groupFolded?: boolean,
164
+ filters: IAVFilter[],
165
+ sorts: IAVSort[],
166
+ groups: IAVView[]
167
+ group: IAVGroup
168
+ groupKey: IAVColumn
169
+ groupValue: IAVCellValue
170
+ }
171
+
172
+ interface IAVTable extends IAVView {
173
+ columns: IAVColumn[],
174
+ rows: IAVRow[],
175
+ rowCount: number,
176
+ }
177
+
178
+ interface IAVGallery extends IAVView {
179
+ coverFrom: number; // 0:无,1:内容图,2:资源字段,3:内容块
180
+ coverFromAssetKeyID?: string;
181
+ cardSize: number; // 0:小卡片,1:中卡片,2:大卡片
182
+ cardAspectRatio: number;
183
+ displayFieldName: boolean;
184
+ fitImage: boolean;
185
+ cards: IAVGalleryItem[],
186
+ desc: string
187
+ fields: IAVColumn[]
188
+ cardCount: number,
189
+ }
190
+
191
+ interface IAVFilter {
192
+ column: string,
193
+ operator: TAVFilterOperator,
194
+ quantifier?: string,
195
+ value: IAVCellValue,
196
+ relativeDate?: IAVRelativeDate
197
+ relativeDate2?: IAVRelativeDate
198
+ }
199
+
200
+ interface IAVRelativeDate {
201
+ count: number; // 数量
202
+ unit: number; // 单位:0: 天、1: 周、2: 月、3: 年
203
+ direction: number; // 方向:-1: 前、0: 现在、1: 后
204
+ }
205
+
206
+ interface IAVGroup {
207
+ field: string,
208
+ method?: number // 0: 按值分组、1: 按数字范围分组、2: 按相对日期分组、3: 按天日期分组、4: 按周日期分组、5: 按月日期分组、6: 按年日期分组
209
+ range?: {
210
+ numStart: number // 数字范围起始值 0
211
+ numEnd: number // 数字范围结束值 1000
212
+ numStep: number // 数字范围步长 100
213
+ }
214
+ hideEmpty?: boolean
215
+ order?: number // 升序: 0(默认), 降序: 1, 手动排序: 2, 按选项排序: 3
216
+ }
217
+
218
+ interface IAVSort {
219
+ column: string,
220
+ order: "ASC" | "DESC"
221
+ }
222
+
223
+ interface IAVColumn {
224
+ width: string,
225
+ icon: string,
226
+ id: string,
227
+ name: string,
228
+ desc: string,
229
+ wrap: boolean,
230
+ pin: boolean,
231
+ hidden: boolean,
232
+ type: TAVCol,
233
+ numberFormat: string,
234
+ template: string,
235
+ calc: IAVCalc,
236
+ updated?: {
237
+ includeTime: boolean
238
+ }
239
+ created?: {
240
+ includeTime: boolean
241
+ }
242
+ date?: {
243
+ autoFillNow: boolean,
244
+ fillSpecificTime: boolean,
245
+ }
246
+ // 选项列表
247
+ options?: {
248
+ name: string,
249
+ color: string,
250
+ desc?: string,
251
+ }[],
252
+ relation?: IAVColumnRelation,
253
+ rollup?: IAVCellRollupValue
254
+ }
255
+
256
+ interface IAVRow {
257
+ id: string,
258
+ cells: IAVCell[]
259
+ }
260
+
261
+ interface IAVGalleryItem {
262
+ coverURL?: string;
263
+ coverContent?: string;
264
+ id: string;
265
+ values: IAVCell[];
266
+ }
267
+
268
+ interface IAVCell {
269
+ id: string,
270
+ color: string,
271
+ bgColor: string,
272
+ value: IAVCellValue,
273
+ valueType: TAVCol,
274
+ }
275
+
276
+ interface IAVCellValue {
277
+ keyID?: string,
278
+ id?: string,
279
+ blockID?: string // 为 row id
280
+ type: TAVCol,
281
+ isDetached?: boolean,
282
+ text?: {
283
+ content: string
284
+ },
285
+ number?: {
286
+ content?: number,
287
+ isNotEmpty: boolean,
288
+ format?: string,
289
+ formattedContent?: string
290
+ },
291
+ mSelect?: IAVCellSelectValue[]
292
+ mAsset?: IAVCellAssetValue[]
293
+ block?: {
294
+ content: string,
295
+ id?: string,
296
+ icon?: string
297
+ }
298
+ url?: {
299
+ content: string
300
+ }
301
+ phone?: {
302
+ content: string
303
+ }
304
+ email?: {
305
+ content: string
306
+ }
307
+ template?: {
308
+ content: string
309
+ },
310
+ checkbox?: {
311
+ checked: boolean,
312
+ content?: string, // gallery 中显示 https://github.com/siyuan-note/siyuan/issues/15389
313
+ }
314
+ relation?: IAVCellRelationValue
315
+ rollup?: {
316
+ contents?: IAVCellValue[]
317
+ }
318
+ date?: IAVCellDateValue
319
+ created?: IAVCellDateValue
320
+ updated?: IAVCellDateValue
321
+ }
322
+
323
+ interface IAVCellRelationValue {
324
+ blockIDs: string[];
325
+ contents?: IAVCellValue[];
326
+ }
327
+
328
+ interface IAVCellDateValue {
329
+ content?: number,
330
+ isNotEmpty?: boolean
331
+ content2?: number,
332
+ isNotEmpty2?: boolean
333
+ hasEndDate?: boolean
334
+ formattedContent?: string,
335
+ isNotTime?: boolean // 默认 true
336
+ }
337
+
338
+ interface IAVCellSelectValue {
339
+ content: string,
340
+ color: string
341
+ }
342
+
343
+ interface IAVCellAssetValue {
344
+ content: string,
345
+ name: string,
346
+ type: "file" | "image"
347
+ }
348
+
349
+ interface IAVColumnRelation {
350
+ avID?: string;
351
+ backKeyID?: string;
352
+ isTwoWay?: boolean;
353
+ }
354
+
355
+ interface IAVCellRollupValue {
356
+ relationKeyID?: string; // 关联列 ID
357
+ keyID?: string;
358
+ calc?: IAVCalc;
359
+ }
360
+
361
+ interface IAVCalc {
362
+ operator?: string,
363
+ result?: IAVCellValue
364
+ }
365
+
125
366
  export interface IOperation {
126
367
  action: TOperation, // move, delete 不需要传 data
127
368
  id?: string,
@@ -450,7 +691,7 @@ export declare class subMenu {
450
691
 
451
692
  export declare class App {
452
693
  plugins: Plugin[];
453
- appId: string
694
+ appId: string;
454
695
  }
455
696
 
456
697
  export declare class Menus {
@@ -1,7 +1,13 @@
1
1
  import {
2
- App, Config, Editor,
2
+ App,
3
+ Config,
4
+ Editor,
5
+ IAV,
3
6
  IObject,
4
- IOperation, IPosition, IWebSocketData, Menu,
7
+ IOperation,
8
+ IPosition,
9
+ IWebSocketData,
10
+ Menu,
5
11
  } from "./../siyuan";
6
12
  import {Model} from "./layout/Model";
7
13
 
@@ -290,6 +296,75 @@ export class Protyle {
290
296
  public renderAVAttribute(element: HTMLElement, id: string, cb?: (element: HTMLElement) => void): void
291
297
  }
292
298
 
299
+ export class ProtyleMethod {
300
+ /**
301
+ * @description 使用 graphviz 进行渲染
302
+ * @param {string} [cdn=Constants.PROTYLE_CDN]
303
+ */
304
+ public static graphvizRender(element: Element, cdn?: string): void
305
+
306
+ /**
307
+ * @description 为 element 中的代码块进行高亮渲染
308
+ * @param {string} [cdn=Constants.PROTYLE_CDN]
309
+ * @param {number} [zoom=1]
310
+ */
311
+ public static highlightRender(element: Element, cdn?: string, zoom?: number): void
312
+
313
+ /**
314
+ * @description 对数学公式进行渲染
315
+ * @param {string} [cdn=Constants.PROTYLE_CDN]
316
+ * @param {boolean} [maxWidth=false]
317
+ */
318
+ public static mathRender(element: Element, cdn?: string, maxWidth?: boolean): void;
319
+
320
+ /**
321
+ * @description mermaid.js 渲染,支持流程图/时序图/甘特图渲染等
322
+ * @param {string} [cdn=Constants.PROTYLE_CDN]
323
+ */
324
+ public static mermaidRender(element: Element, cdn?: string): void;
325
+
326
+ /**
327
+ * @description flowchart.js 渲染
328
+ * @param {string} [cdn=Constants.PROTYLE_CDN]
329
+ */
330
+ public static flowchartRender(element: Element, cdn?: string): void;
331
+
332
+ /**
333
+ * @description 图表渲染
334
+ * @param {string} [cdn=Constants.PROTYLE_CDN]
335
+ */
336
+ public static chartRender(element: Element, cdn?: string): void;
337
+
338
+ /**
339
+ * @description 五线谱渲染
340
+ * @param {string} [cdn=Constants.PROTYLE_CDN]
341
+ */
342
+ public static abcRender(element: Element, cdn?: string): void;
343
+
344
+ /**
345
+ * @description 脑图渲染
346
+ * @param {string} [cdn=Constants.PROTYLE_CDN]
347
+ */
348
+ public static mindmapRender(element: Element, cdn?: string): void;
349
+
350
+ /**
351
+ * @description UML 渲染
352
+ * @param {string} [cdn=Constants.PROTYLE_CDN]
353
+ */
354
+ public static plantumlRender(element: Element, cdn?: string): void;
355
+
356
+ /**
357
+ * @description 数据库渲染
358
+ * @param {boolean} [renderAll=true]
359
+ */
360
+ public static avRender(element: Element, protyle: IProtyle, cb?: (data: IAV) => void, renderAll?: boolean, avData?: IAV): Promise<void>;
361
+
362
+ /**
363
+ * @description html 渲染
364
+ */
365
+ public static htmlRender(element: Element): void;
366
+ }
367
+
293
368
  interface ILuteNode {
294
369
  TokensStr: () => string;
295
370
  __internal_object__: {