@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,161 @@
|
|
|
1
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
2
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
3
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
4
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
5
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
6
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
7
|
+
import { CommandRegistry, getOrigin, ToolbarInstance, useInject } 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
|
+
import { ExecutableCellModel, ExecutableCellView } from "../cell/index.js";
|
|
12
|
+
import { NotebookCommands } from "../command/index.js";
|
|
13
|
+
import { MoreOutlined } from "../material-from-designer.js";
|
|
14
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
15
|
+
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
16
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
17
|
+
var codeItems = [{
|
|
18
|
+
id: NotebookCommands['HideCellCode'].id,
|
|
19
|
+
label: /*#__PURE__*/_jsxs(_Fragment, {
|
|
20
|
+
children: [/*#__PURE__*/_jsx("span", {
|
|
21
|
+
className: "libro-menu-item-label",
|
|
22
|
+
children: l10n.t('隐藏 Code')
|
|
23
|
+
}), /*#__PURE__*/_jsx("span", {
|
|
24
|
+
className: "libro-menu-item-keybind",
|
|
25
|
+
children: "Cmd + '"
|
|
26
|
+
})]
|
|
27
|
+
})
|
|
28
|
+
}, {
|
|
29
|
+
id: NotebookCommands['ShowCellCode'].id,
|
|
30
|
+
label: /*#__PURE__*/_jsxs(_Fragment, {
|
|
31
|
+
children: [/*#__PURE__*/_jsx("span", {
|
|
32
|
+
className: "libro-menu-item-label",
|
|
33
|
+
children: l10n.t('显示 Code')
|
|
34
|
+
}), /*#__PURE__*/_jsx("span", {
|
|
35
|
+
className: "libro-menu-item-keybind",
|
|
36
|
+
children: "Cmd + '"
|
|
37
|
+
})]
|
|
38
|
+
})
|
|
39
|
+
}];
|
|
40
|
+
var outputItems = [{
|
|
41
|
+
id: NotebookCommands['HideCellOutputs'].id,
|
|
42
|
+
label: /*#__PURE__*/_jsxs(_Fragment, {
|
|
43
|
+
children: [/*#__PURE__*/_jsx("span", {
|
|
44
|
+
className: "libro-menu-item-label",
|
|
45
|
+
children: l10n.t('隐藏 Output')
|
|
46
|
+
}), /*#__PURE__*/_jsx("span", {
|
|
47
|
+
className: "libro-menu-item-keybind",
|
|
48
|
+
children: "Cmd + O"
|
|
49
|
+
})]
|
|
50
|
+
})
|
|
51
|
+
}, {
|
|
52
|
+
id: NotebookCommands['ShowCellOutputs'].id,
|
|
53
|
+
label: /*#__PURE__*/_jsxs(_Fragment, {
|
|
54
|
+
children: [/*#__PURE__*/_jsx("span", {
|
|
55
|
+
className: "libro-menu-item-label",
|
|
56
|
+
children: l10n.t('显示 Output')
|
|
57
|
+
}), /*#__PURE__*/_jsx("span", {
|
|
58
|
+
className: "libro-menu-item-keybind",
|
|
59
|
+
children: "Cmd + O"
|
|
60
|
+
})]
|
|
61
|
+
})
|
|
62
|
+
}];
|
|
63
|
+
var moreItems = [{
|
|
64
|
+
id: NotebookCommands['CopyCell'].id,
|
|
65
|
+
label: /*#__PURE__*/_jsxs(_Fragment, {
|
|
66
|
+
children: [/*#__PURE__*/_jsx("span", {
|
|
67
|
+
className: "libro-menu-item-label",
|
|
68
|
+
children: l10n.t('复制')
|
|
69
|
+
}), /*#__PURE__*/_jsx("span", {
|
|
70
|
+
className: "libro-menu-item-keybind",
|
|
71
|
+
children: "C"
|
|
72
|
+
})]
|
|
73
|
+
})
|
|
74
|
+
}, {
|
|
75
|
+
id: NotebookCommands['CutCell'].id,
|
|
76
|
+
label: /*#__PURE__*/_jsxs(_Fragment, {
|
|
77
|
+
children: [/*#__PURE__*/_jsx("span", {
|
|
78
|
+
className: "libro-menu-item-label",
|
|
79
|
+
children: l10n.t('剪切')
|
|
80
|
+
}), /*#__PURE__*/_jsx("span", {
|
|
81
|
+
className: "libro-menu-item-keybind",
|
|
82
|
+
children: "X"
|
|
83
|
+
})]
|
|
84
|
+
})
|
|
85
|
+
}, {
|
|
86
|
+
id: NotebookCommands['PasteCellBelow'].id,
|
|
87
|
+
label: /*#__PURE__*/_jsxs(_Fragment, {
|
|
88
|
+
children: [/*#__PURE__*/_jsx("span", {
|
|
89
|
+
className: "libro-menu-item-label",
|
|
90
|
+
children: l10n.t('粘贴')
|
|
91
|
+
}), /*#__PURE__*/_jsx("span", {
|
|
92
|
+
className: "libro-menu-item-keybind",
|
|
93
|
+
children: "V"
|
|
94
|
+
})]
|
|
95
|
+
})
|
|
96
|
+
}];
|
|
97
|
+
export var LibroSideToolbarMoreMenu = function LibroSideToolbarMoreMenu() {
|
|
98
|
+
var _cell$outputArea;
|
|
99
|
+
var command = useInject(CommandRegistry);
|
|
100
|
+
var toolbar = useInject(ToolbarInstance);
|
|
101
|
+
var data = toolbar.currentArgs;
|
|
102
|
+
var args = getOrigin(data) || [];
|
|
103
|
+
var cell = args[0];
|
|
104
|
+
if (!cell) {
|
|
105
|
+
return null;
|
|
106
|
+
}
|
|
107
|
+
var hasOutput = ExecutableCellView.is(cell) && (_cell$outputArea = cell.outputArea) !== null && _cell$outputArea !== void 0 && _cell$outputArea.length && cell.outputArea.length > 0 ? true : false;
|
|
108
|
+
var nodes = [];
|
|
109
|
+
var baseCls = 'mana-menu';
|
|
110
|
+
var contextValue = {
|
|
111
|
+
prefixCls: baseCls
|
|
112
|
+
};
|
|
113
|
+
var codeMenuItem = cell.hasInputHidden ? 1 : 0;
|
|
114
|
+
nodes.push( /*#__PURE__*/_jsx(Menu.Item, {
|
|
115
|
+
onClick: function onClick() {
|
|
116
|
+
command.executeCommand.apply(command, [codeItems[codeMenuItem].id].concat(_toConsumableArray(args)));
|
|
117
|
+
cell.hasInputHidden = !cell.hasInputHidden;
|
|
118
|
+
},
|
|
119
|
+
children: codeItems[codeMenuItem].label
|
|
120
|
+
}, codeItems[codeMenuItem].id));
|
|
121
|
+
var outputMenuItem = ExecutableCellModel.is(cell.model) && cell.model.hasOutputHidden ? 1 : 0;
|
|
122
|
+
nodes.push( /*#__PURE__*/_jsx(Menu.Item, {
|
|
123
|
+
onClick: function onClick() {
|
|
124
|
+
if (hasOutput) {
|
|
125
|
+
command.executeCommand.apply(command, [outputItems[outputMenuItem].id].concat(_toConsumableArray(args)));
|
|
126
|
+
if (ExecutableCellModel.is(cell.model)) {
|
|
127
|
+
cell.model.hasOutputHidden = !cell.model.hasOutputHidden;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
},
|
|
131
|
+
disabled: !hasOutput,
|
|
132
|
+
children: outputItems[outputMenuItem].label
|
|
133
|
+
}, outputItems[outputMenuItem].id));
|
|
134
|
+
nodes.push( /*#__PURE__*/_jsx(Menu.Divider, {}, "libro-menu-divider"));
|
|
135
|
+
moreItems.forEach(function (item) {
|
|
136
|
+
nodes.push( /*#__PURE__*/_jsx(Menu.Item, {
|
|
137
|
+
onClick: function onClick() {
|
|
138
|
+
command.executeCommand.apply(command, [item.id].concat(_toConsumableArray(args)));
|
|
139
|
+
},
|
|
140
|
+
children: item.label
|
|
141
|
+
}, item.id));
|
|
142
|
+
});
|
|
143
|
+
return /*#__PURE__*/_jsx("div", {
|
|
144
|
+
className: "libro-side-toolbar-menu",
|
|
145
|
+
children: /*#__PURE__*/_jsxs(MenuContext.Provider, {
|
|
146
|
+
value: contextValue,
|
|
147
|
+
children: [nodes, " "]
|
|
148
|
+
})
|
|
149
|
+
});
|
|
150
|
+
};
|
|
151
|
+
export var SideToolbarMoreSelect = function SideToolbarMoreSelect() {
|
|
152
|
+
return /*#__PURE__*/_jsx(Popover, {
|
|
153
|
+
placement: "leftTop",
|
|
154
|
+
content: /*#__PURE__*/_jsx(LibroSideToolbarMoreMenu, {}),
|
|
155
|
+
trigger: "click",
|
|
156
|
+
overlayClassName: "libro-popover-side-toolbar-menu libro-side-toolbar-more-select-menu",
|
|
157
|
+
children: /*#__PURE__*/_jsx("span", {
|
|
158
|
+
children: /*#__PURE__*/_jsx(MoreOutlined, {})
|
|
159
|
+
})
|
|
160
|
+
});
|
|
161
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
declare module '*.less';
|
package/package.json
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@difizen/libro-core",
|
|
3
|
+
"version": "0.0.2-alpha.0",
|
|
4
|
+
"description": "",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"libro",
|
|
7
|
+
"core",
|
|
8
|
+
"notebook"
|
|
9
|
+
],
|
|
10
|
+
"type": "module",
|
|
11
|
+
"repository": "git@github.com:difizen/libro.git",
|
|
12
|
+
"license": "MIT",
|
|
13
|
+
"exports": {
|
|
14
|
+
".": {
|
|
15
|
+
"typings": "./es/index.d.ts",
|
|
16
|
+
"default": "./es/index.js"
|
|
17
|
+
},
|
|
18
|
+
"./mock": {
|
|
19
|
+
"typings": "./es/mock/index.d.ts",
|
|
20
|
+
"default": "./es/mock/index.js"
|
|
21
|
+
},
|
|
22
|
+
"./es/mock": {
|
|
23
|
+
"typings": "./es/mock/index.d.ts",
|
|
24
|
+
"default": "./es/mock/index.js"
|
|
25
|
+
},
|
|
26
|
+
"./package.json": "./package.json"
|
|
27
|
+
},
|
|
28
|
+
"main": "es/index.js",
|
|
29
|
+
"module": "es/index.js",
|
|
30
|
+
"typings": "es/index.d.ts",
|
|
31
|
+
"files": [
|
|
32
|
+
"es",
|
|
33
|
+
"src"
|
|
34
|
+
],
|
|
35
|
+
"dependencies": {
|
|
36
|
+
"@difizen/mana-app": "alpha",
|
|
37
|
+
"@difizen/mana-react": "alpha",
|
|
38
|
+
"@difizen/mana-l10n": "alpha",
|
|
39
|
+
"@ant-design/icons": "^5.1.0",
|
|
40
|
+
"@difizen/libro-code-editor": "^0.0.2-alpha.0",
|
|
41
|
+
"@difizen/libro-common": "^0.0.2-alpha.0",
|
|
42
|
+
"@difizen/libro-shared-model": "^0.0.2-alpha.0",
|
|
43
|
+
"classnames": "^2.3.2",
|
|
44
|
+
"dnd-core": "^16.0.1",
|
|
45
|
+
"react-dnd": "^16.0.1",
|
|
46
|
+
"react-dnd-html5-backend": "^16.0.1",
|
|
47
|
+
"uuid": "^8.3.2"
|
|
48
|
+
},
|
|
49
|
+
"devDependencies": {
|
|
50
|
+
"@types/react": "^18.2.25",
|
|
51
|
+
"@types/uuid": "^8.3.4"
|
|
52
|
+
},
|
|
53
|
+
"peerDependencies": {
|
|
54
|
+
"antd": "^5.8.6",
|
|
55
|
+
"react": "^18.2.0"
|
|
56
|
+
},
|
|
57
|
+
"scripts": {
|
|
58
|
+
"setup": "father build",
|
|
59
|
+
"build": "father build",
|
|
60
|
+
"test": ": Note: lint task is delegated to test:* scripts",
|
|
61
|
+
"test:vitest": "vitest run",
|
|
62
|
+
"test:jest": "jest",
|
|
63
|
+
"coverage": ": Note: lint task is delegated to coverage:* scripts",
|
|
64
|
+
"coverage:vitest": "vitest run --coverage",
|
|
65
|
+
"coverage:jest": "jest --coverage",
|
|
66
|
+
"lint": ": Note: lint task is delegated to lint:* scripts",
|
|
67
|
+
"lint:eslint": "eslint src",
|
|
68
|
+
"lint:tsc": "tsc --noEmit"
|
|
69
|
+
}
|
|
70
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
.default-add-cell-container {
|
|
2
|
+
display: flex;
|
|
3
|
+
align-items: center;
|
|
4
|
+
justify-content: start;
|
|
5
|
+
height: 90px;
|
|
6
|
+
padding-bottom: 30px;
|
|
7
|
+
margin: 0 72px;
|
|
8
|
+
|
|
9
|
+
.libro-add-cell-container-item {
|
|
10
|
+
margin-right: 16px;
|
|
11
|
+
padding-left: 12px;
|
|
12
|
+
border-radius: 6px;
|
|
13
|
+
/* stylelint-disable-next-line declaration-property-value-disallowed-list */
|
|
14
|
+
font-family: PingFangSC;
|
|
15
|
+
font-weight: 400;
|
|
16
|
+
font-size: 14px;
|
|
17
|
+
background: var(--mana-libro-bottom-btn-background-color) !important;
|
|
18
|
+
border-color: var(--mana-libro-bottom-btn-border-color) !important;
|
|
19
|
+
line-height: 22px;
|
|
20
|
+
|
|
21
|
+
.libro-add-cell-icon {
|
|
22
|
+
padding-right: 8px;
|
|
23
|
+
color: var(--mana-libro-bottom-btn-icon-color) !important;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
span:not(.libro-add-cell-icon) {
|
|
27
|
+
color: var(--mana-libro-bottom-btn-text-color);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
path {
|
|
31
|
+
// position: absolute;
|
|
32
|
+
// top: 11px;
|
|
33
|
+
// left: 12px;
|
|
34
|
+
height: 9.8px;
|
|
35
|
+
width: 9.4px;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ManaModule } from '@difizen/mana-app';
|
|
2
|
+
|
|
3
|
+
import { LibroAddCellSlotContribution } from './libro-add-cell-slot-contribution.js';
|
|
4
|
+
import { LibroAddCellView } from './libro-add-cell-view.js';
|
|
5
|
+
|
|
6
|
+
export const LibroAddCellModule = ManaModule.create().register(
|
|
7
|
+
LibroAddCellSlotContribution,
|
|
8
|
+
LibroAddCellView,
|
|
9
|
+
);
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { ViewManager } from '@difizen/mana-app';
|
|
2
|
+
import { inject, singleton } from '@difizen/mana-app';
|
|
3
|
+
|
|
4
|
+
import type { LibroView } from '../libro-view.js';
|
|
5
|
+
import { LibroExtensionSlotContribution } from '../slot/index.js';
|
|
6
|
+
import type { LibroExtensionSlotFactory, LibroSlot } from '../slot/index.js';
|
|
7
|
+
|
|
8
|
+
import { LibroAddCellView } from './libro-add-cell-view.js';
|
|
9
|
+
|
|
10
|
+
@singleton({ contrib: LibroExtensionSlotContribution })
|
|
11
|
+
export class LibroAddCellSlotContribution implements LibroExtensionSlotContribution {
|
|
12
|
+
protected viewManager: ViewManager;
|
|
13
|
+
constructor(@inject(ViewManager) viewManager: ViewManager) {
|
|
14
|
+
this.viewManager = viewManager;
|
|
15
|
+
}
|
|
16
|
+
protected viewMap: Map<string, LibroAddCellView> = new Map();
|
|
17
|
+
|
|
18
|
+
public readonly slot: LibroSlot = 'list';
|
|
19
|
+
|
|
20
|
+
factory: LibroExtensionSlotFactory = async (libro: LibroView) => {
|
|
21
|
+
const view = await this.viewManager.getOrCreateView(LibroAddCellView, {
|
|
22
|
+
parentId: libro.id,
|
|
23
|
+
});
|
|
24
|
+
view.parent = libro;
|
|
25
|
+
this.viewMap.set(libro.id, view);
|
|
26
|
+
view.onDisposed(() => {
|
|
27
|
+
this.viewMap.delete(libro.id);
|
|
28
|
+
});
|
|
29
|
+
return view;
|
|
30
|
+
};
|
|
31
|
+
}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { DisplayWrapComponent } from '@difizen/libro-common';
|
|
2
|
+
import { prop, useInject } from '@difizen/mana-app';
|
|
3
|
+
import { BaseView, CommandRegistry, view, ViewInstance } from '@difizen/mana-app';
|
|
4
|
+
import { inject, transient } from '@difizen/mana-app';
|
|
5
|
+
import { Button } from 'antd';
|
|
6
|
+
import React from 'react';
|
|
7
|
+
import './index.less';
|
|
8
|
+
|
|
9
|
+
import { CellService } from '../cell/index.js';
|
|
10
|
+
import type { CellMeta } from '../cell/index.js';
|
|
11
|
+
import { NotebookCommands } from '../command/index.js';
|
|
12
|
+
import type { LibroView } from '../libro-view.js';
|
|
13
|
+
import { PlusOutlined } from '../material-from-designer.js';
|
|
14
|
+
|
|
15
|
+
type AddType = {
|
|
16
|
+
name: string;
|
|
17
|
+
type: string;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export const LibroAddCell: React.FC = () => {
|
|
21
|
+
const instance = useInject<LibroAddCellView>(ViewInstance);
|
|
22
|
+
const command = useInject(CommandRegistry);
|
|
23
|
+
const addCell = async (type: string) => {
|
|
24
|
+
command.executeCommand(
|
|
25
|
+
NotebookCommands['InsertCellBottom'].id,
|
|
26
|
+
instance.parent,
|
|
27
|
+
type,
|
|
28
|
+
);
|
|
29
|
+
};
|
|
30
|
+
return (
|
|
31
|
+
<div className="libro-add-cell-container default-add-cell-container">
|
|
32
|
+
{instance
|
|
33
|
+
.getCellList()
|
|
34
|
+
.sort((a, b) => {
|
|
35
|
+
if (a.order < b.order) {
|
|
36
|
+
return -1;
|
|
37
|
+
} else {
|
|
38
|
+
return 1;
|
|
39
|
+
}
|
|
40
|
+
})
|
|
41
|
+
.map((item: AddType) => {
|
|
42
|
+
return (
|
|
43
|
+
<Button
|
|
44
|
+
className="libro-add-cell-container-item "
|
|
45
|
+
key={item.name}
|
|
46
|
+
onClick={() => {
|
|
47
|
+
addCell(item.type);
|
|
48
|
+
}}
|
|
49
|
+
icon={<PlusOutlined className="libro-add-cell-icon" />}
|
|
50
|
+
>
|
|
51
|
+
{item.name}
|
|
52
|
+
</Button>
|
|
53
|
+
);
|
|
54
|
+
})}
|
|
55
|
+
</div>
|
|
56
|
+
);
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
export const LibroWrappedAddCell = React.forwardRef(function LibroWrappedAddCell() {
|
|
60
|
+
const instance = useInject<LibroAddCellView>(ViewInstance);
|
|
61
|
+
return (
|
|
62
|
+
<DisplayWrapComponent mode={instance.parent?.model.readOnly}>
|
|
63
|
+
<LibroAddCell />
|
|
64
|
+
</DisplayWrapComponent>
|
|
65
|
+
);
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
@transient()
|
|
69
|
+
@view('libro-add-cell-view')
|
|
70
|
+
export class LibroAddCellView extends BaseView {
|
|
71
|
+
parent: LibroView | undefined = undefined;
|
|
72
|
+
override view = LibroWrappedAddCell;
|
|
73
|
+
|
|
74
|
+
@prop()
|
|
75
|
+
addList: CellMeta[] = [];
|
|
76
|
+
|
|
77
|
+
cellService: CellService;
|
|
78
|
+
|
|
79
|
+
constructor(@inject(CellService) cellService: CellService) {
|
|
80
|
+
super();
|
|
81
|
+
this.cellService = cellService;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
override onViewMount() {
|
|
85
|
+
this.addList = this.cellService.cellsMeta;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
override onViewUnmount() {
|
|
89
|
+
//
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
override onViewResize() {
|
|
93
|
+
//
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
defaultFilter = (cellmeta: CellMeta) => cellmeta.type !== 'raw';
|
|
97
|
+
|
|
98
|
+
getCellList(filter = this.defaultFilter) {
|
|
99
|
+
return this.addList.filter(filter);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# Cell abstraction
|
|
2
|
+
|
|
3
|
+
## Cell View
|
|
4
|
+
|
|
5
|
+
缩进代表继承关系
|
|
6
|
+
|
|
7
|
+
- LibroCellView
|
|
8
|
+
- LibroEditorCellView: 带有文本编辑器相关能力
|
|
9
|
+
- LibroExecutableCellView: 带有执行、输出能力
|
|
10
|
+
- LibroCodeCellView
|
|
11
|
+
- AIStudioLibroCodeCellView
|
|
12
|
+
- LibroSqlCellView
|
|
13
|
+
- LibroMarkdownCellView
|
|
14
|
+
- LibroRawCellView
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export * from './libro-cell-protocol.js';
|
|
2
|
+
export * from './libro-cell-service.js';
|
|
3
|
+
export * from './libro-cell-view.js';
|
|
4
|
+
export * from './libro-cell-contribution.js';
|
|
5
|
+
export * from './libro-cell-model.js';
|
|
6
|
+
export * from './libro-edit-cell-view.js';
|
|
7
|
+
export * from './libro-executable-cell-model.js';
|
|
8
|
+
export * from './libro-markdown-cell-model.js';
|
|
9
|
+
export * from './libro-executable-cell-view.js';
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { inject, singleton } from '@difizen/mana-app';
|
|
2
|
+
|
|
3
|
+
import type { CellModel, CellOptions } from '../libro-protocol.js';
|
|
4
|
+
|
|
5
|
+
import type { CellMeta } from './libro-cell-protocol.js';
|
|
6
|
+
import {
|
|
7
|
+
CellModelContribution,
|
|
8
|
+
CellModelFactory,
|
|
9
|
+
CellViewContribution,
|
|
10
|
+
} from './libro-cell-protocol.js';
|
|
11
|
+
import { LibroCellView } from './libro-cell-view.js';
|
|
12
|
+
|
|
13
|
+
@singleton({ contrib: [CellModelContribution, CellViewContribution] })
|
|
14
|
+
export class LibroCellContribution
|
|
15
|
+
implements CellModelContribution, CellViewContribution
|
|
16
|
+
{
|
|
17
|
+
libroCellModelFactory: CellModelFactory;
|
|
18
|
+
|
|
19
|
+
constructor(@inject(CellModelFactory) libroCellModelFactory: CellModelFactory) {
|
|
20
|
+
this.libroCellModelFactory = libroCellModelFactory;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
cellMeta: CellMeta = {
|
|
24
|
+
type: 'raw',
|
|
25
|
+
name: 'Raw',
|
|
26
|
+
order: 'a',
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
30
|
+
canHandle(_options: CellOptions): number {
|
|
31
|
+
return 1;
|
|
32
|
+
}
|
|
33
|
+
createModel(options: CellOptions): CellModel {
|
|
34
|
+
const model = this.libroCellModelFactory(options);
|
|
35
|
+
return model;
|
|
36
|
+
}
|
|
37
|
+
view = LibroCellView;
|
|
38
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { Model } from '@difizen/libro-code-editor';
|
|
2
|
+
import type { ICell } from '@difizen/libro-common';
|
|
3
|
+
import { concatMultilineString } from '@difizen/libro-common';
|
|
4
|
+
import { DisposableCollection } from '@difizen/mana-app';
|
|
5
|
+
import { inject, transient } from '@difizen/mana-app';
|
|
6
|
+
import { prop } from '@difizen/mana-app';
|
|
7
|
+
|
|
8
|
+
import { CellOptions } from '../libro-protocol.js';
|
|
9
|
+
import type { CellModel } from '../libro-protocol.js';
|
|
10
|
+
|
|
11
|
+
import type { LibroCellMetadata } from './libro-cell-protocol.js';
|
|
12
|
+
import { getLibroCellType } from './libro-cell-protocol.js';
|
|
13
|
+
|
|
14
|
+
@transient()
|
|
15
|
+
export class LibroCellModel extends Model implements CellModel {
|
|
16
|
+
toDispose = new DisposableCollection();
|
|
17
|
+
|
|
18
|
+
options: CellOptions;
|
|
19
|
+
|
|
20
|
+
@prop()
|
|
21
|
+
metadata: Partial<LibroCellMetadata>;
|
|
22
|
+
|
|
23
|
+
@prop()
|
|
24
|
+
trusted: boolean;
|
|
25
|
+
|
|
26
|
+
constructor(@inject(CellOptions) options: CellOptions) {
|
|
27
|
+
super({
|
|
28
|
+
id: options.cell.id as string,
|
|
29
|
+
value: concatMultilineString(options?.cell?.source ?? ''),
|
|
30
|
+
});
|
|
31
|
+
this.options = options;
|
|
32
|
+
this.type = getLibroCellType(options);
|
|
33
|
+
this.metadata = options?.cell?.metadata || {};
|
|
34
|
+
this.trusted = options?.cell?.metadata?.trusted ?? false;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
async run() {
|
|
38
|
+
return true;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
toJSON(): Omit<ICell, 'outputs'> {
|
|
42
|
+
return {
|
|
43
|
+
id: this.id,
|
|
44
|
+
cell_type: this.type,
|
|
45
|
+
metadata: this.metadata,
|
|
46
|
+
source: this.value,
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
disposed = false;
|
|
51
|
+
override dispose() {
|
|
52
|
+
if (!this.disposed) {
|
|
53
|
+
this.toDispose.dispose();
|
|
54
|
+
}
|
|
55
|
+
this.disposed = true;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export function isLibroCellModel(model: CellModel): model is LibroCellModel {
|
|
60
|
+
return model instanceof LibroCellModel;
|
|
61
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { ManaModule } from '@difizen/mana-app';
|
|
2
|
+
|
|
3
|
+
import { CellOptions } from '../libro-protocol.js';
|
|
4
|
+
|
|
5
|
+
import { LibroCellContribution } from './libro-cell-contribution.js';
|
|
6
|
+
import { LibroCellModel } from './libro-cell-model.js';
|
|
7
|
+
import {
|
|
8
|
+
CellModelContribution,
|
|
9
|
+
CellModelFactory,
|
|
10
|
+
CellViewContribution,
|
|
11
|
+
} from './libro-cell-protocol.js';
|
|
12
|
+
import { LibroCellService } from './libro-cell-service.js';
|
|
13
|
+
import { LibroCellView } from './libro-cell-view.js';
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* 基础的cell实现,作为实现更复杂的cell的参考,一般不用加载到实际应用中
|
|
17
|
+
*/
|
|
18
|
+
export const LibroBaseCellModule = ManaModule.create()
|
|
19
|
+
.register(LibroCellContribution, LibroCellView, LibroCellModel)
|
|
20
|
+
.register({
|
|
21
|
+
token: CellModelFactory,
|
|
22
|
+
useFactory: (ctx) => {
|
|
23
|
+
return (options: CellOptions) => {
|
|
24
|
+
const child = ctx.container.createChild();
|
|
25
|
+
child.register({
|
|
26
|
+
token: CellOptions,
|
|
27
|
+
useValue: options,
|
|
28
|
+
});
|
|
29
|
+
const model = child.get(LibroCellModel);
|
|
30
|
+
return model;
|
|
31
|
+
};
|
|
32
|
+
},
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* cell 定义
|
|
37
|
+
*/
|
|
38
|
+
export const LibroCellModule = ManaModule.create()
|
|
39
|
+
.contribution(CellViewContribution, CellModelContribution)
|
|
40
|
+
.register(LibroCellService);
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type { IBaseCell, ICell, ICellMetadata } from '@difizen/libro-common';
|
|
2
|
+
import type { MaybePromise, Newable } from '@difizen/mana-app';
|
|
3
|
+
import { Syringe } from '@difizen/mana-app';
|
|
4
|
+
|
|
5
|
+
import type { CellModel, CellOptions, CellView } from '../libro-protocol.js';
|
|
6
|
+
|
|
7
|
+
export type LibroCellMetadata = ICellMetadata & {
|
|
8
|
+
libroCellType?: string;
|
|
9
|
+
};
|
|
10
|
+
export interface LibroCustomCell extends IBaseCell {
|
|
11
|
+
metadata: Partial<LibroCellMetadata>;
|
|
12
|
+
}
|
|
13
|
+
export type LibroCell = LibroCustomCell | ICell;
|
|
14
|
+
|
|
15
|
+
export type CellModelFactory = (options: CellOptions) => CellModel;
|
|
16
|
+
export const CellModelFactory = Symbol('CellModelFactory');
|
|
17
|
+
|
|
18
|
+
export const getLibroCellType = (options: CellOptions) => {
|
|
19
|
+
return (options.cell.metadata?.libroCellType as string) ?? options.cell.cell_type;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export const CellModelContribution = Syringe.defineToken('CellModelContribution');
|
|
23
|
+
export interface CellModelContribution {
|
|
24
|
+
cellMeta: CellMeta;
|
|
25
|
+
canHandle: (options: CellOptions, libroType?: string) => number;
|
|
26
|
+
createModel: (options: CellOptions) => MaybePromise<CellModel>;
|
|
27
|
+
getDefaultCellOption?: () => CellOptions;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export const CellViewContribution = Syringe.defineToken('CellViewContribution');
|
|
31
|
+
export interface CellViewContribution {
|
|
32
|
+
canHandle: (options: CellOptions) => number;
|
|
33
|
+
view: Newable<CellView>;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export interface CellMeta {
|
|
37
|
+
type: string;
|
|
38
|
+
name: string;
|
|
39
|
+
order: string;
|
|
40
|
+
nbformatType?: string;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
//
|
|
44
|
+
|
|
45
|
+
export const CellService = Symbol('CellService');
|
|
46
|
+
export interface CellService {
|
|
47
|
+
cellsMeta: CellMeta[];
|
|
48
|
+
getModelFromCache: (groupId: string, modelId: string) => CellModel | undefined;
|
|
49
|
+
getOrCreateModel: (options: CellOptions, cacheGroupId?: string) => Promise<CellModel>;
|
|
50
|
+
getOrCreateView: (options: CellOptions, parentId: string) => Promise<CellView>;
|
|
51
|
+
findModelProvider: (options: CellOptions) => CellModelContribution | undefined;
|
|
52
|
+
findViewProvider: (options: CellOptions) => CellViewContribution | undefined;
|
|
53
|
+
}
|