@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,192 @@
|
|
|
1
|
+
import type { ToolbarRegistry } from '@difizen/mana-app';
|
|
2
|
+
import {
|
|
3
|
+
inject,
|
|
4
|
+
ModalService,
|
|
5
|
+
singleton,
|
|
6
|
+
ToolbarContribution,
|
|
7
|
+
} from '@difizen/mana-app';
|
|
8
|
+
import { l10n } from '@difizen/mana-l10n';
|
|
9
|
+
|
|
10
|
+
import { DocumentCommands, NotebookCommands } from '../command/index.js';
|
|
11
|
+
|
|
12
|
+
import { ToolItemSelect } from './change-cell-to-selector.js';
|
|
13
|
+
import { HideAllSelect } from './hide-all-selector.js';
|
|
14
|
+
// import { RunSelect } from './run-selector';
|
|
15
|
+
import { SaveIcon } from './save-icon.js';
|
|
16
|
+
import { SideToolbarMoreSelect } from './side-toolar-more-select.js';
|
|
17
|
+
// import { SideToolbarRunSelect } from './side-toolbar-run-select';
|
|
18
|
+
@singleton({ contrib: [ToolbarContribution] })
|
|
19
|
+
export class LibroToolbarContribution implements ToolbarContribution {
|
|
20
|
+
protected readonly modalService: ModalService;
|
|
21
|
+
|
|
22
|
+
constructor(@inject(ModalService) modalService: ModalService) {
|
|
23
|
+
this.modalService = modalService;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
registerToolbarItems(registry: ToolbarRegistry): void {
|
|
27
|
+
registry.registerItem({
|
|
28
|
+
id: DocumentCommands['Save'].id,
|
|
29
|
+
command: DocumentCommands['Save'].id,
|
|
30
|
+
icon: SaveIcon,
|
|
31
|
+
tooltip: (
|
|
32
|
+
<div className="libro-tooltip">
|
|
33
|
+
<span className="libro-tooltip-text">{l10n.t('保存')}</span>
|
|
34
|
+
<span className="libro-tooltip-keybind">Cmd + S</span>
|
|
35
|
+
</div>
|
|
36
|
+
),
|
|
37
|
+
|
|
38
|
+
group: ['group1'],
|
|
39
|
+
order: '1',
|
|
40
|
+
});
|
|
41
|
+
registry.registerItem({
|
|
42
|
+
id: NotebookCommands['Interrupt'].id,
|
|
43
|
+
command: NotebookCommands['Interrupt'].id,
|
|
44
|
+
tooltip: (
|
|
45
|
+
<div className="libro-tooltip">
|
|
46
|
+
<span className="libro-tooltip-text">{l10n.t('中断')}</span>
|
|
47
|
+
</div>
|
|
48
|
+
),
|
|
49
|
+
|
|
50
|
+
showLabelInline: true,
|
|
51
|
+
group: ['group2'],
|
|
52
|
+
order: 'b-all',
|
|
53
|
+
});
|
|
54
|
+
registry.registerItem({
|
|
55
|
+
id: NotebookCommands['CloseAndShutdown'].id,
|
|
56
|
+
command: NotebookCommands['CloseAndShutdown'].id,
|
|
57
|
+
tooltip: (
|
|
58
|
+
<div className="libro-tooltip">
|
|
59
|
+
<span className="libro-tooltip-text">{l10n.t('关闭内核')}</span>
|
|
60
|
+
</div>
|
|
61
|
+
),
|
|
62
|
+
|
|
63
|
+
showLabelInline: true,
|
|
64
|
+
group: ['group2'],
|
|
65
|
+
order: 'b-all',
|
|
66
|
+
});
|
|
67
|
+
registry.registerItem({
|
|
68
|
+
id: NotebookCommands['RestartClearOutput'].id,
|
|
69
|
+
command: NotebookCommands['RestartClearOutput'].id,
|
|
70
|
+
tooltip: (
|
|
71
|
+
<div className="libro-tooltip">
|
|
72
|
+
<span className="libro-tooltip-text">{l10n.t('重启并清空输出')}</span>
|
|
73
|
+
</div>
|
|
74
|
+
),
|
|
75
|
+
|
|
76
|
+
showLabelInline: true,
|
|
77
|
+
group: ['group2'],
|
|
78
|
+
order: 'c-all',
|
|
79
|
+
});
|
|
80
|
+
registry.registerItem({
|
|
81
|
+
id: NotebookCommands['MoveCellUp'].id,
|
|
82
|
+
command: NotebookCommands['MoveCellUp'].id,
|
|
83
|
+
tooltip: (
|
|
84
|
+
<div className="libro-side-tooltip">
|
|
85
|
+
<span className="libro-tooltip-text">{l10n.t('上移')}</span>
|
|
86
|
+
<span className="libro-tooltip-keybind">Up</span>
|
|
87
|
+
</div>
|
|
88
|
+
),
|
|
89
|
+
|
|
90
|
+
group: ['sidetoolbar1'],
|
|
91
|
+
order: 'e',
|
|
92
|
+
});
|
|
93
|
+
registry.registerItem({
|
|
94
|
+
id: NotebookCommands['MoveCellDown'].id,
|
|
95
|
+
command: NotebookCommands['MoveCellDown'].id,
|
|
96
|
+
tooltip: (
|
|
97
|
+
<div className="libro-side-tooltip">
|
|
98
|
+
<span className="libro-tooltip-text">{l10n.t('下移')}</span>
|
|
99
|
+
<span className="libro-tooltip-keybind">Down</span>
|
|
100
|
+
</div>
|
|
101
|
+
),
|
|
102
|
+
|
|
103
|
+
group: ['sidetoolbar1'],
|
|
104
|
+
order: 'f',
|
|
105
|
+
});
|
|
106
|
+
registry.registerItem({
|
|
107
|
+
id: NotebookCommands['InsertCellBelow'].id,
|
|
108
|
+
command: NotebookCommands['InsertCellBelow'].id,
|
|
109
|
+
tooltip: (
|
|
110
|
+
<div className="libro-side-tooltip">
|
|
111
|
+
<span className="libro-tooltip-text">{l10n.t('增加')}</span>
|
|
112
|
+
<span className="libro-tooltip-keybind">B</span>
|
|
113
|
+
</div>
|
|
114
|
+
),
|
|
115
|
+
|
|
116
|
+
group: ['sidetoolbar2'],
|
|
117
|
+
order: 'g1',
|
|
118
|
+
});
|
|
119
|
+
registry.registerItem({
|
|
120
|
+
id: NotebookCommands['DeleteCell'].id,
|
|
121
|
+
command: NotebookCommands['DeleteCell'].id,
|
|
122
|
+
tooltip: (
|
|
123
|
+
<div className="libro-side-tooltip">
|
|
124
|
+
<span className="libro-tooltip-text">{l10n.t('删除')}</span>
|
|
125
|
+
<span className="libro-tooltip-keybind">D D</span>
|
|
126
|
+
</div>
|
|
127
|
+
),
|
|
128
|
+
|
|
129
|
+
group: ['sidetoolbar2'],
|
|
130
|
+
order: 'g2',
|
|
131
|
+
});
|
|
132
|
+
registry.registerItem({
|
|
133
|
+
id: NotebookCommands['UndoCellAction'].id,
|
|
134
|
+
command: NotebookCommands['UndoCellAction'].id,
|
|
135
|
+
tooltip: (
|
|
136
|
+
<div className="libro-tooltip">
|
|
137
|
+
<span className="libro-tooltip-text">{l10n.t('撤销')}</span>
|
|
138
|
+
<span className="libro-tooltip-keybind">Z</span>
|
|
139
|
+
</div>
|
|
140
|
+
),
|
|
141
|
+
|
|
142
|
+
group: ['group3'],
|
|
143
|
+
order: 'h1',
|
|
144
|
+
});
|
|
145
|
+
registry.registerItem({
|
|
146
|
+
id: NotebookCommands['RedoCellAction'].id,
|
|
147
|
+
command: NotebookCommands['RedoCellAction'].id,
|
|
148
|
+
tooltip: (
|
|
149
|
+
<div className="libro-tooltip">
|
|
150
|
+
<span className="libro-tooltip-text">{l10n.t('重做')}</span>
|
|
151
|
+
<span className="libro-tooltip-keybind">Shift + Z</span>
|
|
152
|
+
</div>
|
|
153
|
+
),
|
|
154
|
+
|
|
155
|
+
group: ['group3'],
|
|
156
|
+
order: 'h2',
|
|
157
|
+
});
|
|
158
|
+
registry.registerItem({
|
|
159
|
+
id: NotebookCommands['HideAllCell'].id,
|
|
160
|
+
command: NotebookCommands['HideAllCell'].id,
|
|
161
|
+
icon: HideAllSelect,
|
|
162
|
+
group: ['group3'],
|
|
163
|
+
order: 'i',
|
|
164
|
+
});
|
|
165
|
+
registry.registerItem({
|
|
166
|
+
id: NotebookCommands['ClearAllCellOutput'].id,
|
|
167
|
+
command: NotebookCommands['ClearAllCellOutput'].id,
|
|
168
|
+
tooltip: (
|
|
169
|
+
<div className="libro-tooltip">
|
|
170
|
+
<span className="libro-tooltip-text">{l10n.t('清空输出')}</span>
|
|
171
|
+
</div>
|
|
172
|
+
),
|
|
173
|
+
|
|
174
|
+
group: ['group3'],
|
|
175
|
+
order: 'j',
|
|
176
|
+
});
|
|
177
|
+
registry.registerItem({
|
|
178
|
+
id: NotebookCommands['ChangeCellTo'].id,
|
|
179
|
+
icon: ToolItemSelect,
|
|
180
|
+
command: NotebookCommands['ChangeCellTo'].id,
|
|
181
|
+
group: ['group4'],
|
|
182
|
+
order: 'k',
|
|
183
|
+
});
|
|
184
|
+
registry.registerItem({
|
|
185
|
+
id: NotebookCommands['More'].id,
|
|
186
|
+
icon: SideToolbarMoreSelect,
|
|
187
|
+
command: NotebookCommands['More'].id,
|
|
188
|
+
group: ['sidetoolbar3'],
|
|
189
|
+
order: 'm',
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ManaModule } from '@difizen/mana-app';
|
|
2
|
+
|
|
3
|
+
import { LibroToolbarContribution } from './libro-toolbar.js';
|
|
4
|
+
import { RestartClearOutputsContribution } from './restart-clear-outputs-contribution.js';
|
|
5
|
+
import { ShutdownContribution } from './shutdown-contribution.js';
|
|
6
|
+
|
|
7
|
+
export const LibroToolbarModule = ManaModule.create().register(
|
|
8
|
+
LibroToolbarContribution,
|
|
9
|
+
RestartClearOutputsContribution,
|
|
10
|
+
ShutdownContribution,
|
|
11
|
+
);
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ModalContribution, singleton } from '@difizen/mana-app';
|
|
2
|
+
|
|
3
|
+
import { RestartClearOutputModal } from './restart-clear-outputs-modal.js';
|
|
4
|
+
|
|
5
|
+
@singleton({ contrib: ModalContribution })
|
|
6
|
+
export class RestartClearOutputsContribution implements ModalContribution {
|
|
7
|
+
registerModal() {
|
|
8
|
+
return RestartClearOutputModal;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { ModalItemProps, ModalItem } from '@difizen/mana-app';
|
|
2
|
+
import { Modal } from 'antd';
|
|
3
|
+
import { useCallback } from 'react';
|
|
4
|
+
|
|
5
|
+
import { NotebookCommands } from '../command/index.js';
|
|
6
|
+
import type { LibroView } from '../libro-view.js';
|
|
7
|
+
|
|
8
|
+
export const RestartClearOutputModalComponent: React.FC<ModalItemProps<LibroView>> = ({
|
|
9
|
+
visible,
|
|
10
|
+
close,
|
|
11
|
+
data,
|
|
12
|
+
}: ModalItemProps<LibroView>) => {
|
|
13
|
+
const handleRestart = useCallback(() => {
|
|
14
|
+
data?.restartClearOutput();
|
|
15
|
+
close();
|
|
16
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
17
|
+
}, [data]);
|
|
18
|
+
|
|
19
|
+
return (
|
|
20
|
+
<Modal
|
|
21
|
+
title="Restart Kernel?"
|
|
22
|
+
open={visible}
|
|
23
|
+
onOk={handleRestart}
|
|
24
|
+
onCancel={() => close()}
|
|
25
|
+
width={'400px'}
|
|
26
|
+
centered={true}
|
|
27
|
+
className="libro-restart-kernel-modal"
|
|
28
|
+
>
|
|
29
|
+
Do you want to restart the current kernel? All variables will be lost.
|
|
30
|
+
</Modal>
|
|
31
|
+
);
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export const RestartClearOutputModal: ModalItem<LibroView> = {
|
|
35
|
+
id: NotebookCommands['RestartClearOutput'].id,
|
|
36
|
+
component: RestartClearOutputModalComponent,
|
|
37
|
+
};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import {
|
|
2
|
+
SaveOutlined,
|
|
3
|
+
CheckOutlined,
|
|
4
|
+
CloseOutlined,
|
|
5
|
+
LoadingOutlined,
|
|
6
|
+
} from '@ant-design/icons';
|
|
7
|
+
import { useInject, ViewInstance } from '@difizen/mana-app';
|
|
8
|
+
import type { Disposable } from '@difizen/mana-app';
|
|
9
|
+
import type { FC } from 'react';
|
|
10
|
+
import { useEffect, useCallback, useState } from 'react';
|
|
11
|
+
|
|
12
|
+
import type { LibroView } from '../libro-view.js';
|
|
13
|
+
|
|
14
|
+
export const SaveIcon: FC = () => {
|
|
15
|
+
const [saved, setSaved] = useState<boolean | undefined>(undefined);
|
|
16
|
+
const libroView = useInject<LibroView>(ViewInstance);
|
|
17
|
+
|
|
18
|
+
const handleSave = useCallback((result: boolean) => {
|
|
19
|
+
setSaved(result);
|
|
20
|
+
setTimeout(() => {
|
|
21
|
+
setSaved(undefined);
|
|
22
|
+
}, 500);
|
|
23
|
+
}, []);
|
|
24
|
+
|
|
25
|
+
useEffect(() => {
|
|
26
|
+
let toDispose: Disposable;
|
|
27
|
+
if (libroView) {
|
|
28
|
+
toDispose = libroView.onSave((result) => {
|
|
29
|
+
handleSave(result);
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
return () => {
|
|
33
|
+
toDispose?.dispose();
|
|
34
|
+
};
|
|
35
|
+
}, [handleSave, libroView]);
|
|
36
|
+
if (saved !== undefined) {
|
|
37
|
+
if (saved) {
|
|
38
|
+
return <CheckOutlined style={{ color: 'green' }} />;
|
|
39
|
+
} else {
|
|
40
|
+
return <CloseOutlined style={{ color: 'red' }} />;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
if (libroView?.saving) {
|
|
44
|
+
return <LoadingOutlined />;
|
|
45
|
+
}
|
|
46
|
+
return <SaveOutlined />;
|
|
47
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ModalContribution, singleton } from '@difizen/mana-app';
|
|
2
|
+
|
|
3
|
+
import { ShutdownModal } from './shutdown-modal.js';
|
|
4
|
+
|
|
5
|
+
@singleton({ contrib: ModalContribution })
|
|
6
|
+
export class ShutdownContribution implements ModalContribution {
|
|
7
|
+
registerModal() {
|
|
8
|
+
return ShutdownModal;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { ModalItemProps, ModalItem } from '@difizen/mana-app';
|
|
2
|
+
import { Modal } from 'antd';
|
|
3
|
+
import { useCallback } from 'react';
|
|
4
|
+
|
|
5
|
+
import { NotebookCommands } from '../command/index.js';
|
|
6
|
+
import type { LibroView } from '../libro-view.js';
|
|
7
|
+
|
|
8
|
+
export const ShutdownModalComponent: React.FC<ModalItemProps<LibroView>> = ({
|
|
9
|
+
visible,
|
|
10
|
+
close,
|
|
11
|
+
data,
|
|
12
|
+
}: ModalItemProps<LibroView>) => {
|
|
13
|
+
const handleShutdown = useCallback(() => {
|
|
14
|
+
data?.closeAndShutdown();
|
|
15
|
+
close();
|
|
16
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
17
|
+
}, [data]);
|
|
18
|
+
|
|
19
|
+
return (
|
|
20
|
+
<Modal
|
|
21
|
+
title="Shutdown Kernel?"
|
|
22
|
+
open={visible}
|
|
23
|
+
onOk={handleShutdown}
|
|
24
|
+
onCancel={() => close()}
|
|
25
|
+
width={'400px'}
|
|
26
|
+
centered={true}
|
|
27
|
+
className="libro-shut-down-kernel-modal"
|
|
28
|
+
>
|
|
29
|
+
Do you want to shutdown the current kernel?.
|
|
30
|
+
</Modal>
|
|
31
|
+
);
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export const ShutdownModal: ModalItem<LibroView> = {
|
|
35
|
+
id: NotebookCommands['CloseAndShutdown'].id,
|
|
36
|
+
component: ShutdownModalComponent,
|
|
37
|
+
};
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import type { Toolbar } from '@difizen/mana-app';
|
|
2
|
+
import {
|
|
3
|
+
CommandRegistry,
|
|
4
|
+
getOrigin,
|
|
5
|
+
ToolbarInstance,
|
|
6
|
+
useInject,
|
|
7
|
+
} from '@difizen/mana-app';
|
|
8
|
+
import { l10n } from '@difizen/mana-l10n';
|
|
9
|
+
import { Menu, MenuContext } from '@difizen/mana-react';
|
|
10
|
+
import { Popover } from 'antd';
|
|
11
|
+
|
|
12
|
+
import { ExecutableCellModel, ExecutableCellView } from '../cell/index.js';
|
|
13
|
+
import { NotebookCommands } from '../command/index.js';
|
|
14
|
+
import type { LibroSideToolbarMenuItemType } from '../components/libro-side-toolbar-menu.js';
|
|
15
|
+
import { MoreOutlined } from '../material-from-designer.js';
|
|
16
|
+
|
|
17
|
+
import type { LibroToolbarArags } from './libro-toolbar-protocol.js';
|
|
18
|
+
|
|
19
|
+
const codeItems: LibroSideToolbarMenuItemType[] = [
|
|
20
|
+
{
|
|
21
|
+
id: NotebookCommands['HideCellCode'].id,
|
|
22
|
+
label: (
|
|
23
|
+
<>
|
|
24
|
+
<span className="libro-menu-item-label">{l10n.t('隐藏 Code')}</span>
|
|
25
|
+
<span className="libro-menu-item-keybind">Cmd + '</span>
|
|
26
|
+
</>
|
|
27
|
+
),
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
id: NotebookCommands['ShowCellCode'].id,
|
|
31
|
+
label: (
|
|
32
|
+
<>
|
|
33
|
+
<span className="libro-menu-item-label">{l10n.t('显示 Code')}</span>
|
|
34
|
+
<span className="libro-menu-item-keybind">Cmd + '</span>
|
|
35
|
+
</>
|
|
36
|
+
),
|
|
37
|
+
},
|
|
38
|
+
];
|
|
39
|
+
|
|
40
|
+
const outputItems: LibroSideToolbarMenuItemType[] = [
|
|
41
|
+
{
|
|
42
|
+
id: NotebookCommands['HideCellOutputs'].id,
|
|
43
|
+
label: (
|
|
44
|
+
<>
|
|
45
|
+
<span className="libro-menu-item-label">{l10n.t('隐藏 Output')}</span>
|
|
46
|
+
<span className="libro-menu-item-keybind">Cmd + O</span>
|
|
47
|
+
</>
|
|
48
|
+
),
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
id: NotebookCommands['ShowCellOutputs'].id,
|
|
52
|
+
label: (
|
|
53
|
+
<>
|
|
54
|
+
<span className="libro-menu-item-label">{l10n.t('显示 Output')}</span>
|
|
55
|
+
<span className="libro-menu-item-keybind">Cmd + O</span>
|
|
56
|
+
</>
|
|
57
|
+
),
|
|
58
|
+
},
|
|
59
|
+
];
|
|
60
|
+
|
|
61
|
+
const moreItems: LibroSideToolbarMenuItemType[] = [
|
|
62
|
+
{
|
|
63
|
+
id: NotebookCommands['CopyCell'].id,
|
|
64
|
+
label: (
|
|
65
|
+
<>
|
|
66
|
+
<span className="libro-menu-item-label">{l10n.t('复制')}</span>
|
|
67
|
+
<span className="libro-menu-item-keybind">C</span>
|
|
68
|
+
</>
|
|
69
|
+
),
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
id: NotebookCommands['CutCell'].id,
|
|
73
|
+
label: (
|
|
74
|
+
<>
|
|
75
|
+
<span className="libro-menu-item-label">{l10n.t('剪切')}</span>
|
|
76
|
+
<span className="libro-menu-item-keybind">X</span>
|
|
77
|
+
</>
|
|
78
|
+
),
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
id: NotebookCommands['PasteCellBelow'].id,
|
|
82
|
+
label: (
|
|
83
|
+
<>
|
|
84
|
+
<span className="libro-menu-item-label">{l10n.t('粘贴')}</span>
|
|
85
|
+
<span className="libro-menu-item-keybind">V</span>
|
|
86
|
+
</>
|
|
87
|
+
),
|
|
88
|
+
},
|
|
89
|
+
];
|
|
90
|
+
|
|
91
|
+
export const LibroSideToolbarMoreMenu: React.FC = () => {
|
|
92
|
+
const command = useInject(CommandRegistry);
|
|
93
|
+
const toolbar = useInject<Toolbar>(ToolbarInstance);
|
|
94
|
+
const data = toolbar.currentArgs as LibroToolbarArags;
|
|
95
|
+
const args = getOrigin(data) || [];
|
|
96
|
+
const cell = args[0];
|
|
97
|
+
if (!cell) {
|
|
98
|
+
return null;
|
|
99
|
+
}
|
|
100
|
+
const hasOutput =
|
|
101
|
+
ExecutableCellView.is(cell) && cell.outputArea?.length && cell.outputArea.length > 0
|
|
102
|
+
? true
|
|
103
|
+
: false;
|
|
104
|
+
const nodes: React.ReactNode[] = [];
|
|
105
|
+
const baseCls = 'mana-menu';
|
|
106
|
+
const contextValue: MenuContext.Context = {
|
|
107
|
+
prefixCls: baseCls,
|
|
108
|
+
};
|
|
109
|
+
const codeMenuItem = cell.hasInputHidden ? 1 : 0;
|
|
110
|
+
nodes.push(
|
|
111
|
+
<Menu.Item
|
|
112
|
+
key={codeItems[codeMenuItem].id}
|
|
113
|
+
onClick={() => {
|
|
114
|
+
command.executeCommand(codeItems[codeMenuItem].id, ...args);
|
|
115
|
+
cell.hasInputHidden = !cell.hasInputHidden;
|
|
116
|
+
}}
|
|
117
|
+
>
|
|
118
|
+
{codeItems[codeMenuItem].label}
|
|
119
|
+
</Menu.Item>,
|
|
120
|
+
);
|
|
121
|
+
const outputMenuItem =
|
|
122
|
+
ExecutableCellModel.is(cell.model) && cell.model.hasOutputHidden ? 1 : 0;
|
|
123
|
+
nodes.push(
|
|
124
|
+
<Menu.Item
|
|
125
|
+
key={outputItems[outputMenuItem].id}
|
|
126
|
+
onClick={() => {
|
|
127
|
+
if (hasOutput) {
|
|
128
|
+
command.executeCommand(outputItems[outputMenuItem].id, ...args);
|
|
129
|
+
if (ExecutableCellModel.is(cell.model)) {
|
|
130
|
+
cell.model.hasOutputHidden = !cell.model.hasOutputHidden;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}}
|
|
134
|
+
disabled={!hasOutput}
|
|
135
|
+
>
|
|
136
|
+
{outputItems[outputMenuItem].label}
|
|
137
|
+
</Menu.Item>,
|
|
138
|
+
);
|
|
139
|
+
nodes.push(<Menu.Divider key="libro-menu-divider" />);
|
|
140
|
+
moreItems.forEach((item) => {
|
|
141
|
+
nodes.push(
|
|
142
|
+
<Menu.Item
|
|
143
|
+
key={item.id}
|
|
144
|
+
onClick={() => {
|
|
145
|
+
command.executeCommand(item.id, ...args);
|
|
146
|
+
}}
|
|
147
|
+
>
|
|
148
|
+
{item.label}
|
|
149
|
+
</Menu.Item>,
|
|
150
|
+
);
|
|
151
|
+
});
|
|
152
|
+
return (
|
|
153
|
+
<div className="libro-side-toolbar-menu">
|
|
154
|
+
<MenuContext.Provider value={contextValue}>{nodes} </MenuContext.Provider>
|
|
155
|
+
</div>
|
|
156
|
+
);
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
export const SideToolbarMoreSelect: React.FC = () => {
|
|
160
|
+
return (
|
|
161
|
+
<Popover
|
|
162
|
+
placement="leftTop"
|
|
163
|
+
content={<LibroSideToolbarMoreMenu />}
|
|
164
|
+
trigger="click"
|
|
165
|
+
overlayClassName="libro-popover-side-toolbar-menu libro-side-toolbar-more-select-menu"
|
|
166
|
+
>
|
|
167
|
+
<span>
|
|
168
|
+
<MoreOutlined />
|
|
169
|
+
</span>
|
|
170
|
+
</Popover>
|
|
171
|
+
);
|
|
172
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
declare module '*.less';
|