siyuan 1.0.3 → 1.0.5

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
@@ -1,5 +1,432 @@
1
+ import {
2
+ Config, Dialog,
3
+ IProtyle,
4
+ Menu,
5
+ Plugin,
6
+ Protyle,
7
+ TDock,
8
+ TEditorMode,
9
+ TOperation,
10
+ TProtyleAction
11
+ } from "../siyuan";
12
+ import {Model} from "./layout/Model";
13
+ import {Wnd} from "./layout/Wnd";
14
+ import {Tab} from "./layout/Tab";
15
+ import {BlockPanel} from "./block/Panel";
16
+ import {Inbox} from "./layout/dock/Inbox";
17
+ import {MobileOutline} from "./mobile/dock/MobileOutline";
18
+ import {MobileFiles} from "./mobile/dock/MobileFiles";
19
+ import {MobileBookmarks} from "./mobile/dock/MobileBookmarks";
20
+ import {MobileTags} from "./mobile/dock/MobileTags";
21
+ import {MobileBacklinks} from "./mobile/dock/MobileBacklinks";
22
+
1
23
  export * from "./config";
2
24
  export * from "./events";
3
25
  export * from "./protyle";
4
26
  export * from "./response";
5
27
  export * from "./constants";
28
+ export * from "./layout/Wnd";
29
+ export * from "./layout/Tab";
30
+ export * from "./layout/Model";
31
+ export * from "./layout/dock/Files";
32
+ export * from "./layout/dock/Inbox";
33
+ export * from "./block/Panel";
34
+ export * from "./mobile/dock/MobileTags";
35
+ export * from "./mobile/dock/MobileOutline";
36
+ export * from "./mobile/dock/MobileBacklinks";
37
+ export * from "./mobile/dock/MobileBookmarks";
38
+ export * from "./mobile/dock/MobileFiles";
39
+ export * as platformUtils from "./protyle/util/compatibility";
40
+
41
+
42
+ type TDockPosition = "Left" | "Right" | "Bottom"
43
+
44
+ export type TAVCol =
45
+ "text"
46
+ | "date"
47
+ | "number"
48
+ | "relation"
49
+ | "rollup"
50
+ | "select"
51
+ | "block"
52
+ | "mSelect"
53
+ | "url"
54
+ | "email"
55
+ | "phone"
56
+ | "mAsset"
57
+ | "template"
58
+ | "created"
59
+ | "updated"
60
+ | "checkbox"
61
+ | "lineNumber"
62
+
63
+ interface ILayoutOptions {
64
+ direction?: Config.TUILayoutDirection
65
+ size?: string
66
+ resize?: Config.TUILayoutDirection
67
+ type?: Config.TUILayoutType
68
+ element?: HTMLElement
69
+ }
70
+
71
+ interface IOperationSrcs {
72
+ id: string,
73
+ content?: string,
74
+ isDetached: boolean
75
+ }
76
+
77
+ interface INotebook {
78
+ name: string
79
+ id: string
80
+ closed: boolean
81
+ icon: string
82
+ sort: number
83
+ dueFlashcardCount?: string;
84
+ newFlashcardCount?: string;
85
+ flashcardCount?: string;
86
+ sortMode: number
87
+ }
88
+
89
+ interface IEmojiItem {
90
+ unicode: string,
91
+ description: string,
92
+ description_zh_cn: string,
93
+ description_ja_jp: string,
94
+ keywords: string
95
+ }
96
+
97
+ interface IEmoji {
98
+ id: string,
99
+ title: string,
100
+ title_zh_cn: string,
101
+ title_ja_jp: string,
102
+ items: IEmojiItem[]
103
+ }
104
+
105
+ interface IBackStack {
106
+ id: string,
107
+ // 仅移动端
108
+ data?: {
109
+ startId: string,
110
+ endId: string
111
+ path: string
112
+ notebookId: string
113
+ },
114
+ scrollTop?: number,
115
+ callback?: TProtyleAction[],
116
+ position?: {
117
+ start: number,
118
+ end: number
119
+ }
120
+ // 仅桌面端
121
+ protyle?: IProtyle,
122
+ zoomId?: string
123
+ }
124
+
125
+ export interface IOperation {
126
+ action: TOperation, // move, delete 不需要传 data
127
+ id?: string,
128
+ blockID?: string,
129
+ isTwoWay?: boolean, // 是否双向关联
130
+ backRelationKeyID?: string, // 双向关联的目标关联列 ID
131
+ avID?: string, // av
132
+ format?: string // updateAttrViewColNumberFormat 专享
133
+ keyID?: string // updateAttrViewCell 专享
134
+ rowID?: string // updateAttrViewCell 专享
135
+ data?: any, // updateAttr 时为 { old: IObject, new: IObject }, updateAttrViewCell 时为 {TAVCol: {content: string}}
136
+ parentID?: string
137
+ previousID?: string
138
+ retData?: any
139
+ nextID?: string // insert 专享
140
+ isDetached?: boolean // insertAttrViewBlock 专享
141
+ ignoreFillFilter?: boolean // insertAttrViewBlock 专享
142
+ srcIDs?: string[] // removeAttrViewBlock 专享
143
+ srcs?: IOperationSrcs[] // insertAttrViewBlock 专享
144
+ name?: string // addAttrViewCol 专享
145
+ type?: TAVCol // addAttrViewCol 专享
146
+ deckID?: string // add/removeFlashcards 专享
147
+ blockIDs?: string[] // add/removeFlashcards 专享
148
+ removeDest?: boolean // removeAttrViewCol 专享
149
+ }
150
+
151
+ export interface IPosition {
152
+ x: number,
153
+ y: number,
154
+ w?: number,
155
+ h?: number,
156
+ isLeft?: boolean
157
+ }
158
+
159
+ export interface ISiyuan {
160
+ zIndex: number
161
+ storage?: {
162
+ [key: string]: any
163
+ },
164
+ transactions?: {
165
+ protyle: IProtyle,
166
+ doOperations: IOperation[],
167
+ undoOperations: IOperation[]
168
+ }[]
169
+ reqIds: {
170
+ [key: string]: number
171
+ },
172
+ editorIsFullscreen?: boolean,
173
+ hideBreadcrumb?: boolean,
174
+ notebooks?: INotebook[],
175
+ emojis?: IEmoji[],
176
+ backStack?: IBackStack[],
177
+ mobile?: {
178
+ editor?: Protyle
179
+ popEditor?: Protyle
180
+ docks?: {
181
+ outline: MobileOutline | null,
182
+ file: MobileFiles | null,
183
+ bookmark: MobileBookmarks | null,
184
+ tag: MobileTags | null,
185
+ backlink: MobileBacklinks | null,
186
+ inbox: Inbox | null,
187
+ } & { [key: string]: Model | boolean };
188
+ },
189
+ user?: {
190
+ userId: string
191
+ userName: string
192
+ userAvatarURL: string
193
+ userHomeBImgURL: string
194
+ userIntro: string
195
+ userNickname: string
196
+ userSiYuanOneTimePayStatus: number // 0 未付费;1 已付费
197
+ userSiYuanProExpireTime: number // -1 终身会员;0 普通用户;> 0 过期时间
198
+ userSiYuanSubscriptionPlan: number // 0 年付订阅/终生;1 教育优惠;2 订阅试用
199
+ userSiYuanSubscriptionType: number // 0 年付;1 终生;2 月付
200
+ userSiYuanSubscriptionStatus: number // -1:未订阅,0:订阅可用,1:订阅封禁,2:订阅过期
201
+ userToken: string
202
+ userTitles: {
203
+ name: string,
204
+ icon: string,
205
+ desc: string
206
+ }[]
207
+ },
208
+ dragElement?: HTMLElement,
209
+ layout?: {
210
+ layout?: Layout,
211
+ centerLayout?: Layout,
212
+ leftDock?: Dock,
213
+ rightDock?: Dock,
214
+ bottomDock?: Dock,
215
+ }
216
+ config?: Config.IConf;
217
+ ws: Model,
218
+ ctrlIsPressed?: boolean,
219
+ altIsPressed?: boolean,
220
+ shiftIsPressed?: boolean,
221
+ coordinates?: {
222
+ pageX: number,
223
+ pageY: number,
224
+ clientX: number,
225
+ clientY: number,
226
+ screenX: number,
227
+ screenY: number,
228
+ },
229
+ menus?: Menus
230
+ languages?: {
231
+ [key: string]: any;
232
+ }
233
+ bookmarkLabel?: string[]
234
+ blockPanels: BlockPanel[],
235
+ dialogs: Dialog[],
236
+ viewer?: Viewer
237
+ }
238
+
239
+ export interface IMenu {
240
+ checked?: boolean,
241
+ iconClass?: string,
242
+ label?: string,
243
+ click?: (element: HTMLElement, event: MouseEvent) => boolean | void | Promise<boolean | void>
244
+ type?: "separator" | "submenu" | "readonly" | "empty",
245
+ accelerator?: string,
246
+ action?: string,
247
+ id?: string,
248
+ submenu?: IMenu[]
249
+ disabled?: boolean
250
+ icon?: string
251
+ iconHTML?: string
252
+ current?: boolean
253
+ bind?: (element: HTMLElement) => void
254
+ index?: number
255
+ element?: HTMLElement
256
+ ignore?: boolean
257
+ waring?: boolean
258
+ }
259
+
260
+ export interface IPosition {
261
+ x: number,
262
+ y: number,
263
+ w?: number,
264
+ h?: number,
265
+ isLeft?: boolean
266
+ }
267
+
268
+ export interface IWebSocketData {
269
+ cmd: string;
270
+ callback?: string;
271
+ data: any;
272
+ msg: string;
273
+ code: number;
274
+ sid: string;
275
+ }
276
+
277
+ export interface IObject {
278
+ [key: string]: string;
279
+ }
280
+
281
+ declare class Viewer {
282
+ public destroyed: boolean;
283
+
284
+ constructor(element: Element, options: {
285
+ title: [number, (image: HTMLImageElement, imageData: IObject) => string],
286
+ button: boolean,
287
+ initialViewIndex?: number,
288
+ transition: boolean,
289
+ hidden: () => void,
290
+ toolbar: {
291
+ zoomIn: boolean,
292
+ zoomOut: boolean,
293
+ oneToOne: boolean,
294
+ reset: boolean,
295
+ prev: boolean,
296
+ play: boolean,
297
+ next: boolean,
298
+ rotateLeft: boolean,
299
+ rotateRight: boolean,
300
+ flipHorizontal: boolean,
301
+ flipVertical: boolean,
302
+ close: () => void
303
+ }
304
+ })
305
+
306
+ public destroy(): void
307
+
308
+ public show(): void
309
+ }
310
+
311
+ export declare class Layout {
312
+ element: HTMLElement;
313
+ children?: Array<Layout | Wnd>;
314
+ parent?: Layout;
315
+ direction: Config.TUILayoutDirection;
316
+ type?: Config.TUILayoutType;
317
+ id?: string;
318
+ resize?: Config.TUILayoutDirection;
319
+ size?: string;
320
+
321
+ constructor(options?: ILayoutOptions);
322
+
323
+ addLayout(child: Layout, id?: string): void;
324
+
325
+ addWnd(child: Wnd, id?: string): void;
326
+ }
327
+
328
+ export declare class Editor extends Model {
329
+ element: HTMLElement;
330
+ editor: Protyle;
331
+ headElement: HTMLElement;
332
+
333
+ constructor(options: {
334
+ app: App;
335
+ tab: Tab;
336
+ blockId: string;
337
+ rootId: string;
338
+ mode?: TEditorMode;
339
+ action?: string[];
340
+ });
341
+
342
+ private initProtyle;
343
+ }
344
+
345
+ export declare class Dock {
346
+ element: HTMLElement;
347
+ layout: Layout;
348
+ private position;
349
+ private app;
350
+ resizeElement: HTMLElement;
351
+ pin: boolean;
352
+ data: {
353
+ [key in TDock | string]: Model | boolean;
354
+ };
355
+ private hideResizeTimeout;
356
+
357
+ constructor(options: {
358
+ app: App;
359
+ data: {
360
+ pin: boolean;
361
+ data: Config.IUILayoutDockTab[][];
362
+ };
363
+ position: TDockPosition;
364
+ });
365
+
366
+ togglePin(): void;
367
+
368
+ resetDockPosition(show: boolean): void;
369
+
370
+ showDock(reset?: boolean): void;
371
+
372
+ hideDock(reset?: boolean): void;
373
+
374
+ toggleModel(type: string, show?: boolean, close?: boolean, hide?: boolean, isSaveLayout?: boolean): void;
375
+
376
+ add(index: number, sourceElement: Element, previousType?: string): void;
377
+
378
+ remove(key: string): void;
379
+
380
+ setSize(): void;
381
+
382
+ private getMaxSize;
383
+
384
+ genButton(data: Config.IUILayoutDockTab[], index: number, tabIndex?: number): void;
385
+ }
386
+
387
+ export declare class Custom extends Model {
388
+ element: Element;
389
+ tab: Tab;
390
+ data: any;
391
+ type: string;
392
+ init: (custom: Custom) => void;
393
+ destroy: () => void;
394
+ beforeDestroy: () => void;
395
+ resize: () => void;
396
+ update: () => void;
397
+ editors: Protyle[];
398
+
399
+ constructor(options: {
400
+ app: App;
401
+ type: string;
402
+ tab: Tab;
403
+ data: any;
404
+ destroy?: () => void;
405
+ beforeDestroy?: () => void;
406
+ resize?: () => void;
407
+ update?: () => void;
408
+ init: (custom: Custom) => void;
409
+ });
410
+ }
411
+
412
+ export declare class subMenu {
413
+ menus: IMenu[];
414
+
415
+ constructor();
416
+
417
+ addSeparator(index?: number): void;
418
+
419
+ addItem(menu: IMenu): void;
420
+ }
421
+
422
+ export declare class App {
423
+ plugins: Plugin[];
424
+ appId: string
425
+ }
426
+
427
+ export declare class Menus {
428
+ menu: Menu;
429
+ constructor(app: App);
430
+ private getDir;
431
+ private unselect;
432
+ }
@@ -0,0 +1,23 @@
1
+ import {App, IWebSocketData, Tab} from "../../siyuan";
2
+
3
+ type TWS = "main" | "filetree" | "protyle"
4
+
5
+ export declare class Model {
6
+ public ws: WebSocket;
7
+ public reqId: number;
8
+ public parent: Tab;
9
+ public app: App;
10
+
11
+ constructor(options: {
12
+ app: App,
13
+ id: string,
14
+ type?: TWS,
15
+ callback?: () => void,
16
+ msgCallback?: (data: IWebSocketData) => void
17
+ })
18
+
19
+ /**
20
+ * @param {boolean} [process=false]
21
+ */
22
+ public send(cmd: string, param: Record<string, unknown>, process: boolean): void;
23
+ }
@@ -0,0 +1,36 @@
1
+ import {Model} from "./Model";
2
+ import {Wnd} from "./Wnd";
3
+
4
+ interface ITab {
5
+ icon?: string
6
+ docIcon?: string
7
+ title?: string
8
+ panel?: string
9
+ callback?: (tab: Tab) => void
10
+ }
11
+
12
+ export declare class Tab {
13
+ parent: Wnd;
14
+ id: string;
15
+ headElement: HTMLElement;
16
+ panelElement: HTMLElement;
17
+ callback: (tab: Tab) => void;
18
+ model: Model;
19
+ title: string;
20
+ icon: string;
21
+ docIcon: string;
22
+
23
+ constructor(options: ITab);
24
+
25
+ updateTitle(title: string): void;
26
+
27
+ addModel(model: Model): void;
28
+
29
+ pin(): void;
30
+
31
+ setDocIcon(icon: string): void;
32
+
33
+ unpin(): void;
34
+
35
+ close(): void;
36
+ }
@@ -0,0 +1,34 @@
1
+ import {Config} from "../config";
2
+ import {App, Layout} from "../index";
3
+ import {Tab} from "./Tab";
4
+
5
+ export declare class Wnd {
6
+ private app;
7
+ id: string;
8
+ parent?: Layout;
9
+ element: HTMLElement;
10
+ headersElement: HTMLElement;
11
+ children: Tab[];
12
+ resize?: Config.TUILayoutDirection;
13
+
14
+ constructor(app: App, resize?: Config.TUILayoutDirection, parentType?: Config.TUILayoutType);
15
+
16
+ showHeading(): void;
17
+
18
+ switchTab(target: HTMLElement, pushBack?: boolean, update?: boolean, resize?: boolean, isSaveLayout?: boolean): void;
19
+
20
+ addTab(tab: Tab, keepCursor?: boolean, isSaveLayout?: boolean, activeTime?: string): void;
21
+
22
+ private renderTabList;
23
+ private removeOverCounter;
24
+ private destroyModel;
25
+ private removeTabAction;
26
+
27
+ removeTab(id: string, closeAll?: boolean, animate?: boolean, isSaveLayout?: boolean): void;
28
+
29
+ moveTab(tab: Tab, nextId?: string): void;
30
+
31
+ split(direction: Config.TUILayoutDirection): Wnd;
32
+
33
+ private remove;
34
+ }
@@ -0,0 +1,56 @@
1
+ import {App} from "../../../siyuan";
2
+ import {Tab} from "../Tab";
3
+ import {Model} from "../Model";
4
+
5
+ interface IFile {
6
+ icon: string;
7
+ name1: string;
8
+ alias: string;
9
+ memo: string;
10
+ bookmark: string;
11
+ path: string;
12
+ name: string;
13
+ hMtime: string;
14
+ hCtime: string;
15
+ hSize: string;
16
+ dueFlashcardCount?: string;
17
+ newFlashcardCount?: string;
18
+ flashcardCount?: string;
19
+ id: string;
20
+ count: number;
21
+ subFileCount: number;
22
+ }
23
+
24
+ export declare class Files extends Model {
25
+ element: HTMLElement;
26
+ parent: Tab;
27
+ private actionsElement;
28
+ closeElement: HTMLElement;
29
+ constructor(options: {
30
+ tab: Tab;
31
+ app: App;
32
+ });
33
+ private genNotebook;
34
+ init(init?: boolean): void;
35
+ private onRemove;
36
+ private onMount;
37
+ onRename(data: {
38
+ path: string;
39
+ title: string;
40
+ box: string;
41
+ }): void;
42
+ private onMove;
43
+ private onLsHTML;
44
+ private onLsSelect;
45
+ private setCurrent;
46
+ getLeaf(liElement: Element, notebookId: string): void;
47
+ selectItem(notebookId: string, filePath: string, data?: {
48
+ files: IFile[];
49
+ box: string;
50
+ path: string;
51
+ }, setStorage?: boolean): void;
52
+ private getOpenPaths;
53
+ private genDocAriaLabel;
54
+ private genFileHTML;
55
+ private initMoreMenu;
56
+ }
@@ -0,0 +1,18 @@
1
+ import { Tab } from "../Tab";
2
+ import { Model } from "../Model";
3
+ import { App } from "../../index";
4
+ export declare class Inbox extends Model {
5
+ private element;
6
+ private selectIds;
7
+ private currentPage;
8
+ private pageCount;
9
+ private data;
10
+ constructor(app: App, tab: Tab | Element);
11
+ private back;
12
+ private genDetail;
13
+ private genItemHTML;
14
+ private more;
15
+ private remove;
16
+ private move;
17
+ private update;
18
+ }
@@ -0,0 +1,10 @@
1
+ import { App } from "../../index";
2
+ export declare class MobileBacklinks {
3
+ element: HTMLElement;
4
+ private tree;
5
+ private notebookId;
6
+ private mTree;
7
+ beforeLen: number;
8
+ constructor(app: App);
9
+ update(): void;
10
+ }
@@ -0,0 +1,8 @@
1
+ import { App } from "../../index";
2
+ export declare class MobileBookmarks {
3
+ element: HTMLElement;
4
+ private tree;
5
+ private openNodes;
6
+ constructor(app: App);
7
+ update(): void;
8
+ }
@@ -0,0 +1,31 @@
1
+ import { Model } from "../../layout/Model";
2
+ import {App, IFile} from "../../index";
3
+ export declare class MobileFiles extends Model {
4
+ element: HTMLElement;
5
+ private actionsElement;
6
+ private closeElement;
7
+ constructor(app: App);
8
+ private genSort;
9
+ private genNotebook;
10
+ init(init?: boolean): void;
11
+ private onMove;
12
+ private onMkdir;
13
+ private onRemove;
14
+ onRename(data: {
15
+ path: string;
16
+ title: string;
17
+ box: string;
18
+ }): void;
19
+ private onMount;
20
+ private onLsHTML;
21
+ private onLsSelect;
22
+ private setCurrent;
23
+ getLeaf(liElement: Element, notebookId: string): void;
24
+ selectItem(notebookId: string, filePath: string, data?: {
25
+ files: IFile[];
26
+ box: string;
27
+ path: string;
28
+ }, setStorage?: boolean): void;
29
+ private getOpenPaths;
30
+ private genFileHTML;
31
+ }
@@ -0,0 +1,12 @@
1
+ import { App } from "../../index";
2
+ import { Model } from "../../layout/Model";
3
+ export declare class MobileOutline extends Model {
4
+ private tree;
5
+ private openNodes;
6
+ private element;
7
+ constructor(app: App);
8
+ update(): void;
9
+ private setCurrentByPreview;
10
+ private setCurrentById;
11
+ private setCurrent;
12
+ }
@@ -0,0 +1,8 @@
1
+ import { App } from "../../index";
2
+ export declare class MobileTags {
3
+ element: HTMLElement;
4
+ private tree;
5
+ private openNodes;
6
+ constructor(app: App);
7
+ update(): void;
8
+ }
@@ -0,0 +1,16 @@
1
+ export declare const openByMobile: (uri: string) => void;
2
+ export declare const readText: () => string | Promise<string>;
3
+ export declare const writeText: (text: string) => void;
4
+ export declare const copyPlainText: (text: string) => Promise<void>;
5
+ export declare const getEventName: () => "click" | "touchstart";
6
+ export declare const isOnlyMeta: (event: KeyboardEvent | MouseEvent) => boolean;
7
+ export declare const isNotCtrl: (event: KeyboardEvent | MouseEvent) => boolean;
8
+ export declare const isHuawei: () => boolean;
9
+ export declare const isIPhone: () => boolean;
10
+ export declare const isIPad: () => boolean;
11
+ export declare const isMac: () => boolean;
12
+ export declare const isInAndroid: () => boolean;
13
+ export declare const isInIOS: () => any;
14
+ export declare const updateHotkeyTip: (hotkey: string) => string;
15
+ export declare const getLocalStorage: (cb: () => void) => void;
16
+ export declare const setStorageVal: (key: string, val: any, cb?: () => void) => void;