@difizen/libro-core 0.0.2-alpha.0
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/LICENSE +21 -0
- package/README.md +3 -0
- package/es/add-cell/index.d.ts +4 -0
- package/es/add-cell/index.d.ts.map +1 -0
- package/es/add-cell/index.js +3 -0
- package/es/add-cell/index.less +38 -0
- package/es/add-cell/libro-add-cell-module.d.ts +3 -0
- package/es/add-cell/libro-add-cell-module.d.ts.map +1 -0
- package/es/add-cell/libro-add-cell-module.js +4 -0
- package/es/add-cell/libro-add-cell-slot-contribution.d.ts +12 -0
- package/es/add-cell/libro-add-cell-slot-contribution.d.ts.map +1 -0
- package/es/add-cell/libro-add-cell-slot-contribution.js +53 -0
- package/es/add-cell/libro-add-cell-view.d.ts +21 -0
- package/es/add-cell/libro-add-cell-view.d.ts.map +1 -0
- package/es/add-cell/libro-add-cell-view.js +129 -0
- package/es/cell/index.d.ts +10 -0
- package/es/cell/index.d.ts.map +1 -0
- package/es/cell/index.js +9 -0
- package/es/cell/libro-cell-contribution.d.ts +13 -0
- package/es/cell/libro-cell-contribution.d.ts.map +1 -0
- package/es/cell/libro-cell-contribution.js +41 -0
- package/es/cell/libro-cell-model.d.ts +19 -0
- package/es/cell/libro-cell-model.d.ts.map +1 -0
- package/es/cell/libro-cell-model.js +103 -0
- package/es/cell/libro-cell-module.d.ts +10 -0
- package/es/cell/libro-cell-module.d.ts.map +1 -0
- package/es/cell/libro-cell-module.js +30 -0
- package/es/cell/libro-cell-protocol.d.ts +42 -0
- package/es/cell/libro-cell-protocol.d.ts.map +1 -0
- package/es/cell/libro-cell-protocol.js +11 -0
- package/es/cell/libro-cell-service.d.ts +28 -0
- package/es/cell/libro-cell-service.d.ts.map +1 -0
- package/es/cell/libro-cell-service.js +242 -0
- package/es/cell/libro-cell-view.d.ts +65 -0
- package/es/cell/libro-cell-view.d.ts.map +1 -0
- package/es/cell/libro-cell-view.js +191 -0
- package/es/cell/libro-edit-cell-view.d.ts +32 -0
- package/es/cell/libro-edit-cell-view.d.ts.map +1 -0
- package/es/cell/libro-edit-cell-view.js +72 -0
- package/es/cell/libro-executable-cell-model.d.ts +14 -0
- package/es/cell/libro-executable-cell-model.d.ts.map +1 -0
- package/es/cell/libro-executable-cell-model.js +7 -0
- package/es/cell/libro-executable-cell-view.d.ts +27 -0
- package/es/cell/libro-executable-cell-view.d.ts.map +1 -0
- package/es/cell/libro-executable-cell-view.js +66 -0
- package/es/cell/libro-markdown-cell-model.d.ts +9 -0
- package/es/cell/libro-markdown-cell-model.d.ts.map +1 -0
- package/es/cell/libro-markdown-cell-model.js +7 -0
- package/es/collapse-service.d.ts +36 -0
- package/es/collapse-service.d.ts.map +1 -0
- package/es/collapse-service.js +55 -0
- package/es/command/document-commands.d.ts +6 -0
- package/es/command/document-commands.d.ts.map +1 -0
- package/es/command/document-commands.js +13 -0
- package/es/command/index.d.ts +7 -0
- package/es/command/index.d.ts.map +1 -0
- package/es/command/index.js +6 -0
- package/es/command/kernel-command.d.ts +5 -0
- package/es/command/kernel-command.d.ts.map +1 -0
- package/es/command/kernel-command.js +39 -0
- package/es/command/libro-command-contribution.d.ts +14 -0
- package/es/command/libro-command-contribution.d.ts.map +1 -0
- package/es/command/libro-command-contribution.js +1751 -0
- package/es/command/libro-command-register.d.ts +22 -0
- package/es/command/libro-command-register.d.ts.map +1 -0
- package/es/command/libro-command-register.js +105 -0
- package/es/command/module.d.ts +3 -0
- package/es/command/module.d.ts.map +1 -0
- package/es/command/module.js +4 -0
- package/es/command/notebook-commands.d.ts +6 -0
- package/es/command/notebook-commands.d.ts.map +1 -0
- package/es/command/notebook-commands.js +468 -0
- package/es/components/cell-protocol.d.ts +20 -0
- package/es/components/cell-protocol.d.ts.map +1 -0
- package/es/components/cell-protocol.js +4 -0
- package/es/components/dnd-cell-item-render.d.ts +12 -0
- package/es/components/dnd-cell-item-render.d.ts.map +1 -0
- package/es/components/dnd-cell-item-render.js +253 -0
- package/es/components/dnd-component/custom-drag-layer.d.ts +9 -0
- package/es/components/dnd-component/custom-drag-layer.d.ts.map +1 -0
- package/es/components/dnd-component/custom-drag-layer.js +141 -0
- package/es/components/dnd-component/default-dnd-content.d.ts +10 -0
- package/es/components/dnd-component/default-dnd-content.d.ts.map +1 -0
- package/es/components/dnd-component/default-dnd-content.js +257 -0
- package/es/components/dnd-component/dnd-context.d.ts +3 -0
- package/es/components/dnd-component/dnd-context.d.ts.map +1 -0
- package/es/components/dnd-component/dnd-context.js +20 -0
- package/es/components/dnd-component/dnd-list.d.ts +10 -0
- package/es/components/dnd-component/dnd-list.d.ts.map +1 -0
- package/es/components/dnd-component/dnd-list.js +115 -0
- package/es/components/dnd-component/index.d.ts +5 -0
- package/es/components/dnd-component/index.d.ts.map +1 -0
- package/es/components/dnd-component/index.js +4 -0
- package/es/components/index.d.ts +6 -0
- package/es/components/index.d.ts.map +1 -0
- package/es/components/index.js +5 -0
- package/es/components/libro-component.d.ts +5 -0
- package/es/components/libro-component.d.ts.map +1 -0
- package/es/components/libro-component.js +35 -0
- package/es/components/libro-side-toolbar-menu.d.ts +21 -0
- package/es/components/libro-side-toolbar-menu.d.ts.map +1 -0
- package/es/components/libro-side-toolbar-menu.js +58 -0
- package/es/components/libro-view-header.d.ts +3 -0
- package/es/components/libro-view-header.d.ts.map +1 -0
- package/es/components/libro-view-header.js +37 -0
- package/es/configuration/libro-configuration-contribution.d.ts +5 -0
- package/es/configuration/libro-configuration-contribution.d.ts.map +1 -0
- package/es/configuration/libro-configuration-contribution.js +24 -0
- package/es/configuration/libro-configuration.d.ts +10 -0
- package/es/configuration/libro-configuration.d.ts.map +1 -0
- package/es/configuration/libro-configuration.js +81 -0
- package/es/content/index.d.ts +5 -0
- package/es/content/index.d.ts.map +1 -0
- package/es/content/index.js +4 -0
- package/es/content/libro-content-contribution.d.ts +11 -0
- package/es/content/libro-content-contribution.d.ts.map +1 -0
- package/es/content/libro-content-contribution.js +32 -0
- package/es/content/libro-content-module.d.ts +3 -0
- package/es/content/libro-content-module.d.ts.map +1 -0
- package/es/content/libro-content-module.js +5 -0
- package/es/content/libro-content-protocol.d.ts +8 -0
- package/es/content/libro-content-protocol.d.ts.map +1 -0
- package/es/content/libro-content-protocol.js +2 -0
- package/es/content/libro-content-service.d.ts +9 -0
- package/es/content/libro-content-service.d.ts.map +1 -0
- package/es/content/libro-content-service.js +35 -0
- package/es/index.d.ts +20 -0
- package/es/index.d.ts.map +1 -0
- package/es/index.js +19 -0
- package/es/index.less +682 -0
- package/es/libro-context-key.d.ts +22 -0
- package/es/libro-context-key.d.ts.map +1 -0
- package/es/libro-context-key.js +80 -0
- package/es/libro-keybind-registry.d.ts +5 -0
- package/es/libro-keybind-registry.d.ts.map +1 -0
- package/es/libro-keybind-registry.js +68 -0
- package/es/libro-model.d.ts +129 -0
- package/es/libro-model.d.ts.map +1 -0
- package/es/libro-model.js +803 -0
- package/es/libro-protocol.d.ts +241 -0
- package/es/libro-protocol.d.ts.map +1 -0
- package/es/libro-protocol.js +34 -0
- package/es/libro-service.d.ts +34 -0
- package/es/libro-service.d.ts.map +1 -0
- package/es/libro-service.js +180 -0
- package/es/libro-view-tracker.d.ts +6 -0
- package/es/libro-view-tracker.d.ts.map +1 -0
- package/es/libro-view-tracker.js +13 -0
- package/es/libro-view.d.ts +151 -0
- package/es/libro-view.d.ts.map +1 -0
- package/es/libro-view.js +1963 -0
- package/es/material-from-designer.d.ts +27 -0
- package/es/material-from-designer.d.ts.map +1 -0
- package/es/material-from-designer.js +550 -0
- package/es/module.d.ts +3 -0
- package/es/module.d.ts.map +1 -0
- package/es/module.js +55 -0
- package/es/output/index.d.ts +6 -0
- package/es/output/index.d.ts.map +1 -0
- package/es/output/index.js +5 -0
- package/es/output/output-area.d.ts +51 -0
- package/es/output/output-area.d.ts.map +1 -0
- package/es/output/output-area.js +346 -0
- package/es/output/output-contribution.d.ts +11 -0
- package/es/output/output-contribution.d.ts.map +1 -0
- package/es/output/output-contribution.js +31 -0
- package/es/output/output-model.d.ts +27 -0
- package/es/output/output-model.d.ts.map +1 -0
- package/es/output/output-model.js +95 -0
- package/es/output/output-module.d.ts +3 -0
- package/es/output/output-module.d.ts.map +1 -0
- package/es/output/output-module.js +6 -0
- package/es/output/output-protocol.d.ts +130 -0
- package/es/output/output-protocol.d.ts.map +1 -0
- package/es/output/output-protocol.js +18 -0
- package/es/slot/index.d.ts +5 -0
- package/es/slot/index.d.ts.map +1 -0
- package/es/slot/index.js +4 -0
- package/es/slot/libro-slot-manager.d.ts +13 -0
- package/es/slot/libro-slot-manager.d.ts.map +1 -0
- package/es/slot/libro-slot-manager.js +57 -0
- package/es/slot/libro-slot-protocol.d.ts +19 -0
- package/es/slot/libro-slot-protocol.d.ts.map +1 -0
- package/es/slot/libro-slot-protocol.js +5 -0
- package/es/slot/libro-slot-view.d.ts +9 -0
- package/es/slot/libro-slot-view.d.ts.map +1 -0
- package/es/slot/libro-slot-view.js +81 -0
- package/es/slot/module.d.ts +3 -0
- package/es/slot/module.d.ts.map +1 -0
- package/es/slot/module.js +5 -0
- package/es/theme/libro-color-registry.d.ts +6 -0
- package/es/theme/libro-color-registry.d.ts.map +1 -0
- package/es/theme/libro-color-registry.js +494 -0
- package/es/toolbar/change-cell-to-selector.d.ts +5 -0
- package/es/toolbar/change-cell-to-selector.d.ts.map +1 -0
- package/es/toolbar/change-cell-to-selector.js +48 -0
- package/es/toolbar/hide-all-selector.d.ts +5 -0
- package/es/toolbar/hide-all-selector.d.ts.map +1 -0
- package/es/toolbar/hide-all-selector.js +99 -0
- package/es/toolbar/index.d.ts +4 -0
- package/es/toolbar/index.d.ts.map +1 -0
- package/es/toolbar/index.js +3 -0
- package/es/toolbar/index.less +59 -0
- package/es/toolbar/libro-toolbar-protocol.d.ts +4 -0
- package/es/toolbar/libro-toolbar-protocol.d.ts.map +1 -0
- package/es/toolbar/libro-toolbar-protocol.js +1 -0
- package/es/toolbar/libro-toolbar.d.ts +8 -0
- package/es/toolbar/libro-toolbar.d.ts.map +1 -0
- package/es/toolbar/libro-toolbar.js +223 -0
- package/es/toolbar/module.d.ts +3 -0
- package/es/toolbar/module.d.ts.map +1 -0
- package/es/toolbar/module.js +5 -0
- package/es/toolbar/restart-clear-outputs-contribution.d.ts +5 -0
- package/es/toolbar/restart-clear-outputs-contribution.d.ts.map +1 -0
- package/es/toolbar/restart-clear-outputs-contribution.js +23 -0
- package/es/toolbar/restart-clear-outputs-modal.d.ts +6 -0
- package/es/toolbar/restart-clear-outputs-modal.d.ts.map +1 -0
- package/es/toolbar/restart-clear-outputs-modal.js +30 -0
- package/es/toolbar/save-icon.d.ts +3 -0
- package/es/toolbar/save-icon.d.ts.map +1 -0
- package/es/toolbar/save-icon.js +54 -0
- package/es/toolbar/shutdown-contribution.d.ts +5 -0
- package/es/toolbar/shutdown-contribution.d.ts.map +1 -0
- package/es/toolbar/shutdown-contribution.js +23 -0
- package/es/toolbar/shutdown-modal.d.ts +6 -0
- package/es/toolbar/shutdown-modal.d.ts.map +1 -0
- package/es/toolbar/shutdown-modal.js +30 -0
- package/es/toolbar/side-toolar-more-select.d.ts +4 -0
- package/es/toolbar/side-toolar-more-select.d.ts.map +1 -0
- package/es/toolbar/side-toolar-more-select.js +161 -0
- package/es/typings/index.d.ts +1 -0
- package/package.json +70 -0
- package/src/add-cell/index.less +38 -0
- package/src/add-cell/index.ts +3 -0
- package/src/add-cell/libro-add-cell-module.ts +9 -0
- package/src/add-cell/libro-add-cell-slot-contribution.ts +31 -0
- package/src/add-cell/libro-add-cell-view.tsx +101 -0
- package/src/cell/README.md +14 -0
- package/src/cell/index.ts +9 -0
- package/src/cell/libro-cell-contribution.ts +38 -0
- package/src/cell/libro-cell-model.ts +61 -0
- package/src/cell/libro-cell-module.ts +40 -0
- package/src/cell/libro-cell-protocol.ts +53 -0
- package/src/cell/libro-cell-service.ts +157 -0
- package/src/cell/libro-cell-view.tsx +128 -0
- package/src/cell/libro-edit-cell-view.tsx +60 -0
- package/src/cell/libro-executable-cell-model.ts +32 -0
- package/src/cell/libro-executable-cell-view.ts +74 -0
- package/src/cell/libro-markdown-cell-model.ts +20 -0
- package/src/collapse-service.ts +69 -0
- package/src/command/document-commands.ts +18 -0
- package/src/command/index.ts +6 -0
- package/src/command/kernel-command.ts +41 -0
- package/src/command/libro-command-contribution.ts +1339 -0
- package/src/command/libro-command-register.ts +171 -0
- package/src/command/module.ts +9 -0
- package/src/command/notebook-commands.ts +498 -0
- package/src/components/cell-protocol.ts +22 -0
- package/src/components/dnd-cell-item-render.tsx +308 -0
- package/src/components/dnd-component/custom-drag-layer.tsx +145 -0
- package/src/components/dnd-component/default-dnd-content.tsx +275 -0
- package/src/components/dnd-component/dnd-context.tsx +28 -0
- package/src/components/dnd-component/dnd-list.tsx +116 -0
- package/src/components/dnd-component/index.tsx +4 -0
- package/src/components/index.ts +5 -0
- package/src/components/libro-component.tsx +30 -0
- package/src/components/libro-side-toolbar-menu.tsx +82 -0
- package/src/components/libro-view-header.tsx +33 -0
- package/src/configuration/libro-configuration-contribution.ts +29 -0
- package/src/configuration/libro-configuration.ts +88 -0
- package/src/content/index.ts +4 -0
- package/src/content/libro-content-contribution.ts +17 -0
- package/src/content/libro-content-module.ts +9 -0
- package/src/content/libro-content-protocol.ts +8 -0
- package/src/content/libro-content-service.ts +30 -0
- package/src/index.less +682 -0
- package/src/index.tsx +19 -0
- package/src/libro-context-key.ts +80 -0
- package/src/libro-keybind-registry.ts +43 -0
- package/src/libro-model.ts +614 -0
- package/src/libro-protocol.ts +322 -0
- package/src/libro-service.ts +121 -0
- package/src/libro-view-tracker.ts +9 -0
- package/src/libro-view.tsx +1399 -0
- package/src/material-from-designer.tsx +457 -0
- package/src/module.ts +90 -0
- package/src/output/index.ts +5 -0
- package/src/output/output-area.tsx +255 -0
- package/src/output/output-contribution.ts +18 -0
- package/src/output/output-model.tsx +66 -0
- package/src/output/output-module.ts +10 -0
- package/src/output/output-protocol.ts +164 -0
- package/src/slot/index.ts +4 -0
- package/src/slot/libro-slot-manager.ts +37 -0
- package/src/slot/libro-slot-protocol.ts +28 -0
- package/src/slot/libro-slot-view.tsx +51 -0
- package/src/slot/module.ts +9 -0
- package/src/theme/libro-color-registry.ts +371 -0
- package/src/toolbar/change-cell-to-selector.tsx +58 -0
- package/src/toolbar/hide-all-selector.tsx +126 -0
- package/src/toolbar/index.less +59 -0
- package/src/toolbar/index.ts +3 -0
- package/src/toolbar/libro-toolbar-protocol.ts +4 -0
- package/src/toolbar/libro-toolbar.tsx +192 -0
- package/src/toolbar/module.ts +11 -0
- package/src/toolbar/restart-clear-outputs-contribution.tsx +10 -0
- package/src/toolbar/restart-clear-outputs-modal.tsx +37 -0
- package/src/toolbar/save-icon.tsx +47 -0
- package/src/toolbar/shutdown-contribution.tsx +10 -0
- package/src/toolbar/shutdown-modal.tsx +37 -0
- package/src/toolbar/side-toolar-more-select.tsx +172 -0
- package/src/typings/index.d.ts +1 -0
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
/// <reference types="react" resolution-mode="require"/>
|
|
2
|
+
import type { IModel } from '@difizen/libro-code-editor';
|
|
3
|
+
import type { CellType, ICell, ICellMetadata, INotebookContent, INotebookMetadata } from '@difizen/libro-common';
|
|
4
|
+
import type { ISharedNotebook } from '@difizen/libro-shared-model';
|
|
5
|
+
import { View } from '@difizen/mana-app';
|
|
6
|
+
import type { Disposable, Event } from '@difizen/mana-app';
|
|
7
|
+
import type { LibroCell } from './cell/index.js';
|
|
8
|
+
import type { LibroView } from './libro-view.js';
|
|
9
|
+
export declare const LibroContextKeys: {
|
|
10
|
+
active: string;
|
|
11
|
+
focus: string;
|
|
12
|
+
commandMode: string;
|
|
13
|
+
};
|
|
14
|
+
export declare const LibroToolbarArea: {
|
|
15
|
+
HeaderLeft: string;
|
|
16
|
+
HeaderCenter: string;
|
|
17
|
+
HeaderRight: string;
|
|
18
|
+
CellTop: string;
|
|
19
|
+
CellRight: string;
|
|
20
|
+
};
|
|
21
|
+
export declare const NotebookOption: unique symbol;
|
|
22
|
+
/**
|
|
23
|
+
* Libro 创建参数
|
|
24
|
+
* 默认可 json 序列化
|
|
25
|
+
*/
|
|
26
|
+
export interface NotebookOption extends Options {
|
|
27
|
+
id?: string;
|
|
28
|
+
modelId?: string;
|
|
29
|
+
[key: string]: any;
|
|
30
|
+
}
|
|
31
|
+
export declare const ModelFactory: unique symbol;
|
|
32
|
+
export type ModelFactory<T = NotebookOption> = (options: T) => NotebookModel;
|
|
33
|
+
export declare const NotebookModel: unique symbol;
|
|
34
|
+
export type Options = {
|
|
35
|
+
id?: string;
|
|
36
|
+
[key: string]: any;
|
|
37
|
+
};
|
|
38
|
+
export type NotebookModel = BaseNotebookModel & DndListModel;
|
|
39
|
+
export interface BaseNotebookModel {
|
|
40
|
+
id: string;
|
|
41
|
+
/**
|
|
42
|
+
* The dirty state of the model.
|
|
43
|
+
* #### Notes
|
|
44
|
+
* This should be cleared when the document is loaded from
|
|
45
|
+
* or saved to disk.
|
|
46
|
+
*/
|
|
47
|
+
dirty: boolean;
|
|
48
|
+
executeCount: number;
|
|
49
|
+
lastClipboardInteraction?: string;
|
|
50
|
+
clipboard?: CellView | CellView[];
|
|
51
|
+
active?: CellView | undefined;
|
|
52
|
+
activeIndex: number;
|
|
53
|
+
dndAreaNullEnable: boolean;
|
|
54
|
+
/**
|
|
55
|
+
* The read-only state of the model.
|
|
56
|
+
*/
|
|
57
|
+
readOnly: boolean;
|
|
58
|
+
/**
|
|
59
|
+
* The quick edit mode the model.
|
|
60
|
+
*/
|
|
61
|
+
quickEditMode: boolean;
|
|
62
|
+
/**
|
|
63
|
+
* The command mode of the model.
|
|
64
|
+
*/
|
|
65
|
+
commandMode: boolean;
|
|
66
|
+
trusted: boolean;
|
|
67
|
+
onCommandModeChanged: Event<boolean>;
|
|
68
|
+
onContentChanged: Event<boolean>;
|
|
69
|
+
getCells: () => CellView[];
|
|
70
|
+
/**
|
|
71
|
+
* Serialize the model to a string.
|
|
72
|
+
*/
|
|
73
|
+
toString: () => string;
|
|
74
|
+
/**
|
|
75
|
+
* Deserialize the model from a string.
|
|
76
|
+
*
|
|
77
|
+
* #### Notes
|
|
78
|
+
* Should emit a [contentChanged] signal.
|
|
79
|
+
*/
|
|
80
|
+
fromString: (value: string) => void;
|
|
81
|
+
/**
|
|
82
|
+
* The list of cells in the notebook.
|
|
83
|
+
*/
|
|
84
|
+
cells: CellView[];
|
|
85
|
+
selections: CellView[];
|
|
86
|
+
canUndo?: boolean;
|
|
87
|
+
canRedo?: boolean;
|
|
88
|
+
/**
|
|
89
|
+
* The metadata associated with the notebook.
|
|
90
|
+
*/
|
|
91
|
+
readonly metadata: INotebookMetadata;
|
|
92
|
+
/**
|
|
93
|
+
* The array of deleted cells since the notebook was last run.
|
|
94
|
+
*/
|
|
95
|
+
readonly deletedCells: CellView[];
|
|
96
|
+
/**
|
|
97
|
+
* If the model is initialized or not.
|
|
98
|
+
*/
|
|
99
|
+
isInitialized: boolean;
|
|
100
|
+
initialize: () => Promise<CellOptions[]>;
|
|
101
|
+
options: Options;
|
|
102
|
+
/**
|
|
103
|
+
* save notebook
|
|
104
|
+
*/
|
|
105
|
+
toJSON: () => INotebookContent;
|
|
106
|
+
saveNotebookContent: () => Promise<void>;
|
|
107
|
+
fontSize: number;
|
|
108
|
+
theme: string;
|
|
109
|
+
/**
|
|
110
|
+
* 聚焦
|
|
111
|
+
*/
|
|
112
|
+
focus?: () => void;
|
|
113
|
+
blur?: () => void;
|
|
114
|
+
/**
|
|
115
|
+
* 进入命令模式
|
|
116
|
+
*/
|
|
117
|
+
enterCommandMode?: () => void;
|
|
118
|
+
enterEditMode?: () => void;
|
|
119
|
+
onChange?: () => void;
|
|
120
|
+
interrupt?: () => void;
|
|
121
|
+
canRun?: () => boolean;
|
|
122
|
+
restart?: () => void;
|
|
123
|
+
shutdown?: () => void;
|
|
124
|
+
undo: () => void;
|
|
125
|
+
redo: () => void;
|
|
126
|
+
readonly sharedModel: ISharedNotebook;
|
|
127
|
+
scrollToView: (cell: CellView) => void;
|
|
128
|
+
customParams: Record<string, any>;
|
|
129
|
+
getCustomKey: (key: string) => any;
|
|
130
|
+
setCustomKey: (key: string, val: any) => void;
|
|
131
|
+
libroViewClass: string;
|
|
132
|
+
}
|
|
133
|
+
export declare const notebookViewFactoryId = "notebook-view-factory";
|
|
134
|
+
export type NotebookView = LibroView;
|
|
135
|
+
export interface CellView extends View {
|
|
136
|
+
model: CellModel;
|
|
137
|
+
parent: NotebookView;
|
|
138
|
+
wrapperCls?: string;
|
|
139
|
+
blur: () => void;
|
|
140
|
+
focus: (isEdit: boolean) => void;
|
|
141
|
+
run: () => Promise<boolean>;
|
|
142
|
+
shouldEnterEditorMode: (e: React.FocusEvent<HTMLElement>) => boolean;
|
|
143
|
+
hasCellHidden: () => boolean;
|
|
144
|
+
hasInputHidden: boolean;
|
|
145
|
+
hasModal: boolean;
|
|
146
|
+
/**
|
|
147
|
+
* 是否被折叠隐藏
|
|
148
|
+
*/
|
|
149
|
+
collapsedHidden: boolean;
|
|
150
|
+
toJSON: () => ICell;
|
|
151
|
+
toJSONWithoutId: () => ICell;
|
|
152
|
+
}
|
|
153
|
+
export declare function isCellView(view: View): view is CellView;
|
|
154
|
+
export declare const CellOptions: unique symbol;
|
|
155
|
+
export interface CellOptions {
|
|
156
|
+
id?: string;
|
|
157
|
+
modelId?: string;
|
|
158
|
+
mimetype?: string;
|
|
159
|
+
cell: LibroCell;
|
|
160
|
+
[key: string]: any;
|
|
161
|
+
}
|
|
162
|
+
export declare const CellViewOptions: unique symbol;
|
|
163
|
+
export interface CellViewOptions {
|
|
164
|
+
parentId: string;
|
|
165
|
+
id: string;
|
|
166
|
+
modelId: string;
|
|
167
|
+
mimetype?: string;
|
|
168
|
+
cell: ICell;
|
|
169
|
+
[key: string]: any;
|
|
170
|
+
}
|
|
171
|
+
export interface CellModel extends IModel, Disposable {
|
|
172
|
+
/**
|
|
173
|
+
* A unique identifier for the cell.
|
|
174
|
+
*/
|
|
175
|
+
id: string;
|
|
176
|
+
/**
|
|
177
|
+
* The type of the cell.
|
|
178
|
+
*/
|
|
179
|
+
type: CellType;
|
|
180
|
+
/**
|
|
181
|
+
* A signal emitted when the content of the model changes.
|
|
182
|
+
*/
|
|
183
|
+
/**
|
|
184
|
+
* A signal emitted when a model state changes.
|
|
185
|
+
*/
|
|
186
|
+
/**
|
|
187
|
+
* Whether the cell is trusted.
|
|
188
|
+
*/
|
|
189
|
+
trusted: boolean;
|
|
190
|
+
/**
|
|
191
|
+
* The metadata associated with the cell.
|
|
192
|
+
*/
|
|
193
|
+
readonly metadata: Partial<ICellMetadata>;
|
|
194
|
+
/**
|
|
195
|
+
* Serialize the model to JSON.
|
|
196
|
+
* 输出时的字段顺序也要保持稳定
|
|
197
|
+
*/
|
|
198
|
+
toJSON: () => Omit<ICell, 'outputs'>;
|
|
199
|
+
options: CellOptions;
|
|
200
|
+
}
|
|
201
|
+
export declare const NotebookService: unique symbol;
|
|
202
|
+
export interface NotebookService {
|
|
203
|
+
getOrCreateModel: (options: NotebookOption) => NotebookModel;
|
|
204
|
+
getOrCreateView: (options: NotebookOption) => Promise<NotebookView>;
|
|
205
|
+
setActive: (view: NotebookView | undefined) => void;
|
|
206
|
+
onActiveChanged: Event<NotebookView | undefined>;
|
|
207
|
+
}
|
|
208
|
+
export declare const DragAreaKey: unique symbol;
|
|
209
|
+
export type MouseMode = 'multipleSelection' | 'mouseDown' | 'drag';
|
|
210
|
+
export interface DndListModel {
|
|
211
|
+
mouseMode?: MouseMode;
|
|
212
|
+
active?: CellView | undefined;
|
|
213
|
+
hover?: CellView | undefined;
|
|
214
|
+
selectCell: (cell: CellView) => void;
|
|
215
|
+
addCell: (cell: CellView, position?: number, mode?: string) => void;
|
|
216
|
+
insertCells: (cells: CellView[], position?: number, mode?: string) => void;
|
|
217
|
+
invertCell: (toAddcell: CellView, position: number) => void;
|
|
218
|
+
splitCell: (newCells: CellView[], position: number) => void;
|
|
219
|
+
deleteCell: {
|
|
220
|
+
(id: string): boolean;
|
|
221
|
+
(index: number): boolean;
|
|
222
|
+
(cell: CellView): boolean;
|
|
223
|
+
};
|
|
224
|
+
exchangeCell: {
|
|
225
|
+
(source: CellView, target: CellView): boolean;
|
|
226
|
+
(sourceIndex: number, targetIndex: number): boolean;
|
|
227
|
+
(sourceId: string, targetId: string): boolean;
|
|
228
|
+
};
|
|
229
|
+
exchangeCells: (source: CellView[], targetIndex: number) => void;
|
|
230
|
+
}
|
|
231
|
+
export interface DndContentProps {
|
|
232
|
+
cell: CellView;
|
|
233
|
+
index: number;
|
|
234
|
+
}
|
|
235
|
+
export interface DndItemProps {
|
|
236
|
+
isDragOver: boolean;
|
|
237
|
+
isDrag: boolean;
|
|
238
|
+
cell: CellView;
|
|
239
|
+
isMouseOverDragArea?: boolean;
|
|
240
|
+
}
|
|
241
|
+
//# sourceMappingURL=libro-protocol.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"libro-protocol.d.ts","sourceRoot":"","sources":["../src/libro-protocol.ts"],"names":[],"mappings":";AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AACzD,OAAO,KAAK,EACV,QAAQ,EACR,KAAK,EACL,aAAa,EACb,gBAAgB,EAChB,iBAAiB,EAClB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AACnE,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACzC,OAAO,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAE3D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAEjD,eAAO,MAAM,gBAAgB;;;;CAI5B,CAAC;AAEF,eAAO,MAAM,gBAAgB;;;;;;CAM5B,CAAC;AACF,eAAO,MAAM,cAAc,eAA2B,CAAC;AACvD;;;GAGG;AACH,MAAM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,OAAO,CAAC;IACpB,MAAM,EAAE,OAAO,CAAC;IAChB,IAAI,EAAE,QAAQ,CAAC;IACf,mBAAmB,CAAC,EAAE,OAAO,CAAC;CAC/B"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/unified-signatures */
|
|
2
|
+
|
|
3
|
+
import { View } from '@difizen/mana-app';
|
|
4
|
+
export var LibroContextKeys = {
|
|
5
|
+
active: 'active',
|
|
6
|
+
focus: 'focus',
|
|
7
|
+
commandMode: 'commandMode'
|
|
8
|
+
};
|
|
9
|
+
export var LibroToolbarArea = {
|
|
10
|
+
HeaderLeft: 'header-left',
|
|
11
|
+
HeaderCenter: 'header-center',
|
|
12
|
+
HeaderRight: 'header-right',
|
|
13
|
+
CellTop: 'top',
|
|
14
|
+
CellRight: 'right'
|
|
15
|
+
};
|
|
16
|
+
export var NotebookOption = Symbol('NotebookOption');
|
|
17
|
+
/**
|
|
18
|
+
* Libro 创建参数
|
|
19
|
+
* 默认可 json 序列化
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
export var ModelFactory = Symbol('ModelFactory');
|
|
23
|
+
export var NotebookModel = Symbol('NotebookModel');
|
|
24
|
+
export var notebookViewFactoryId = 'notebook-view-factory';
|
|
25
|
+
export function isCellView(view) {
|
|
26
|
+
return View.is(view) && 'model' in view;
|
|
27
|
+
}
|
|
28
|
+
export var CellOptions = Symbol('CellOptions');
|
|
29
|
+
export var CellViewOptions = Symbol('CellViewOptions');
|
|
30
|
+
export var NotebookService = Symbol('NotebookService');
|
|
31
|
+
//#region Protocol for drag & drop
|
|
32
|
+
export var DragAreaKey = Symbol('DragAreaKey');
|
|
33
|
+
|
|
34
|
+
//#endregion
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { Emitter } from '@difizen/mana-app';
|
|
2
|
+
import { ThemeService, ViewManager } from '@difizen/mana-app';
|
|
3
|
+
import type { NotebookOption, NotebookView } from './libro-protocol.js';
|
|
4
|
+
import { ModelFactory, NotebookService } from './libro-protocol.js';
|
|
5
|
+
import { LibroViewTracker } from './libro-view-tracker.js';
|
|
6
|
+
export declare class LibroService implements NotebookService {
|
|
7
|
+
protected libroModelFactory: ModelFactory;
|
|
8
|
+
protected viewManager: ViewManager;
|
|
9
|
+
protected libroViewTracker: LibroViewTracker;
|
|
10
|
+
protected themeService: ThemeService;
|
|
11
|
+
themeMode: string;
|
|
12
|
+
constructor(themeService: ThemeService, libroModelFactory: ModelFactory, viewManager: ViewManager, libroViewTracker: LibroViewTracker);
|
|
13
|
+
protected _active?: NotebookView;
|
|
14
|
+
protected onActiveChangedEmitter: Emitter<NotebookView | undefined>;
|
|
15
|
+
get onActiveChanged(): import("@difizen/mana-app").Event<import("./libro-view.js").LibroView | undefined>;
|
|
16
|
+
get active(): NotebookView | undefined;
|
|
17
|
+
set active(value: NotebookView | undefined);
|
|
18
|
+
protected _focus?: NotebookView;
|
|
19
|
+
protected onFocusChangedEmitter: Emitter<NotebookView | undefined>;
|
|
20
|
+
get onFocusChanged(): import("@difizen/mana-app").Event<import("./libro-view.js").LibroView | undefined>;
|
|
21
|
+
protected onNotebookViewCreatedEmitter: Emitter<NotebookView>;
|
|
22
|
+
get onNotebookViewCreated(): import("@difizen/mana-app").Event<import("./libro-view.js").LibroView>;
|
|
23
|
+
get focus(): NotebookView | undefined;
|
|
24
|
+
set focus(value: NotebookView | undefined);
|
|
25
|
+
get hasFocus(): boolean;
|
|
26
|
+
getViewCache(): Map<string, NotebookView>;
|
|
27
|
+
deleteLibroViewFromCache(instance: NotebookView): void;
|
|
28
|
+
protected _hasFocus: boolean;
|
|
29
|
+
getOrCreateModel(options: NotebookOption): import("./libro-protocol.js").NotebookModel;
|
|
30
|
+
getOrCreateView(options: NotebookOption): Promise<NotebookView>;
|
|
31
|
+
setActive(view?: NotebookView): void;
|
|
32
|
+
setHasFocus(hasFocus: boolean): void;
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=libro-service.d.ts.map
|
|
@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qB,2EAExB;IAED,IAAI,KAAK,IAAI,YAAY,GAAG,SAAS,CAEpC;IACD,IAAI,KAAK,CAAC,KAAK,EAAE,YAAY,GAAG,SAAS,EAGxC;IAED,IAAI,QAAQ,IAAI,OAAO,CAEtB;IAED,YAAY,IAAI,GAAG,CAAC,MAAM,EAAE,YAAY,CAAC;IAIzC,wBAAwB,CAAC,QAAQ,EAAE,YAAY;IAM/C,SAAS,CAAC,SAAS,UAAS;IAE5B,gBAAgB,CAAC,OAAO,EAAE,cAAc;IAWlC,eAAe,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,YAAY,CAAC;IAerE,SAAS,CAAC,IAAI,CAAC,EAAE,YAAY,GAAG,IAAI;IAKpC,WAAW,CAAC,QAAQ,EAAE,OAAO,GAAG,IAAI;CAGrC"}
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
2
|
+
var _dec, _dec2, _dec3, _dec4, _dec5, _class, _class2, _descriptor, _descriptor2, _descriptor3, _descriptor4;
|
|
3
|
+
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = Object.defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; defineProperty(this, "_invoke", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; } function maybeInvokeDelegate(delegate, context) { var methodName = context.method, method = delegate.iterator[methodName]; if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel; var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (val) { var object = Object(val), keys = []; for (var key in object) keys.push(key); return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, catch: function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
|
|
4
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
5
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
6
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
7
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
8
|
+
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
9
|
+
function _initializerDefineProperty(target, property, descriptor, context) { if (!descriptor) return; Object.defineProperty(target, property, { enumerable: descriptor.enumerable, configurable: descriptor.configurable, writable: descriptor.writable, value: descriptor.initializer ? descriptor.initializer.call(context) : void 0 }); }
|
|
10
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
11
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
12
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
13
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
14
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
15
|
+
function _applyDecoratedDescriptor(target, property, decorators, descriptor, context) { var desc = {}; Object.keys(descriptor).forEach(function (key) { desc[key] = descriptor[key]; }); desc.enumerable = !!desc.enumerable; desc.configurable = !!desc.configurable; if ('value' in desc || desc.initializer) { desc.writable = true; } desc = decorators.slice().reverse().reduce(function (desc, decorator) { return decorator(target, property, desc) || desc; }, desc); if (context && desc.initializer !== void 0) { desc.value = desc.initializer ? desc.initializer.call(context) : void 0; desc.initializer = undefined; } if (desc.initializer === void 0) { Object.defineProperty(target, property, desc); desc = null; } return desc; }
|
|
16
|
+
function _initializerWarningHelper(descriptor, context) { throw new Error('Decorating class property failed. Please ensure that ' + 'transform-class-properties is enabled and runs after the decorators transform.'); }
|
|
17
|
+
import { Emitter } from '@difizen/mana-app';
|
|
18
|
+
import { ThemeService, ViewManager } from '@difizen/mana-app';
|
|
19
|
+
import { inject, singleton } from '@difizen/mana-app';
|
|
20
|
+
import { prop } from '@difizen/mana-app';
|
|
21
|
+
import { notebookViewFactoryId, ModelFactory, NotebookService } from "./libro-protocol.js";
|
|
22
|
+
import { LibroViewTracker } from "./libro-view-tracker.js";
|
|
23
|
+
export var LibroService = (_dec = singleton({
|
|
24
|
+
contrib: NotebookService
|
|
25
|
+
}), _dec2 = prop(), _dec3 = prop(), _dec4 = prop(), _dec5 = prop(), _dec(_class = (_class2 = /*#__PURE__*/function () {
|
|
26
|
+
function LibroService(themeService, libroModelFactory, viewManager, libroViewTracker) {
|
|
27
|
+
var _this = this;
|
|
28
|
+
_classCallCheck(this, LibroService);
|
|
29
|
+
this.libroModelFactory = void 0;
|
|
30
|
+
this.viewManager = void 0;
|
|
31
|
+
this.libroViewTracker = void 0;
|
|
32
|
+
this.themeService = void 0;
|
|
33
|
+
_initializerDefineProperty(this, "themeMode", _descriptor, this);
|
|
34
|
+
_initializerDefineProperty(this, "_active", _descriptor2, this);
|
|
35
|
+
this.onActiveChangedEmitter = new Emitter();
|
|
36
|
+
_initializerDefineProperty(this, "_focus", _descriptor3, this);
|
|
37
|
+
this.onFocusChangedEmitter = new Emitter();
|
|
38
|
+
this.onNotebookViewCreatedEmitter = new Emitter();
|
|
39
|
+
_initializerDefineProperty(this, "_hasFocus", _descriptor4, this);
|
|
40
|
+
this.themeService = themeService;
|
|
41
|
+
this.themeMode = this.themeService.getCurrentTheme().type;
|
|
42
|
+
this.themeService.onDidColorThemeChange(function (e) {
|
|
43
|
+
_this.themeMode = e.newTheme.type;
|
|
44
|
+
});
|
|
45
|
+
this.libroModelFactory = libroModelFactory;
|
|
46
|
+
this.viewManager = viewManager;
|
|
47
|
+
this.libroViewTracker = libroViewTracker;
|
|
48
|
+
}
|
|
49
|
+
LibroService = inject(LibroViewTracker)(LibroService, undefined, 3) || LibroService;
|
|
50
|
+
LibroService = inject(ViewManager)(LibroService, undefined, 2) || LibroService;
|
|
51
|
+
LibroService = inject(ModelFactory)(LibroService, undefined, 1) || LibroService;
|
|
52
|
+
LibroService = inject(ThemeService)(LibroService, undefined, 0) || LibroService;
|
|
53
|
+
_createClass(LibroService, [{
|
|
54
|
+
key: "onActiveChanged",
|
|
55
|
+
get: function get() {
|
|
56
|
+
return this.onActiveChangedEmitter.event;
|
|
57
|
+
}
|
|
58
|
+
}, {
|
|
59
|
+
key: "active",
|
|
60
|
+
get: function get() {
|
|
61
|
+
return this._active;
|
|
62
|
+
},
|
|
63
|
+
set: function set(value) {
|
|
64
|
+
this._active = value;
|
|
65
|
+
this.onActiveChangedEmitter.fire(value);
|
|
66
|
+
}
|
|
67
|
+
}, {
|
|
68
|
+
key: "onFocusChanged",
|
|
69
|
+
get: function get() {
|
|
70
|
+
return this.onFocusChangedEmitter.event;
|
|
71
|
+
}
|
|
72
|
+
}, {
|
|
73
|
+
key: "onNotebookViewCreated",
|
|
74
|
+
get: function get() {
|
|
75
|
+
return this.onNotebookViewCreatedEmitter.event;
|
|
76
|
+
}
|
|
77
|
+
}, {
|
|
78
|
+
key: "focus",
|
|
79
|
+
get: function get() {
|
|
80
|
+
return this._focus;
|
|
81
|
+
},
|
|
82
|
+
set: function set(value) {
|
|
83
|
+
this._focus = value;
|
|
84
|
+
this.onFocusChangedEmitter.fire(value);
|
|
85
|
+
}
|
|
86
|
+
}, {
|
|
87
|
+
key: "hasFocus",
|
|
88
|
+
get: function get() {
|
|
89
|
+
return this._hasFocus;
|
|
90
|
+
}
|
|
91
|
+
}, {
|
|
92
|
+
key: "getViewCache",
|
|
93
|
+
value: function getViewCache() {
|
|
94
|
+
return this.libroViewTracker.viewCache;
|
|
95
|
+
}
|
|
96
|
+
}, {
|
|
97
|
+
key: "deleteLibroViewFromCache",
|
|
98
|
+
value: function deleteLibroViewFromCache(instance) {
|
|
99
|
+
this.libroViewTracker.viewCache.delete(instance.id);
|
|
100
|
+
this.libroViewTracker.modelCache.delete(instance.model.id);
|
|
101
|
+
}
|
|
102
|
+
}, {
|
|
103
|
+
key: "getOrCreateModel",
|
|
104
|
+
value: function getOrCreateModel(options) {
|
|
105
|
+
if (options.modelId) {
|
|
106
|
+
var exist = this.libroViewTracker.modelCache.get(options.modelId);
|
|
107
|
+
if (exist) {
|
|
108
|
+
return exist;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
var model = this.libroModelFactory(options);
|
|
112
|
+
this.libroViewTracker.modelCache.set(model.id, model);
|
|
113
|
+
return model;
|
|
114
|
+
}
|
|
115
|
+
}, {
|
|
116
|
+
key: "getOrCreateView",
|
|
117
|
+
value: function () {
|
|
118
|
+
var _getOrCreateView = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(options) {
|
|
119
|
+
var model, notebookViewPromise, notebookView;
|
|
120
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
121
|
+
while (1) switch (_context.prev = _context.next) {
|
|
122
|
+
case 0:
|
|
123
|
+
model = this.getOrCreateModel(options);
|
|
124
|
+
notebookViewPromise = this.viewManager.getOrCreateView(notebookViewFactoryId, _objectSpread(_objectSpread({}, options || {}), {}, {
|
|
125
|
+
modelId: model.id
|
|
126
|
+
}));
|
|
127
|
+
_context.next = 4;
|
|
128
|
+
return notebookViewPromise;
|
|
129
|
+
case 4:
|
|
130
|
+
notebookView = _context.sent;
|
|
131
|
+
this.libroViewTracker.viewCache.set(notebookView.id, notebookView);
|
|
132
|
+
this.onNotebookViewCreatedEmitter.fire(notebookView);
|
|
133
|
+
return _context.abrupt("return", notebookViewPromise);
|
|
134
|
+
case 8:
|
|
135
|
+
case "end":
|
|
136
|
+
return _context.stop();
|
|
137
|
+
}
|
|
138
|
+
}, _callee, this);
|
|
139
|
+
}));
|
|
140
|
+
function getOrCreateView(_x) {
|
|
141
|
+
return _getOrCreateView.apply(this, arguments);
|
|
142
|
+
}
|
|
143
|
+
return getOrCreateView;
|
|
144
|
+
}()
|
|
145
|
+
}, {
|
|
146
|
+
key: "setActive",
|
|
147
|
+
value: function setActive(view) {
|
|
148
|
+
this._active = view;
|
|
149
|
+
this.onActiveChangedEmitter.fire(view);
|
|
150
|
+
}
|
|
151
|
+
}, {
|
|
152
|
+
key: "setHasFocus",
|
|
153
|
+
value: function setHasFocus(hasFocus) {
|
|
154
|
+
this._hasFocus = hasFocus;
|
|
155
|
+
}
|
|
156
|
+
}]);
|
|
157
|
+
return LibroService;
|
|
158
|
+
}(), (_descriptor = _applyDecoratedDescriptor(_class2.prototype, "themeMode", [_dec2], {
|
|
159
|
+
configurable: true,
|
|
160
|
+
enumerable: true,
|
|
161
|
+
writable: true,
|
|
162
|
+
initializer: null
|
|
163
|
+
}), _descriptor2 = _applyDecoratedDescriptor(_class2.prototype, "_active", [_dec3], {
|
|
164
|
+
configurable: true,
|
|
165
|
+
enumerable: true,
|
|
166
|
+
writable: true,
|
|
167
|
+
initializer: null
|
|
168
|
+
}), _descriptor3 = _applyDecoratedDescriptor(_class2.prototype, "_focus", [_dec4], {
|
|
169
|
+
configurable: true,
|
|
170
|
+
enumerable: true,
|
|
171
|
+
writable: true,
|
|
172
|
+
initializer: null
|
|
173
|
+
}), _descriptor4 = _applyDecoratedDescriptor(_class2.prototype, "_hasFocus", [_dec5], {
|
|
174
|
+
configurable: true,
|
|
175
|
+
enumerable: true,
|
|
176
|
+
writable: true,
|
|
177
|
+
initializer: function initializer() {
|
|
178
|
+
return false;
|
|
179
|
+
}
|
|
180
|
+
})), _class2)) || _class);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"libro-view-tracker.d.ts","sourceRoot":"","sources":["../src/libro-view-tracker.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAEvE,qBACa,gBAAgB;IAC3B,SAAS,EAAE,GAAG,CAAC,MAAM,EAAE,YAAY,CAAC,CAAa;IACjD,UAAU,EAAE,GAAG,CAAC,MAAM,EAAE,aAAa,CAAC,CAAa;CACpD"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
2
|
+
var _dec, _class;
|
|
3
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
4
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
5
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
6
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
7
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
8
|
+
import { singleton } from '@difizen/mana-app';
|
|
9
|
+
export var LibroViewTracker = (_dec = singleton(), _dec(_class = /*#__PURE__*/_createClass(function LibroViewTracker() {
|
|
10
|
+
_classCallCheck(this, LibroViewTracker);
|
|
11
|
+
this.viewCache = new Map();
|
|
12
|
+
this.modelCache = new Map();
|
|
13
|
+
})) || _class);
|