siyuan 0.8.3 → 0.8.4
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 +7 -1
- package/package.json +12 -2
- package/siyuan.d.ts +121 -20
- package/types/events.d.ts +237 -0
- package/types/index.d.ts +2 -0
- package/types/protyle.d.ts +54 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
-
## 0.8.
|
|
3
|
+
## 0.8.5 2023-09
|
|
4
|
+
|
|
5
|
+
## 0.8.4 2023-09-19
|
|
6
|
+
|
|
7
|
+
* [Improve `Menu`](https://github.com/siyuan-note/petal/pull/16)
|
|
8
|
+
* [Add plugin function `transaction`](https://github.com/siyuan-note/siyuan/issues/9172)
|
|
9
|
+
* [Add `CustomEvent` type definition](https://github.com/siyuan-note/petal/pull/15)
|
|
4
10
|
|
|
5
11
|
## 0.8.3 2023-09-05
|
|
6
12
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "siyuan",
|
|
3
|
-
"contributors": [
|
|
3
|
+
"contributors": [
|
|
4
|
+
"zuoez02",
|
|
5
|
+
"Vanessa"
|
|
6
|
+
],
|
|
4
7
|
"types": "siyuan.d.ts",
|
|
5
|
-
"
|
|
8
|
+
"files": [
|
|
9
|
+
"types",
|
|
10
|
+
"CHANGELOG.md",
|
|
11
|
+
"package.json",
|
|
12
|
+
"README.md",
|
|
13
|
+
"siyuan.d.ts"
|
|
14
|
+
],
|
|
15
|
+
"version": "0.8.4",
|
|
6
16
|
"repository": "https://github.com/siyuan-note/petal"
|
|
7
17
|
}
|
package/siyuan.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
type
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import type * as types from "./types";
|
|
2
|
+
import {IProtyle} from "./types/protyle";
|
|
3
|
+
|
|
4
|
+
declare global {
|
|
5
|
+
interface Window extends Global {
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
type TEventBus = keyof IEventBusMap
|
|
10
10
|
|
|
11
11
|
type TCardType = "doc" | "notebook" | "all"
|
|
12
12
|
|
|
@@ -25,10 +25,76 @@ type TProtyleAction = "cb-get-append" | // 向下滚动加载
|
|
|
25
25
|
"cb-get-html" | // 直接渲染,不需要再 /api/block/getDocInfo,否则搜索表格无法定位
|
|
26
26
|
"cb-get-history" // 历史渲染
|
|
27
27
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
28
|
+
type TOperation =
|
|
29
|
+
"insert"
|
|
30
|
+
| "update"
|
|
31
|
+
| "delete"
|
|
32
|
+
| "move"
|
|
33
|
+
| "foldHeading"
|
|
34
|
+
| "unfoldHeading"
|
|
35
|
+
| "setAttrs"
|
|
36
|
+
| "updateAttrs"
|
|
37
|
+
| "append"
|
|
38
|
+
| "insertAttrViewBlock"
|
|
39
|
+
| "removeAttrViewBlock"
|
|
40
|
+
| "addAttrViewCol"
|
|
41
|
+
| "removeAttrViewCol"
|
|
42
|
+
| "addFlashcards"
|
|
43
|
+
| "removeFlashcards"
|
|
44
|
+
| "updateAttrViewCell"
|
|
45
|
+
| "updateAttrViewCol"
|
|
46
|
+
| "sortAttrViewRow"
|
|
47
|
+
| "sortAttrViewCol"
|
|
48
|
+
| "setAttrViewColHidden"
|
|
49
|
+
| "setAttrViewColWrap"
|
|
50
|
+
| "setAttrViewColWidth"
|
|
51
|
+
| "updateAttrViewColOptions"
|
|
52
|
+
| "removeAttrViewColOption"
|
|
53
|
+
| "updateAttrViewColOption"
|
|
54
|
+
| "setAttrViewName"
|
|
55
|
+
| "setAttrViewFilters"
|
|
56
|
+
| "setAttrViewSorts"
|
|
57
|
+
| "setAttrViewColCalc"
|
|
58
|
+
| "updateAttrViewColNumberFormat"
|
|
59
|
+
|
|
60
|
+
type TAVCol =
|
|
61
|
+
"text"
|
|
62
|
+
| "date"
|
|
63
|
+
| "number"
|
|
64
|
+
| "relation"
|
|
65
|
+
| "rollup"
|
|
66
|
+
| "select"
|
|
67
|
+
| "block"
|
|
68
|
+
| "mSelect"
|
|
69
|
+
| "url"
|
|
70
|
+
| "email"
|
|
71
|
+
| "phone"
|
|
72
|
+
|
|
73
|
+
interface Global {
|
|
74
|
+
Lute: Lute;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
interface IEventBusMap {
|
|
78
|
+
"click-blockicon": types.events.IClickBlockIconDetail;
|
|
79
|
+
"click-editorcontent": types.events.IClickEditorContentDetail;
|
|
80
|
+
"click-editortitleicon": types.events.IClickEditorTitleIconDetail;
|
|
81
|
+
"click-pdf": types.events.IClickPdfDetail;
|
|
82
|
+
"destroy-protyle": types.events.IDestroyProtyleDetail;
|
|
83
|
+
"input-search": types.events.IInputSearchDetail;
|
|
84
|
+
"loaded-protyle-dynamic": types.events.ILoadedProtyleDynamicDetail;
|
|
85
|
+
"loaded-protyle": types.events.ILoadedProtyleDetail;
|
|
86
|
+
"open-menu-av": any;
|
|
87
|
+
"open-menu-blockref": types.events.IOpenMenuBlockRefDetail;
|
|
88
|
+
"open-menu-breadcrumbmore": types.events.IOpenMenuBreadcrumbMoreDetail;
|
|
89
|
+
"open-menu-content": types.events.IOpenMenuContentDetail;
|
|
90
|
+
"open-menu-fileannotationref": types.events.IOpenMenuFileAnnotationRefDetail;
|
|
91
|
+
"open-menu-image": types.events.IOpenMenuImageDetail;
|
|
92
|
+
"open-menu-link": types.events.IOpenMenuLinkDetail;
|
|
93
|
+
"open-menu-tag": types.events.IOpenMenuTagDetail;
|
|
94
|
+
"open-noneditableblock": types.events.IOpenNonEditableBlockDetail;
|
|
95
|
+
"open-siyuan-url-block": types.events.IOpenSiyuanUrlBlockDetail;
|
|
96
|
+
"open-siyuan-url-plugin": types.events.IOpenSiyuanUrlPluginDetail;
|
|
97
|
+
"ws-main": types.events.IWebSocketMainDetail;
|
|
32
98
|
}
|
|
33
99
|
|
|
34
100
|
interface ITab {
|
|
@@ -208,6 +274,25 @@ interface IProtyleOption {
|
|
|
208
274
|
after?(protyle: Protyle): void;
|
|
209
275
|
}
|
|
210
276
|
|
|
277
|
+
interface IOperation {
|
|
278
|
+
action: TOperation, // move, delete 不需要传 data
|
|
279
|
+
id?: string,
|
|
280
|
+
avID?: string, // av
|
|
281
|
+
format?: string // updateAttrViewColNumberFormat 专享
|
|
282
|
+
keyID?: string // updateAttrViewCell 专享
|
|
283
|
+
rowID?: string // updateAttrViewCell 专享
|
|
284
|
+
data?: any, // updateAttr 时为 { old: IObject, new: IObject }, updateAttrViewCell 时为 {TAVCol: {content: string}}
|
|
285
|
+
parentID?: string
|
|
286
|
+
previousID?: string
|
|
287
|
+
retData?: any
|
|
288
|
+
nextID?: string // insert 专享
|
|
289
|
+
srcIDs?: string[] // insertAttrViewBlock 专享
|
|
290
|
+
name?: string // addAttrViewCol 专享
|
|
291
|
+
type?: TAVCol // addAttrViewCol 专享
|
|
292
|
+
deckID?: string // add/removeFlashcards 专享
|
|
293
|
+
blockIDs?: string[] // add/removeFlashcards 专享
|
|
294
|
+
}
|
|
295
|
+
|
|
211
296
|
export function fetchPost(url: string, data?: any, callback?: (response: IWebSocketData) => void, headers?: IObject): void;
|
|
212
297
|
|
|
213
298
|
export function fetchSyncPost(url: string, data?: any): Promise<IWebSocketData>;
|
|
@@ -394,6 +479,8 @@ export class Protyle {
|
|
|
394
479
|
* @param {boolean} [useProtyleRange=false]
|
|
395
480
|
*/
|
|
396
481
|
insert(html: string, isBlock?: boolean, useProtyleRange?: boolean): void
|
|
482
|
+
|
|
483
|
+
transaction(doOperations: IOperation[], undoOperations?: IOperation[]): void;
|
|
397
484
|
}
|
|
398
485
|
|
|
399
486
|
export class Setting {
|
|
@@ -415,13 +502,25 @@ export class Setting {
|
|
|
415
502
|
}
|
|
416
503
|
|
|
417
504
|
export class EventBus {
|
|
418
|
-
on
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
505
|
+
on<
|
|
506
|
+
K extends TEventBus,
|
|
507
|
+
D = IEventBusMap[K],
|
|
508
|
+
>(type: K, listener: (event: CustomEvent<D>) => any): void;
|
|
509
|
+
|
|
510
|
+
once<
|
|
511
|
+
K extends TEventBus,
|
|
512
|
+
D = IEventBusMap[K],
|
|
513
|
+
>(type: K, listener: (event: CustomEvent<D>) => any): void;
|
|
514
|
+
|
|
515
|
+
off<
|
|
516
|
+
K extends TEventBus,
|
|
517
|
+
D = IEventBusMap[K],
|
|
518
|
+
>(type: K, listener: (event: CustomEvent<D>) => any): void;
|
|
519
|
+
|
|
520
|
+
emit<
|
|
521
|
+
K extends TEventBus,
|
|
522
|
+
D = IEventBusMap[K],
|
|
523
|
+
>(type: K, detail?: D): boolean;
|
|
425
524
|
}
|
|
426
525
|
|
|
427
526
|
export class Dialog {
|
|
@@ -447,6 +546,8 @@ export class Dialog {
|
|
|
447
546
|
export class Menu {
|
|
448
547
|
constructor(id?: string, closeCallback?: () => void);
|
|
449
548
|
|
|
549
|
+
element: HTMLElement;
|
|
550
|
+
|
|
450
551
|
showSubMenu(subMenuElement: HTMLElement): void;
|
|
451
552
|
|
|
452
553
|
addItem(options: IMenuItemOption): HTMLElement;
|
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
import type { IProtyle } from "./protyle";
|
|
2
|
+
import {Menu} from "./../siyuan";
|
|
3
|
+
|
|
4
|
+
//#region click-block-icon
|
|
5
|
+
interface IBlockIconDetail {
|
|
6
|
+
menu: InstanceType<typeof Menu>;
|
|
7
|
+
protyle: IProtyle;
|
|
8
|
+
data?: IDocumentData;
|
|
9
|
+
blockElements?: HTMLElement[];
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
interface IDocumentData {
|
|
13
|
+
id: string;
|
|
14
|
+
ial: Record<string, string>;
|
|
15
|
+
icon: string;
|
|
16
|
+
name: string;
|
|
17
|
+
rootID: string;
|
|
18
|
+
refIDs: string[];
|
|
19
|
+
refCount: number;
|
|
20
|
+
subFileCount: number;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* `click-blockicon`
|
|
25
|
+
*/
|
|
26
|
+
export interface IClickBlockIconDetail extends IBlockIconDetail {
|
|
27
|
+
blockElements: HTMLElement[];
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* `click-editortitleicon`
|
|
32
|
+
*/
|
|
33
|
+
export interface IClickEditorTitleIconDetail extends IBlockIconDetail {
|
|
34
|
+
data: IDocumentData;
|
|
35
|
+
}
|
|
36
|
+
//#endregion click-block-icon
|
|
37
|
+
|
|
38
|
+
//#region click-editor-content
|
|
39
|
+
/**
|
|
40
|
+
* `click-editorcontent`
|
|
41
|
+
*/
|
|
42
|
+
export interface IClickEditorContentDetail {
|
|
43
|
+
event: PointerEvent;
|
|
44
|
+
protyle: IProtyle;
|
|
45
|
+
}
|
|
46
|
+
//#endregion click-editor-content
|
|
47
|
+
|
|
48
|
+
//#region click-pdf
|
|
49
|
+
/**
|
|
50
|
+
* `click-pdf`
|
|
51
|
+
*/
|
|
52
|
+
export interface IClickPdfDetail {
|
|
53
|
+
event: PointerEvent;
|
|
54
|
+
}
|
|
55
|
+
//#endregion click-pdf
|
|
56
|
+
|
|
57
|
+
//#region protyle
|
|
58
|
+
/**
|
|
59
|
+
* `loaded-protyle`
|
|
60
|
+
*/
|
|
61
|
+
export interface ILoadedProtyleDetail extends IProtyle {
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* `loaded-protyle-dynamic`
|
|
66
|
+
*/
|
|
67
|
+
export interface ILoadedProtyleDynamicDetail {
|
|
68
|
+
protyle: IProtyle;
|
|
69
|
+
positon: string;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* `destroy-protyle`
|
|
74
|
+
*/
|
|
75
|
+
export interface IDestroyProtyleDetail {
|
|
76
|
+
protyle: IProtyle;
|
|
77
|
+
}
|
|
78
|
+
//#endregion protyle
|
|
79
|
+
|
|
80
|
+
//#region input-search
|
|
81
|
+
interface IInputSearchConfig {
|
|
82
|
+
removed: boolean;
|
|
83
|
+
k: string;
|
|
84
|
+
r: string;
|
|
85
|
+
hasReplace: boolean;
|
|
86
|
+
method: number;
|
|
87
|
+
hPath: string;
|
|
88
|
+
idPath: string[];
|
|
89
|
+
group: number;
|
|
90
|
+
sort: number;
|
|
91
|
+
types: {
|
|
92
|
+
blockquote: boolean;
|
|
93
|
+
codeBlock: boolean;
|
|
94
|
+
document: boolean;
|
|
95
|
+
embedBlock: boolean;
|
|
96
|
+
heading: boolean;
|
|
97
|
+
htmlBlock: boolean;
|
|
98
|
+
list: boolean;
|
|
99
|
+
listItem: boolean;
|
|
100
|
+
mathBlock: boolean;
|
|
101
|
+
paragraph: boolean;
|
|
102
|
+
superBlock: boolean;
|
|
103
|
+
table: boolean;
|
|
104
|
+
};
|
|
105
|
+
page: number;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
interface IInputSearchProtyle {
|
|
109
|
+
protyle: IProtyle;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* `input-search`
|
|
114
|
+
*/
|
|
115
|
+
export interface IInputSearchDetail {
|
|
116
|
+
config: IInputSearchConfig;
|
|
117
|
+
protyle: IInputSearchProtyle;
|
|
118
|
+
searchElement: HTMLInputElement;
|
|
119
|
+
}
|
|
120
|
+
//#endregion input-search
|
|
121
|
+
|
|
122
|
+
//#region open-menu
|
|
123
|
+
interface IMenuBaseDetail {
|
|
124
|
+
menu: InstanceType<typeof Menu>;
|
|
125
|
+
protyle: IProtyle;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
interface IMenuInlineDetail extends IMenuBaseDetail {
|
|
129
|
+
element: HTMLSpanElement,
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
interface IBreadcrumbData {
|
|
133
|
+
imageCount: number;
|
|
134
|
+
linkCount: number;
|
|
135
|
+
refCount: number;
|
|
136
|
+
runeCount: number;
|
|
137
|
+
wordCount: number;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* `open-menu-breadcrumbmore`
|
|
142
|
+
*/
|
|
143
|
+
export interface IOpenMenuBreadcrumbMoreDetail extends IMenuBaseDetail {
|
|
144
|
+
data: IBreadcrumbData;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* `open-menu-content`
|
|
149
|
+
*/
|
|
150
|
+
export interface IOpenMenuContentDetail extends IMenuBaseDetail {
|
|
151
|
+
element: HTMLDivElement,
|
|
152
|
+
range: Range;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* `open-menu-blockref`
|
|
157
|
+
*/
|
|
158
|
+
export interface IOpenMenuBlockRefDetail extends IMenuInlineDetail {
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* `open-menu-fileannotationref`
|
|
163
|
+
*/
|
|
164
|
+
export interface IOpenMenuFileAnnotationRefDetail extends IMenuInlineDetail {
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* `open-menu-image`
|
|
169
|
+
*/
|
|
170
|
+
export interface IOpenMenuImageDetail extends IMenuInlineDetail {
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* `open-menu-link`
|
|
175
|
+
*/
|
|
176
|
+
export interface IOpenMenuLinkDetail extends IMenuInlineDetail {
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* `open-menu-tag`
|
|
181
|
+
*/
|
|
182
|
+
export interface IOpenMenuTagDetail extends IMenuInlineDetail {
|
|
183
|
+
}
|
|
184
|
+
//#endregion open-menu
|
|
185
|
+
|
|
186
|
+
//#region open-noneditableblock
|
|
187
|
+
interface INonEditableBlockToolbar {
|
|
188
|
+
element: HTMLDivElement;
|
|
189
|
+
range: Range;
|
|
190
|
+
subElement: HTMLDivElement;
|
|
191
|
+
subElementCloseCB: () => any;
|
|
192
|
+
toolbarHeight: number;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* `open-noneditableblock`
|
|
197
|
+
*/
|
|
198
|
+
export interface IOpenNonEditableBlockDetail {
|
|
199
|
+
protyle: IProtyle;
|
|
200
|
+
toolbar: INonEditableBlockToolbar;
|
|
201
|
+
}
|
|
202
|
+
//#endregion open-noneditableblock
|
|
203
|
+
|
|
204
|
+
//#region open-siyuan-url
|
|
205
|
+
interface IOpenSiyuanUrlDetail {
|
|
206
|
+
url: string;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* `open-siyuan-url-block`
|
|
211
|
+
*/
|
|
212
|
+
export interface IOpenSiyuanUrlBlockDetail extends IOpenSiyuanUrlDetail {
|
|
213
|
+
id: string;
|
|
214
|
+
focus: boolean;
|
|
215
|
+
exist: boolean;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
/**
|
|
219
|
+
* `open-siyuan-url-plugin`
|
|
220
|
+
*/
|
|
221
|
+
export interface IOpenSiyuanUrlPluginDetail extends IOpenSiyuanUrlDetail {
|
|
222
|
+
}
|
|
223
|
+
//#endregion open-siyuan-url
|
|
224
|
+
|
|
225
|
+
//#region ws-main
|
|
226
|
+
/**
|
|
227
|
+
* `ws-main`
|
|
228
|
+
*/
|
|
229
|
+
export interface IWebSocketMainDetail {
|
|
230
|
+
cmd?: string
|
|
231
|
+
callback?: string
|
|
232
|
+
data?: any
|
|
233
|
+
msg: string
|
|
234
|
+
code: number
|
|
235
|
+
sid?: string
|
|
236
|
+
}
|
|
237
|
+
//#endregion ws-main
|
package/types/index.d.ts
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import {App, Lute} from "./../siyuan";
|
|
2
|
+
|
|
3
|
+
// REF: https://github.com/siyuan-note/siyuan/blob/dev/app/src/types/protyle.d.ts
|
|
4
|
+
export interface IProtyle {
|
|
5
|
+
app: App;
|
|
6
|
+
transactionTime: number;
|
|
7
|
+
id: string;
|
|
8
|
+
block: {
|
|
9
|
+
id?: string;
|
|
10
|
+
scroll?: boolean;
|
|
11
|
+
parentID?: string;
|
|
12
|
+
parent2ID?: string;
|
|
13
|
+
rootID?: string;
|
|
14
|
+
showAll?: boolean;
|
|
15
|
+
mode?: number;
|
|
16
|
+
blockCount?: number;
|
|
17
|
+
action?: string[];
|
|
18
|
+
};
|
|
19
|
+
disabled: boolean;
|
|
20
|
+
selectElement?: HTMLElement;
|
|
21
|
+
ws?: any;
|
|
22
|
+
notebookId?: string;
|
|
23
|
+
path?: string;
|
|
24
|
+
model?: any;
|
|
25
|
+
updated: boolean;
|
|
26
|
+
element: HTMLElement;
|
|
27
|
+
scroll?: any;
|
|
28
|
+
gutter?: any;
|
|
29
|
+
breadcrumb?: {
|
|
30
|
+
id: string;
|
|
31
|
+
element: HTMLElement;
|
|
32
|
+
};
|
|
33
|
+
title?: {
|
|
34
|
+
editElement: HTMLElement;
|
|
35
|
+
element: HTMLElement;
|
|
36
|
+
};
|
|
37
|
+
background?: {
|
|
38
|
+
element: HTMLElement;
|
|
39
|
+
ial: Record<string, string>;
|
|
40
|
+
iconElement: HTMLElement;
|
|
41
|
+
imgElement: HTMLElement;
|
|
42
|
+
tagsElement: HTMLElement;
|
|
43
|
+
transparentData: string;
|
|
44
|
+
};
|
|
45
|
+
contentElement?: HTMLElement;
|
|
46
|
+
options: any;
|
|
47
|
+
lute?: Lute;
|
|
48
|
+
toolbar?: any;
|
|
49
|
+
preview?: any;
|
|
50
|
+
hint?: any;
|
|
51
|
+
upload?: any;
|
|
52
|
+
undo?: any;
|
|
53
|
+
wysiwyg?: any;
|
|
54
|
+
}
|