@difizen/libro-jupyter 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 +1 -0
- package/es/add-between-cell/add-between-cell-command-contribution.d.ts +14 -0
- package/es/add-between-cell/add-between-cell-command-contribution.d.ts.map +1 -0
- package/es/add-between-cell/add-between-cell-command-contribution.js +97 -0
- package/es/add-between-cell/add-between-cell.d.ts +5 -0
- package/es/add-between-cell/add-between-cell.d.ts.map +1 -0
- package/es/add-between-cell/add-between-cell.js +243 -0
- package/es/add-between-cell/index.d.ts +3 -0
- package/es/add-between-cell/index.d.ts.map +1 -0
- package/es/add-between-cell/index.js +2 -0
- package/es/add-between-cell/index.less +103 -0
- package/es/add-between-cell/module.d.ts +3 -0
- package/es/add-between-cell/module.d.ts.map +1 -0
- package/es/add-between-cell/module.js +8 -0
- package/es/cell/index.d.ts +3 -0
- package/es/cell/index.d.ts.map +1 -0
- package/es/cell/index.js +2 -0
- package/es/cell/jupyter-code-cell-model.d.ts +12 -0
- package/es/cell/jupyter-code-cell-model.d.ts.map +1 -0
- package/es/cell/jupyter-code-cell-model.js +56 -0
- package/es/cell/jupyter-code-cell-view.d.ts +18 -0
- package/es/cell/jupyter-code-cell-view.d.ts.map +1 -0
- package/es/cell/jupyter-code-cell-view.js +280 -0
- package/es/command/command-contribution.d.ts +10 -0
- package/es/command/command-contribution.d.ts.map +1 -0
- package/es/command/command-contribution.js +161 -0
- package/es/command/index.d.ts +3 -0
- package/es/command/index.d.ts.map +1 -0
- package/es/command/index.js +2 -0
- package/es/command/keybinding-contribution.d.ts +8 -0
- package/es/command/keybinding-contribution.d.ts.map +1 -0
- package/es/command/keybinding-contribution.js +37 -0
- package/es/components/cell-execution-tip.d.ts +6 -0
- package/es/components/cell-execution-tip.d.ts.map +1 -0
- package/es/components/cell-execution-tip.js +69 -0
- package/es/components/cell-input-bottom-blank.d.ts +5 -0
- package/es/components/cell-input-bottom-blank.d.ts.map +1 -0
- package/es/components/cell-input-bottom-blank.js +21 -0
- package/es/components/icons.d.ts +5 -0
- package/es/components/icons.d.ts.map +1 -0
- package/es/components/icons.js +154 -0
- package/es/components/index.d.ts +4 -0
- package/es/components/index.d.ts.map +1 -0
- package/es/components/index.js +3 -0
- package/es/components/index.less +82 -0
- package/es/config/config-contribution.d.ts +10 -0
- package/es/config/config-contribution.d.ts.map +1 -0
- package/es/config/config-contribution.js +50 -0
- package/es/config/config.d.ts +3 -0
- package/es/config/config.d.ts.map +1 -0
- package/es/config/config.js +11 -0
- package/es/config/index.d.ts +2 -0
- package/es/config/index.d.ts.map +1 -0
- package/es/config/index.js +1 -0
- package/es/configuration/index.d.ts +3 -0
- package/es/configuration/index.d.ts.map +1 -0
- package/es/configuration/index.js +2 -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 +3 -0
- package/es/configuration/libro-configuration.d.ts.map +1 -0
- package/es/configuration/libro-configuration.js +12 -0
- package/es/contents/content-contribution.d.ts +7 -0
- package/es/contents/content-contribution.d.ts.map +1 -0
- package/es/contents/content-contribution.js +63 -0
- package/es/contents/index.d.ts +2 -0
- package/es/contents/index.d.ts.map +1 -0
- package/es/contents/index.js +1 -0
- package/es/file/file-name-alias.d.ts +7 -0
- package/es/file/file-name-alias.d.ts.map +1 -0
- package/es/file/file-name-alias.js +26 -0
- package/es/file/file-protocol.d.ts +8 -0
- package/es/file/file-protocol.d.ts.map +1 -0
- package/es/file/file-protocol.js +7 -0
- package/es/file/file-service.d.ts +31 -0
- package/es/file/file-service.d.ts.map +1 -0
- package/es/file/file-service.js +329 -0
- package/es/file/file-tree-label-provider.d.ts +13 -0
- package/es/file/file-tree-label-provider.d.ts.map +1 -0
- package/es/file/file-tree-label-provider.js +62 -0
- package/es/file/file-view/index.d.ts +14 -0
- package/es/file/file-view/index.d.ts.map +1 -0
- package/es/file/file-view/index.js +101 -0
- package/es/file/file-view/index.less +5 -0
- package/es/file/index.d.ts +7 -0
- package/es/file/index.d.ts.map +1 -0
- package/es/file/index.js +6 -0
- package/es/file/module.d.ts +3 -0
- package/es/file/module.d.ts.map +1 -0
- package/es/file/module.js +8 -0
- package/es/file/navigatable-view.d.ts +24 -0
- package/es/file/navigatable-view.d.ts.map +1 -0
- package/es/file/navigatable-view.js +151 -0
- package/es/file/open-handler-contribution.d.ts +11 -0
- package/es/file/open-handler-contribution.d.ts.map +1 -0
- package/es/file/open-handler-contribution.js +102 -0
- package/es/index.d.ts +32 -0
- package/es/index.d.ts.map +1 -0
- package/es/index.js +31 -0
- package/es/keybind-instructions/index.d.ts +6 -0
- package/es/keybind-instructions/index.d.ts.map +1 -0
- package/es/keybind-instructions/index.js +5 -0
- package/es/keybind-instructions/index.less +177 -0
- package/es/keybind-instructions/keybind-instructions-contribution.d.ts +11 -0
- package/es/keybind-instructions/keybind-instructions-contribution.d.ts.map +1 -0
- package/es/keybind-instructions/keybind-instructions-contribution.js +84 -0
- package/es/keybind-instructions/keybind-instructions-icon.d.ts +3 -0
- package/es/keybind-instructions/keybind-instructions-icon.d.ts.map +1 -0
- package/es/keybind-instructions/keybind-instructions-icon.js +23 -0
- package/es/keybind-instructions/keybind-instructions-items.d.ts +14 -0
- package/es/keybind-instructions/keybind-instructions-items.d.ts.map +1 -0
- package/es/keybind-instructions/keybind-instructions-items.js +589 -0
- package/es/keybind-instructions/keybind-instructions-view.d.ts +16 -0
- package/es/keybind-instructions/keybind-instructions-view.d.ts.map +1 -0
- package/es/keybind-instructions/keybind-instructions-view.js +224 -0
- package/es/keybind-instructions/module.d.ts +3 -0
- package/es/keybind-instructions/module.d.ts.map +1 -0
- package/es/keybind-instructions/module.js +5 -0
- package/es/libro-jupyter-file-service.d.ts +106 -0
- package/es/libro-jupyter-file-service.d.ts.map +1 -0
- package/es/libro-jupyter-file-service.js +127 -0
- package/es/libro-jupyter-model.d.ts +49 -0
- package/es/libro-jupyter-model.d.ts.map +1 -0
- package/es/libro-jupyter-model.js +505 -0
- package/es/libro-jupyter-protocol.d.ts +38 -0
- package/es/libro-jupyter-protocol.d.ts.map +1 -0
- package/es/libro-jupyter-protocol.js +9 -0
- package/es/libro-jupyter-server-launch-manager.d.ts +11 -0
- package/es/libro-jupyter-server-launch-manager.d.ts.map +1 -0
- package/es/libro-jupyter-server-launch-manager.js +59 -0
- package/es/libro-jupyter-view.d.ts +10 -0
- package/es/libro-jupyter-view.d.ts.map +1 -0
- package/es/libro-jupyter-view.js +42 -0
- package/es/module.d.ts +3 -0
- package/es/module.d.ts.map +1 -0
- package/es/module.js +48 -0
- package/es/output/index.d.ts +2 -0
- package/es/output/index.d.ts.map +1 -0
- package/es/output/index.js +1 -0
- package/es/output/libro-jupyter-outputarea.d.ts +8 -0
- package/es/output/libro-jupyter-outputarea.d.ts.map +1 -0
- package/es/output/libro-jupyter-outputarea.js +77 -0
- package/es/rendermime/assets/plotly.svg +31 -0
- package/es/rendermime/index.d.ts +5 -0
- package/es/rendermime/index.d.ts.map +1 -0
- package/es/rendermime/index.js +4 -0
- package/es/rendermime/index.less +22 -0
- package/es/rendermime/module.d.ts +3 -0
- package/es/rendermime/module.d.ts.map +1 -0
- package/es/rendermime/module.js +3 -0
- package/es/rendermime/plotly-render.d.ts +7 -0
- package/es/rendermime/plotly-render.d.ts.map +1 -0
- package/es/rendermime/plotly-render.js +30 -0
- package/es/rendermime/plotly-renderers.d.ts +58 -0
- package/es/rendermime/plotly-renderers.d.ts.map +1 -0
- package/es/rendermime/plotly-renderers.js +211 -0
- package/es/rendermime/plotly-rendermime-contribution.d.ts +12 -0
- package/es/rendermime/plotly-rendermime-contribution.d.ts.map +1 -0
- package/es/rendermime/plotly-rendermime-contribution.js +22 -0
- package/es/theme/color-registry.d.ts +6 -0
- package/es/theme/color-registry.d.ts.map +1 -0
- package/es/theme/color-registry.js +393 -0
- package/es/theme/index.d.ts +2 -0
- package/es/theme/index.d.ts.map +1 -0
- package/es/theme/index.js +1 -0
- package/es/toolbar/index.d.ts +6 -0
- package/es/toolbar/index.d.ts.map +1 -0
- package/es/toolbar/index.js +5 -0
- package/es/toolbar/index.less +194 -0
- package/es/toolbar/kernel-selector-dropdown.d.ts +13 -0
- package/es/toolbar/kernel-selector-dropdown.d.ts.map +1 -0
- package/es/toolbar/kernel-selector-dropdown.js +165 -0
- package/es/toolbar/kernel-status-and-selector.d.ts +18 -0
- package/es/toolbar/kernel-status-and-selector.d.ts.map +1 -0
- package/es/toolbar/kernel-status-and-selector.js +164 -0
- package/es/toolbar/run-selector.d.ts +3 -0
- package/es/toolbar/run-selector.d.ts.map +1 -0
- package/es/toolbar/run-selector.js +98 -0
- package/es/toolbar/save-file-error-contribution.d.ts +5 -0
- package/es/toolbar/save-file-error-contribution.d.ts.map +1 -0
- package/es/toolbar/save-file-error-contribution.js +23 -0
- package/es/toolbar/save-file-error.d.ts +5 -0
- package/es/toolbar/save-file-error.d.ts.map +1 -0
- package/es/toolbar/save-file-error.js +27 -0
- package/es/toolbar/side-toolbar-run-selector.d.ts +3 -0
- package/es/toolbar/side-toolbar-run-selector.d.ts.map +1 -0
- package/es/toolbar/side-toolbar-run-selector.js +67 -0
- package/es/toolbar/toolbar-contribution.d.ts +9 -0
- package/es/toolbar/toolbar-contribution.d.ts.map +1 -0
- package/es/toolbar/toolbar-contribution.js +67 -0
- package/es/typings/index.d.ts +31 -0
- package/es/utils/index.d.ts +11 -0
- package/es/utils/index.d.ts.map +1 -0
- package/es/utils/index.js +47 -0
- package/package.json +75 -0
- package/src/add-between-cell/add-between-cell-command-contribution.ts +63 -0
- package/src/add-between-cell/add-between-cell.tsx +201 -0
- package/src/add-between-cell/index.less +103 -0
- package/src/add-between-cell/index.ts +2 -0
- package/src/add-between-cell/module.ts +13 -0
- package/src/cell/index.ts +2 -0
- package/src/cell/jupyter-code-cell-model.ts +36 -0
- package/src/cell/jupyter-code-cell-view.tsx +221 -0
- package/src/command/command-contribution.ts +163 -0
- package/src/command/index.ts +2 -0
- package/src/command/keybinding-contribution.ts +25 -0
- package/src/components/cell-execution-tip.tsx +107 -0
- package/src/components/cell-input-bottom-blank.tsx +24 -0
- package/src/components/icons.tsx +117 -0
- package/src/components/index.less +82 -0
- package/src/components/index.ts +3 -0
- package/src/config/config-contribution.ts +21 -0
- package/src/config/config.ts +14 -0
- package/src/config/index.ts +1 -0
- package/src/configuration/index.ts +2 -0
- package/src/configuration/libro-configuration-contribution.ts +11 -0
- package/src/configuration/libro-configuration.ts +14 -0
- package/src/contents/content-contribution.ts +32 -0
- package/src/contents/index.ts +1 -0
- package/src/file/file-name-alias.ts +15 -0
- package/src/file/file-protocol.ts +7 -0
- package/src/file/file-service.ts +179 -0
- package/src/file/file-tree-label-provider.ts +42 -0
- package/src/file/file-view/index.less +5 -0
- package/src/file/file-view/index.tsx +90 -0
- package/src/file/index.ts +6 -0
- package/src/file/module.ts +19 -0
- package/src/file/navigatable-view.tsx +93 -0
- package/src/file/open-handler-contribution.ts +44 -0
- package/src/index.ts +32 -0
- package/src/keybind-instructions/index.less +177 -0
- package/src/keybind-instructions/index.ts +5 -0
- package/src/keybind-instructions/keybind-instructions-contribution.ts +47 -0
- package/src/keybind-instructions/keybind-instructions-icon.tsx +28 -0
- package/src/keybind-instructions/keybind-instructions-items.tsx +597 -0
- package/src/keybind-instructions/keybind-instructions-view.tsx +239 -0
- package/src/keybind-instructions/module.ts +11 -0
- package/src/libro-jupyter-file-service.ts +158 -0
- package/src/libro-jupyter-model.ts +289 -0
- package/src/libro-jupyter-protocol.ts +59 -0
- package/src/libro-jupyter-server-launch-manager.ts +36 -0
- package/src/libro-jupyter-view.tsx +24 -0
- package/src/module.ts +105 -0
- package/src/output/index.ts +1 -0
- package/src/output/libro-jupyter-outputarea.tsx +71 -0
- package/src/rendermime/assets/plotly.svg +31 -0
- package/src/rendermime/index.less +13 -0
- package/src/rendermime/index.ts +4 -0
- package/src/rendermime/module.ts +7 -0
- package/src/rendermime/plotly-render.tsx +35 -0
- package/src/rendermime/plotly-renderers.ts +191 -0
- package/src/rendermime/plotly-rendermime-contribution.ts +15 -0
- package/src/theme/color-registry.ts +301 -0
- package/src/theme/index.ts +1 -0
- package/src/toolbar/index.less +194 -0
- package/src/toolbar/index.ts +5 -0
- package/src/toolbar/kernel-selector-dropdown.tsx +204 -0
- package/src/toolbar/kernel-status-and-selector.tsx +195 -0
- package/src/toolbar/run-selector.tsx +110 -0
- package/src/toolbar/save-file-error-contribution.ts +10 -0
- package/src/toolbar/save-file-error.tsx +35 -0
- package/src/toolbar/side-toolbar-run-selector.tsx +77 -0
- package/src/toolbar/toolbar-contribution.tsx +62 -0
- package/src/typings/index.d.ts +31 -0
- package/src/utils/index.ts +65 -0
|
@@ -0,0 +1,98 @@
|
|
|
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 { PlayCircleOutlined } from '@ant-design/icons';
|
|
8
|
+
import { NotebookCommands, ExecutableCellModel } from '@difizen/libro-core';
|
|
9
|
+
import { useInject, ToolbarInstance, getOrigin, CommandRegistry, ViewInstance } from '@difizen/mana-app';
|
|
10
|
+
import { l10n } from '@difizen/mana-l10n';
|
|
11
|
+
import { Menu, Dropdown, Tooltip } from 'antd';
|
|
12
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
+
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
14
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
15
|
+
export var RunSelector = function RunSelector() {
|
|
16
|
+
var libroView = useInject(ViewInstance);
|
|
17
|
+
var libroModel = libroView ? libroView.model : undefined;
|
|
18
|
+
var toolbar = useInject(ToolbarInstance);
|
|
19
|
+
var data = toolbar.currentArgs;
|
|
20
|
+
var command = useInject(CommandRegistry);
|
|
21
|
+
var curCell = data === null || data === void 0 ? void 0 : data[0];
|
|
22
|
+
var isRunVisible = ExecutableCellModel.is(curCell === null || curCell === void 0 ? void 0 : curCell.model) && !(curCell !== null && curCell !== void 0 && curCell.model.executing) ? true : false;
|
|
23
|
+
var isKernelIdle = libroModel ? libroModel.isKernelIdle : false;
|
|
24
|
+
var handleChange = function handleChange(e) {
|
|
25
|
+
var args = getOrigin(data) || [];
|
|
26
|
+
if (e.key === 'runCell') {
|
|
27
|
+
command.executeCommand.apply(command, [NotebookCommands['RunCell'].id].concat(_toConsumableArray(args)));
|
|
28
|
+
} else if (e.key === 'runAllCell') {
|
|
29
|
+
command.executeCommand.apply(command, [NotebookCommands['RunAllCells'].id].concat(_toConsumableArray(args)));
|
|
30
|
+
} else if (e.key === 'runAllAbove') {
|
|
31
|
+
command.executeCommand.apply(command, [NotebookCommands['RunAllAbove'].id].concat(_toConsumableArray(args)));
|
|
32
|
+
} else if (e.key === 'runAllBelow') {
|
|
33
|
+
command.executeCommand.apply(command, [NotebookCommands['RunAllBelow'].id].concat(_toConsumableArray(args)));
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
var menu = /*#__PURE__*/_jsx(Menu, {
|
|
37
|
+
className: "libro-run-menu-container",
|
|
38
|
+
onClick: handleChange,
|
|
39
|
+
items: [{
|
|
40
|
+
key: 'runCell',
|
|
41
|
+
label: /*#__PURE__*/_jsxs(_Fragment, {
|
|
42
|
+
children: [/*#__PURE__*/_jsx("span", {
|
|
43
|
+
className: "libro-run-menu-label",
|
|
44
|
+
children: l10n.t('运行当前Cell')
|
|
45
|
+
}), /*#__PURE__*/_jsx("span", {
|
|
46
|
+
className: "libro-run-menu-keybind",
|
|
47
|
+
children: "Cmd + Enter"
|
|
48
|
+
})]
|
|
49
|
+
}),
|
|
50
|
+
disabled: !isRunVisible
|
|
51
|
+
}, {
|
|
52
|
+
key: 'runAllCell',
|
|
53
|
+
label: /*#__PURE__*/_jsxs(_Fragment, {
|
|
54
|
+
children: [/*#__PURE__*/_jsx("span", {
|
|
55
|
+
className: "libro-run-menu-label",
|
|
56
|
+
children: l10n.t('运行全部')
|
|
57
|
+
}), /*#__PURE__*/_jsx("span", {
|
|
58
|
+
className: "libro-run-menu-keybind"
|
|
59
|
+
})]
|
|
60
|
+
})
|
|
61
|
+
}, {
|
|
62
|
+
key: 'runAllAbove',
|
|
63
|
+
label: /*#__PURE__*/_jsxs(_Fragment, {
|
|
64
|
+
children: [/*#__PURE__*/_jsx("span", {
|
|
65
|
+
className: "libro-run-menu-label",
|
|
66
|
+
children: l10n.t('运行之前所有cell')
|
|
67
|
+
}), /*#__PURE__*/_jsx("span", {
|
|
68
|
+
className: "libro-run-menu-keybind",
|
|
69
|
+
children: "Cmd + F8"
|
|
70
|
+
})]
|
|
71
|
+
})
|
|
72
|
+
}, {
|
|
73
|
+
key: 'runAllBelow',
|
|
74
|
+
label: /*#__PURE__*/_jsxs(_Fragment, {
|
|
75
|
+
children: [/*#__PURE__*/_jsx("span", {
|
|
76
|
+
className: "libro-run-menu-label",
|
|
77
|
+
children: l10n.t('运行当前及之后cell')
|
|
78
|
+
}), /*#__PURE__*/_jsx("span", {
|
|
79
|
+
className: "libro-run-menu-keybind",
|
|
80
|
+
children: "Cmd + F10"
|
|
81
|
+
})]
|
|
82
|
+
})
|
|
83
|
+
}]
|
|
84
|
+
});
|
|
85
|
+
if (isKernelIdle) {
|
|
86
|
+
return /*#__PURE__*/_jsx(Dropdown, {
|
|
87
|
+
overlay: menu,
|
|
88
|
+
placement: "bottomLeft",
|
|
89
|
+
children: /*#__PURE__*/_jsx(PlayCircleOutlined, {})
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
return /*#__PURE__*/_jsx(Tooltip, {
|
|
93
|
+
overlayClassName: "libro-tooltip-placement-bottom",
|
|
94
|
+
placement: "bottom",
|
|
95
|
+
title: l10n.t('kernel准备中,无法执行'),
|
|
96
|
+
children: /*#__PURE__*/_jsx(PlayCircleOutlined, {})
|
|
97
|
+
});
|
|
98
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"save-file-error-contribution.d.ts","sourceRoot":"","sources":["../../src/toolbar/save-file-error-contribution.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAa,MAAM,mBAAmB,CAAC;AAIjE,qBACa,yBAA0B,YAAW,iBAAiB;IACjE,aAAa;CAGd"}
|
|
@@ -0,0 +1,23 @@
|
|
|
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 _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
4
|
+
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); } }
|
|
5
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
6
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
7
|
+
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); }
|
|
8
|
+
import { ModalContribution, singleton } from '@difizen/mana-app';
|
|
9
|
+
import { SaveFileErrorModal } from "./save-file-error.js";
|
|
10
|
+
export var SaveFileErrorContribution = (_dec = singleton({
|
|
11
|
+
contrib: ModalContribution
|
|
12
|
+
}), _dec(_class = /*#__PURE__*/function () {
|
|
13
|
+
function SaveFileErrorContribution() {
|
|
14
|
+
_classCallCheck(this, SaveFileErrorContribution);
|
|
15
|
+
}
|
|
16
|
+
_createClass(SaveFileErrorContribution, [{
|
|
17
|
+
key: "registerModal",
|
|
18
|
+
value: function registerModal() {
|
|
19
|
+
return SaveFileErrorModal;
|
|
20
|
+
}
|
|
21
|
+
}]);
|
|
22
|
+
return SaveFileErrorContribution;
|
|
23
|
+
}()) || _class);
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/// <reference types="react" resolution-mode="require"/>
|
|
2
|
+
import type { ModalItemProps, ModalItem } from '@difizen/mana-app';
|
|
3
|
+
export declare const SaveFileModalComponent: React.FC<ModalItemProps<void>>;
|
|
4
|
+
export declare const SaveFileErrorModal: ModalItem;
|
|
5
|
+
//# sourceMappingURL=save-file-error.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"save-file-error.d.ts","sourceRoot":"","sources":["../../src/toolbar/save-file-error.tsx"],"names":[],"mappings":";AACA,OAAO,KAAK,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAMnE,eAAO,MAAM,sBAAsB,EAAE,KAAK,CAAC,EAAE,CAAC,cAAc,CAAC,IAAI,CAAC,CAsBjE,CAAC;AAEF,eAAO,MAAM,kBAAkB,EAAE,SAGhC,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { useInject, ViewInstance } from '@difizen/mana-app';
|
|
2
|
+
import { Modal } from 'antd';
|
|
3
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
4
|
+
export var SaveFileModalComponent = function SaveFileModalComponent(_ref) {
|
|
5
|
+
var visible = _ref.visible,
|
|
6
|
+
close = _ref.close;
|
|
7
|
+
var libroView = useInject(ViewInstance);
|
|
8
|
+
return /*#__PURE__*/_jsx(Modal, {
|
|
9
|
+
title: "File Save Error",
|
|
10
|
+
open: visible,
|
|
11
|
+
onOk: function onOk() {
|
|
12
|
+
return close();
|
|
13
|
+
},
|
|
14
|
+
onCancel: function onCancel() {
|
|
15
|
+
return close();
|
|
16
|
+
},
|
|
17
|
+
width: '400px',
|
|
18
|
+
centered: true,
|
|
19
|
+
children: /*#__PURE__*/_jsx("p", {
|
|
20
|
+
children: "File Save Error for: \"".concat(libroView && libroView.model ? libroView.model.currentFileContents.name : '', "\"")
|
|
21
|
+
})
|
|
22
|
+
});
|
|
23
|
+
};
|
|
24
|
+
export var SaveFileErrorModal = {
|
|
25
|
+
id: 'save-file-error',
|
|
26
|
+
component: SaveFileModalComponent
|
|
27
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"side-toolbar-run-selector.d.ts","sourceRoot":"","sources":["../../src/toolbar/side-toolbar-run-selector.tsx"],"names":[],"mappings":";AA+CA,eAAO,MAAM,sBAAsB,EAAE,KAAK,CAAC,EA6B1C,CAAC"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { PlayCircleOutlined } from '@ant-design/icons';
|
|
2
|
+
import { NotebookCommands, LibroSideToolbarMenu } from '@difizen/libro-core';
|
|
3
|
+
import { useInject, ViewInstance } from '@difizen/mana-app';
|
|
4
|
+
import { l10n } from '@difizen/mana-l10n';
|
|
5
|
+
import { Popover, Tooltip } from 'antd';
|
|
6
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
7
|
+
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
8
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
9
|
+
var items = [{
|
|
10
|
+
id: NotebookCommands['RunCell'].id,
|
|
11
|
+
label: /*#__PURE__*/_jsxs(_Fragment, {
|
|
12
|
+
children: [/*#__PURE__*/_jsx("span", {
|
|
13
|
+
className: "libro-menu-item-label",
|
|
14
|
+
children: l10n.t('运行 Cell')
|
|
15
|
+
}), /*#__PURE__*/_jsx("span", {
|
|
16
|
+
className: "libro-menu-item-keybind",
|
|
17
|
+
children: "Cmd + Enter"
|
|
18
|
+
})]
|
|
19
|
+
}),
|
|
20
|
+
group: 'runCell1'
|
|
21
|
+
}, {
|
|
22
|
+
id: NotebookCommands['RunAllAbove'].id,
|
|
23
|
+
label: /*#__PURE__*/_jsxs(_Fragment, {
|
|
24
|
+
children: [/*#__PURE__*/_jsx("span", {
|
|
25
|
+
className: "libro-menu-item-label",
|
|
26
|
+
children: l10n.t('运行上方所有 Cell')
|
|
27
|
+
}), /*#__PURE__*/_jsx("span", {
|
|
28
|
+
className: "libro-menu-item-keybind",
|
|
29
|
+
children: "Cmd + F8"
|
|
30
|
+
})]
|
|
31
|
+
}),
|
|
32
|
+
group: 'runCell2'
|
|
33
|
+
}, {
|
|
34
|
+
id: NotebookCommands['RunAllBelow'].id,
|
|
35
|
+
label: /*#__PURE__*/_jsxs(_Fragment, {
|
|
36
|
+
children: [/*#__PURE__*/_jsx("span", {
|
|
37
|
+
className: "libro-menu-item-label",
|
|
38
|
+
children: l10n.t('运行当前及下方所有 Cell')
|
|
39
|
+
}), /*#__PURE__*/_jsx("span", {
|
|
40
|
+
className: "libro-menu-item-keybind",
|
|
41
|
+
children: "Cmd + F10"
|
|
42
|
+
})]
|
|
43
|
+
}),
|
|
44
|
+
group: 'runCell2'
|
|
45
|
+
}];
|
|
46
|
+
export var SideToolbarRunSelector = function SideToolbarRunSelector() {
|
|
47
|
+
var libroView = useInject(ViewInstance);
|
|
48
|
+
var libroModel = libroView ? libroView.model : undefined;
|
|
49
|
+
var isKernelIdle = libroModel ? libroModel.isKernelIdle : false;
|
|
50
|
+
if (isKernelIdle) {
|
|
51
|
+
return /*#__PURE__*/_jsx(Popover, {
|
|
52
|
+
placement: "leftTop",
|
|
53
|
+
content: /*#__PURE__*/_jsx(LibroSideToolbarMenu, {
|
|
54
|
+
items: items
|
|
55
|
+
}),
|
|
56
|
+
trigger: "hover",
|
|
57
|
+
overlayClassName: "libro-popover-side-toolbar-menu libro-side-toolbar-run-select-menu",
|
|
58
|
+
children: /*#__PURE__*/_jsx(PlayCircleOutlined, {})
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
return /*#__PURE__*/_jsx(Tooltip, {
|
|
62
|
+
overlayClassName: "libro-tooltip-placement-right",
|
|
63
|
+
placement: "right",
|
|
64
|
+
title: l10n.t('kernel准备中,无法执行'),
|
|
65
|
+
children: /*#__PURE__*/_jsx(PlayCircleOutlined, {})
|
|
66
|
+
});
|
|
67
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ToolbarRegistry } from '@difizen/mana-app';
|
|
2
|
+
import { ToolbarContribution } from '@difizen/mana-app';
|
|
3
|
+
import { KernelStatusAndSelectorProvider } from '../libro-jupyter-protocol.js';
|
|
4
|
+
export declare class LibroJupyterToolbarContribution implements ToolbarContribution {
|
|
5
|
+
kernelStatusAndSelector: KernelStatusAndSelectorProvider;
|
|
6
|
+
constructor(kernelStatusAndSelector: KernelStatusAndSelectorProvider);
|
|
7
|
+
registerToolbarItems(registry: ToolbarRegistry): void;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=toolbar-contribution.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toolbar-contribution.d.ts","sourceRoot":"","sources":["../../src/toolbar/toolbar-contribution.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,EAAqB,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAI3E,OAAO,EAAE,+BAA+B,EAAE,MAAM,8BAA8B,CAAC;AAK/E,qBACa,+BAAgC,YAAW,mBAAmB;IACzE,uBAAuB,EAAE,+BAA+B,CAAC;gBAIvD,uBAAuB,EAAE,+BAA+B;IAK1D,oBAAoB,CAAC,QAAQ,EAAE,eAAe,GAAG,IAAI;CAuCtD"}
|
|
@@ -0,0 +1,67 @@
|
|
|
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 _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
4
|
+
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); } }
|
|
5
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
6
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
7
|
+
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); }
|
|
8
|
+
import { KernelCommands, NotebookCommands } from '@difizen/libro-core';
|
|
9
|
+
import { singleton, inject, ToolbarContribution } from '@difizen/mana-app';
|
|
10
|
+
import { l10n } from '@difizen/mana-l10n';
|
|
11
|
+
import { Location } from "../components/icons.js";
|
|
12
|
+
import { KernelStatusAndSelectorProvider } from "../libro-jupyter-protocol.js";
|
|
13
|
+
import { RunSelector } from "./run-selector.js";
|
|
14
|
+
import { SideToolbarRunSelector } from "./side-toolbar-run-selector.js";
|
|
15
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
16
|
+
export var LibroJupyterToolbarContribution = (_dec = singleton({
|
|
17
|
+
contrib: ToolbarContribution
|
|
18
|
+
}), _dec(_class = /*#__PURE__*/function () {
|
|
19
|
+
function LibroJupyterToolbarContribution(kernelStatusAndSelector) {
|
|
20
|
+
_classCallCheck(this, LibroJupyterToolbarContribution);
|
|
21
|
+
this.kernelStatusAndSelector = void 0;
|
|
22
|
+
this.kernelStatusAndSelector = kernelStatusAndSelector;
|
|
23
|
+
}
|
|
24
|
+
LibroJupyterToolbarContribution = inject(KernelStatusAndSelectorProvider)(LibroJupyterToolbarContribution, undefined, 0) || LibroJupyterToolbarContribution;
|
|
25
|
+
_createClass(LibroJupyterToolbarContribution, [{
|
|
26
|
+
key: "registerToolbarItems",
|
|
27
|
+
value: function registerToolbarItems(registry) {
|
|
28
|
+
registry.registerItem({
|
|
29
|
+
id: KernelCommands['ShowKernelStatusAndSelector'].id,
|
|
30
|
+
icon: this.kernelStatusAndSelector,
|
|
31
|
+
command: KernelCommands['ShowKernelStatusAndSelector'].id,
|
|
32
|
+
order: 'o'
|
|
33
|
+
});
|
|
34
|
+
registry.registerItem({
|
|
35
|
+
id: NotebookCommands['SideToolbarRunSelect'].id,
|
|
36
|
+
command: NotebookCommands['SideToolbarRunSelect'].id,
|
|
37
|
+
icon: SideToolbarRunSelector,
|
|
38
|
+
showLabelInline: true,
|
|
39
|
+
group: ['sidetoolbar1'],
|
|
40
|
+
order: 'a'
|
|
41
|
+
});
|
|
42
|
+
registry.registerItem({
|
|
43
|
+
id: NotebookCommands['TopToolbarRunSelect'].id,
|
|
44
|
+
command: NotebookCommands['TopToolbarRunSelect'].id,
|
|
45
|
+
icon: RunSelector,
|
|
46
|
+
showLabelInline: true,
|
|
47
|
+
group: ['group2'],
|
|
48
|
+
order: 'a'
|
|
49
|
+
});
|
|
50
|
+
registry.registerItem({
|
|
51
|
+
id: NotebookCommands['SelectLastRunCell'].id,
|
|
52
|
+
icon: Location,
|
|
53
|
+
command: NotebookCommands['SelectLastRunCell'].id,
|
|
54
|
+
group: ['group2'],
|
|
55
|
+
order: 'b',
|
|
56
|
+
tooltip: /*#__PURE__*/_jsx("div", {
|
|
57
|
+
className: "libro-tooltip",
|
|
58
|
+
children: /*#__PURE__*/_jsx("span", {
|
|
59
|
+
className: "libro-tooltip-text",
|
|
60
|
+
children: l10n.t('定位正在执行的Cell')
|
|
61
|
+
})
|
|
62
|
+
})
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
}]);
|
|
66
|
+
return LibroJupyterToolbarContribution;
|
|
67
|
+
}()) || _class);
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
declare module '*.less';
|
|
2
|
+
|
|
3
|
+
declare module 'plotly.js' {
|
|
4
|
+
export type Frame = Record<string, any>;
|
|
5
|
+
export function addFrames(root: Plotly.Root, frames: Frame[]): Promise<void>;
|
|
6
|
+
export function animate(root: Plotly.Root): void;
|
|
7
|
+
export type Data = any;
|
|
8
|
+
export type Layout = any;
|
|
9
|
+
|
|
10
|
+
type PlotlyEvent =
|
|
11
|
+
| 'plotly_webglcontextlost'
|
|
12
|
+
| 'plotly_restyle'
|
|
13
|
+
| 'plotly_relayout'
|
|
14
|
+
| 'plotly_update'
|
|
15
|
+
| 'plotly_click'
|
|
16
|
+
| 'plotly_hover'
|
|
17
|
+
| 'plotly_unhover'
|
|
18
|
+
| 'plotly_selected'
|
|
19
|
+
| 'plotly_deselect'
|
|
20
|
+
| 'plotly_doubleclick';
|
|
21
|
+
|
|
22
|
+
export interface PlotlyHTMLElement extends HTMLElement {
|
|
23
|
+
_fullData: Data;
|
|
24
|
+
_fullLayout: Layout;
|
|
25
|
+
data: Data;
|
|
26
|
+
layout: Layout;
|
|
27
|
+
on(event: PlotlyEvent, callback: (update: any) => void): void;
|
|
28
|
+
}
|
|
29
|
+
export function react(node: HTMLElement, data: any, layout: any, config: any): void;
|
|
30
|
+
export function toImage(...args: any[]): Promise<string>;
|
|
31
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { CellModel } from '@difizen/libro-core';
|
|
2
|
+
import type { LibroJupyterModel } from '../libro-jupyter-model.js';
|
|
3
|
+
export declare const EXECUTE_INPUT = "to_execute";
|
|
4
|
+
export declare const EXECUTE_REPLY_START = "shell.execute_reply.started";
|
|
5
|
+
export declare const EXECUTE_REPLY_REPLY = "shell.execute_reply.end";
|
|
6
|
+
export declare function getDefaultKernel(): string;
|
|
7
|
+
export declare const isWaitingExecute: (model: CellModel) => boolean;
|
|
8
|
+
export declare function formatTime(value: number): string;
|
|
9
|
+
export declare function parseExecutionInfoFromModel(model: CellModel): Record<string, string> | undefined;
|
|
10
|
+
export declare function isKernelIdle(libroModel?: LibroJupyterModel): boolean;
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAGrD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAGnE,eAAO,MAAM,aAAa,eAAe,CAAC;AAC1C,eAAO,MAAM,mBAAmB,gCAAgC,CAAC;AACjE,eAAO,MAAM,mBAAmB,4BAA4B,CAAC;AAE7D,wBAAgB,gBAAgB,IAAI,MAAM,CAEzC;AAED,eAAO,MAAM,gBAAgB,UAAW,SAAS,YAIhD,CAAC;AAEF,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAgBhD;AAED,wBAAgB,2BAA2B,CACzC,KAAK,EAAE,SAAS,GACf,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS,CAgBpC;AAED,wBAAgB,YAAY,CAAC,UAAU,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAMpE"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { duration } from 'moment';
|
|
2
|
+
export var EXECUTE_INPUT = 'to_execute'; // 用户点击执行按钮的时间
|
|
3
|
+
export var EXECUTE_REPLY_START = 'shell.execute_reply.started'; // Kernel 开始执行任务时间在 metadata 中的 key
|
|
4
|
+
export var EXECUTE_REPLY_REPLY = 'shell.execute_reply.end'; // Kernel 结束执行任务时间在 metadata 中的 key
|
|
5
|
+
|
|
6
|
+
export function getDefaultKernel() {
|
|
7
|
+
return 'Python 3';
|
|
8
|
+
}
|
|
9
|
+
export var isWaitingExecute = function isWaitingExecute(model) {
|
|
10
|
+
var _ref = model,
|
|
11
|
+
executing = _ref.executing,
|
|
12
|
+
kernelExecuting = _ref.kernelExecuting;
|
|
13
|
+
return !kernelExecuting && executing;
|
|
14
|
+
};
|
|
15
|
+
export function formatTime(value) {
|
|
16
|
+
var time = duration(value);
|
|
17
|
+
var hours = time.hours();
|
|
18
|
+
var minutes = time.minutes();
|
|
19
|
+
var seconds = time.seconds();
|
|
20
|
+
var milliseconds = ('000' + time.milliseconds()).substr(-3);
|
|
21
|
+
if (hours >= 1) {
|
|
22
|
+
return hours + 'h ' + minutes + 'min ' + seconds + 's ' + milliseconds + 'ms';
|
|
23
|
+
} else if (minutes >= 1) {
|
|
24
|
+
return minutes + 'min ' + seconds + 's ' + milliseconds + 'ms';
|
|
25
|
+
} else if (seconds >= 1) {
|
|
26
|
+
return seconds + 's ' + milliseconds + 'ms';
|
|
27
|
+
} else {
|
|
28
|
+
return milliseconds + 'ms';
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
export function parseExecutionInfoFromModel(model) {
|
|
32
|
+
var executionInfo = model.metadata['execution'];
|
|
33
|
+
if (executionInfo) {
|
|
34
|
+
var toExecuteTime = executionInfo[EXECUTE_INPUT]; // 用户点击执行按钮的时间
|
|
35
|
+
var executeStartTime = executionInfo[EXECUTE_REPLY_START]; // Kernel 开始执行任务时间
|
|
36
|
+
var executeFinishTime = executionInfo[EXECUTE_REPLY_REPLY]; // Kernel 结束执行任务时间
|
|
37
|
+
return {
|
|
38
|
+
toExecuteTime: toExecuteTime,
|
|
39
|
+
executeStartTime: executeStartTime,
|
|
40
|
+
executeFinishTime: executeFinishTime
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
export function isKernelIdle(libroModel) {
|
|
46
|
+
return !!(libroModel && libroModel.kernelConnection && libroModel.kernelConnection.status === 'idle');
|
|
47
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@difizen/libro-jupyter",
|
|
3
|
+
"version": "0.0.2-alpha.0",
|
|
4
|
+
"description": "",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"libro"
|
|
7
|
+
],
|
|
8
|
+
"repository": "git@github.com:difizen/libro.git",
|
|
9
|
+
"license": "MIT",
|
|
10
|
+
"type": "module",
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"typings": "./es/index.d.ts",
|
|
14
|
+
"default": "./es/index.js"
|
|
15
|
+
},
|
|
16
|
+
"./mock": {
|
|
17
|
+
"typings": "./es/mock/index.d.ts",
|
|
18
|
+
"default": "./es/mock/index.js"
|
|
19
|
+
},
|
|
20
|
+
"./es/mock": {
|
|
21
|
+
"typings": "./es/mock/index.d.ts",
|
|
22
|
+
"default": "./es/mock/index.js"
|
|
23
|
+
},
|
|
24
|
+
"./package.json": "./package.json"
|
|
25
|
+
},
|
|
26
|
+
"main": "es/index.js",
|
|
27
|
+
"module": "es/index.js",
|
|
28
|
+
"typings": "es/index.d.ts",
|
|
29
|
+
"files": [
|
|
30
|
+
"es",
|
|
31
|
+
"src"
|
|
32
|
+
],
|
|
33
|
+
"dependencies": {
|
|
34
|
+
"@difizen/libro-code-editor": "^0.0.2-alpha.0",
|
|
35
|
+
"@difizen/libro-codemirror": "^0.0.2-alpha.0",
|
|
36
|
+
"@difizen/libro-codemirror-code-cell": "^0.0.2-alpha.0",
|
|
37
|
+
"@difizen/libro-codemirror-markdown-cell": "^0.0.2-alpha.0",
|
|
38
|
+
"@difizen/libro-codemirror-raw-cell": "^0.0.2-alpha.0",
|
|
39
|
+
"@difizen/libro-rendermime": "^0.0.2-alpha.0",
|
|
40
|
+
"@difizen/libro-common": "^0.0.2-alpha.0",
|
|
41
|
+
"@difizen/libro-core": "^0.0.2-alpha.0",
|
|
42
|
+
"@difizen/libro-kernel": "^0.0.2-alpha.0",
|
|
43
|
+
"@difizen/libro-l10n": "^0.0.2-alpha.0",
|
|
44
|
+
"@difizen/libro-output": "^0.0.2-alpha.0",
|
|
45
|
+
"@difizen/libro-search": "^0.0.2-alpha.0",
|
|
46
|
+
"@difizen/libro-search-codemirror-cell": "^0.0.2-alpha.0",
|
|
47
|
+
"@difizen/mana-app": "alpha",
|
|
48
|
+
"@difizen/mana-l10n": "alpha",
|
|
49
|
+
"@ant-design/colors": "^7.0.0",
|
|
50
|
+
"@ant-design/icons": "^5.1.0",
|
|
51
|
+
"classnames": "^2.3.2",
|
|
52
|
+
"moment": "^2.29.4",
|
|
53
|
+
"plotly.js": "^2.16.1"
|
|
54
|
+
},
|
|
55
|
+
"peerDependencies": {
|
|
56
|
+
"antd": "^5.8.6",
|
|
57
|
+
"react": "^18.2.0"
|
|
58
|
+
},
|
|
59
|
+
"devDependencies": {
|
|
60
|
+
"@types/react": "^18.2.25"
|
|
61
|
+
},
|
|
62
|
+
"scripts": {
|
|
63
|
+
"setup": "father build",
|
|
64
|
+
"build": "father build",
|
|
65
|
+
"test": ": Note: lint task is delegated to test:* scripts",
|
|
66
|
+
"test:vitest": "vitest run",
|
|
67
|
+
"test:jest": "jest",
|
|
68
|
+
"coverage": ": Note: lint task is delegated to coverage:* scripts",
|
|
69
|
+
"coverage:vitest": "vitest run --coverage",
|
|
70
|
+
"coverage:jest": "jest --coverage",
|
|
71
|
+
"lint": ": Note: lint task is delegated to lint:* scripts",
|
|
72
|
+
"lint:eslint": "eslint src",
|
|
73
|
+
"lint:tsc": "tsc --noEmit"
|
|
74
|
+
}
|
|
75
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import type { CellOptions } from '@difizen/libro-core';
|
|
2
|
+
import type { CommandRegistry } from '@difizen/mana-app';
|
|
3
|
+
import { CommandContribution, singleton } from '@difizen/mana-app';
|
|
4
|
+
|
|
5
|
+
export const LibroAddBetweenCellCommand = {
|
|
6
|
+
AddBetweenCell: {
|
|
7
|
+
id: 'notebook:libro-add-between-cell',
|
|
8
|
+
},
|
|
9
|
+
AddBetweenCellWithContext: {
|
|
10
|
+
id: 'notebook:libro-add-between-cell-with-context',
|
|
11
|
+
},
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
@singleton({ contrib: CommandContribution })
|
|
15
|
+
export class LibroAddBetweenCellCommandContribution implements CommandContribution {
|
|
16
|
+
registerCommands(command: CommandRegistry): void {
|
|
17
|
+
command.registerCommand(LibroAddBetweenCellCommand.AddBetweenCell, {
|
|
18
|
+
execute: async (
|
|
19
|
+
type: string,
|
|
20
|
+
addCell: (option: CellOptions, position?: number | undefined) => Promise<void>,
|
|
21
|
+
index: number,
|
|
22
|
+
) => {
|
|
23
|
+
if (!type || typeof addCell !== 'function') {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
await addCell(
|
|
27
|
+
{
|
|
28
|
+
cell: {
|
|
29
|
+
cell_type: type,
|
|
30
|
+
metadata: {},
|
|
31
|
+
source: '',
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
index,
|
|
35
|
+
);
|
|
36
|
+
},
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
command.registerCommand(LibroAddBetweenCellCommand.AddBetweenCellWithContext, {
|
|
40
|
+
execute: async (
|
|
41
|
+
type: string,
|
|
42
|
+
addCell: (option: CellOptions, position?: number | undefined) => Promise<void>,
|
|
43
|
+
index: number,
|
|
44
|
+
context: Record<string, any>,
|
|
45
|
+
) => {
|
|
46
|
+
if (!type || typeof addCell !== 'function') {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
await addCell(
|
|
50
|
+
{
|
|
51
|
+
cell: {
|
|
52
|
+
cell_type: type,
|
|
53
|
+
metadata: {},
|
|
54
|
+
source: '',
|
|
55
|
+
},
|
|
56
|
+
context: context,
|
|
57
|
+
},
|
|
58
|
+
index,
|
|
59
|
+
);
|
|
60
|
+
},
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
}
|