@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,308 @@
|
|
|
1
|
+
import { useConfigurationValue } from '@difizen/mana-app';
|
|
2
|
+
import {
|
|
3
|
+
ToolbarRender,
|
|
4
|
+
useInject,
|
|
5
|
+
useObserve,
|
|
6
|
+
ViewInstance,
|
|
7
|
+
ViewRender,
|
|
8
|
+
} from '@difizen/mana-app';
|
|
9
|
+
import classnames from 'classnames';
|
|
10
|
+
import React, { useMemo, useRef, memo, forwardRef } from 'react';
|
|
11
|
+
|
|
12
|
+
import '../index.less';
|
|
13
|
+
import {
|
|
14
|
+
EditorCellView,
|
|
15
|
+
ExecutableCellModel,
|
|
16
|
+
ExecutableCellView,
|
|
17
|
+
isLibroCellModel,
|
|
18
|
+
} from '../cell/index.js';
|
|
19
|
+
import { CellCollapsible } from '../collapse-service.js';
|
|
20
|
+
import {
|
|
21
|
+
CellSideToolbarVisible,
|
|
22
|
+
CellTopToolbarSetting,
|
|
23
|
+
CollapserClickActive,
|
|
24
|
+
} from '../configuration/libro-configuration.js';
|
|
25
|
+
import type { CellView, DndItemProps } from '../libro-protocol.js';
|
|
26
|
+
import { LibroToolbarArea, isCellView } from '../libro-protocol.js';
|
|
27
|
+
import type { LibroView } from '../libro-view.js';
|
|
28
|
+
import { ArrowDown, ArrowRight, ContentMore } from '../material-from-designer.js';
|
|
29
|
+
import { hasErrorOutput } from '../output/index.js';
|
|
30
|
+
|
|
31
|
+
import {
|
|
32
|
+
CellInputBottonBlankProvider,
|
|
33
|
+
CellExecutionTimeProvider,
|
|
34
|
+
CellOutputVisulizationProvider,
|
|
35
|
+
} from './cell-protocol.js';
|
|
36
|
+
|
|
37
|
+
const CellInputContent = memo(function CellInputContent(props: { cell: CellView }) {
|
|
38
|
+
const { cell } = props;
|
|
39
|
+
const observableCell = useObserve(cell);
|
|
40
|
+
const CellExecutionTime = useInject<CellExecutionTimeProvider>(
|
|
41
|
+
CellExecutionTimeProvider,
|
|
42
|
+
);
|
|
43
|
+
const CellInputBottonBlank = useInject<CellInputBottonBlankProvider>(
|
|
44
|
+
CellInputBottonBlankProvider,
|
|
45
|
+
);
|
|
46
|
+
|
|
47
|
+
if (!observableCell?.view || !isCellView(observableCell)) {
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
50
|
+
const isHidden = observableCell.hasInputHidden;
|
|
51
|
+
if (isHidden) {
|
|
52
|
+
return (
|
|
53
|
+
<div className="libro-input-hidden">
|
|
54
|
+
<ContentMore />
|
|
55
|
+
</div>
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
return (
|
|
59
|
+
<div className="libro-cell-input-content">
|
|
60
|
+
<CellExecutionTime cell={cell} />
|
|
61
|
+
<ViewRender view={observableCell} />
|
|
62
|
+
<CellInputBottonBlank cell={cell} />
|
|
63
|
+
</div>
|
|
64
|
+
);
|
|
65
|
+
});
|
|
66
|
+
const CellInput: React.FC<{ cell: CellView }> = forwardRef(function CellInput(
|
|
67
|
+
props: {
|
|
68
|
+
cell: CellView;
|
|
69
|
+
},
|
|
70
|
+
ref: React.ForwardedRef<HTMLDivElement>,
|
|
71
|
+
) {
|
|
72
|
+
const { cell } = props;
|
|
73
|
+
const inputCollapserRef = useRef<HTMLDivElement>(null);
|
|
74
|
+
const [collapserClickActive] = useConfigurationValue(CollapserClickActive);
|
|
75
|
+
const handleCellInputCollapser = () => {
|
|
76
|
+
if (collapserClickActive) {
|
|
77
|
+
cell.hasInputHidden = !cell.hasInputHidden;
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
const hasErrorOutputs = EditorCellView.is(cell) ? hasErrorOutput(cell) : false;
|
|
81
|
+
const isFirstCell = cell.parent.model.cells.indexOf(cell) === 0 ? true : false;
|
|
82
|
+
return (
|
|
83
|
+
<div className="libro-cell-container" tabIndex={10} ref={ref}>
|
|
84
|
+
<div
|
|
85
|
+
className={`libro-cell-input-collapser ${isFirstCell ? 'firtCell' : ''} ${
|
|
86
|
+
hasErrorOutputs ? 'error' : ''
|
|
87
|
+
} `}
|
|
88
|
+
ref={inputCollapserRef}
|
|
89
|
+
onClick={handleCellInputCollapser}
|
|
90
|
+
/>
|
|
91
|
+
<CellInputContent cell={cell} />
|
|
92
|
+
</div>
|
|
93
|
+
);
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
export const CellOutputContent: React.FC<{ cell: CellView }> = memo(
|
|
97
|
+
function CellOutputContent(props: { cell: CellView }) {
|
|
98
|
+
const { cell } = props;
|
|
99
|
+
const observableCell = useObserve(cell);
|
|
100
|
+
const CellOutputVisulization = useInject<CellOutputVisulizationProvider>(
|
|
101
|
+
CellOutputVisulizationProvider,
|
|
102
|
+
);
|
|
103
|
+
|
|
104
|
+
if (!ExecutableCellView.is(cell) || !ExecutableCellView.is(observableCell)) {
|
|
105
|
+
return null;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
if (!ExecutableCellModel.is(observableCell.model)) {
|
|
109
|
+
return null;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
const hasOutputsScrolled = observableCell.model.hasOutputsScrolled;
|
|
113
|
+
|
|
114
|
+
const isHidden = observableCell.model.hasOutputHidden;
|
|
115
|
+
if (isHidden && observableCell?.outputArea?.length) {
|
|
116
|
+
return (
|
|
117
|
+
<div className="libro-cell-output-hidden">
|
|
118
|
+
<ContentMore />
|
|
119
|
+
</div>
|
|
120
|
+
);
|
|
121
|
+
}
|
|
122
|
+
return (
|
|
123
|
+
<div
|
|
124
|
+
className={`libro-cell-output-content ${hasOutputsScrolled ? 'scrolled' : ''} `}
|
|
125
|
+
>
|
|
126
|
+
<CellOutputVisulization cell={cell} />
|
|
127
|
+
<ViewRender view={cell.outputArea} />
|
|
128
|
+
</div>
|
|
129
|
+
);
|
|
130
|
+
},
|
|
131
|
+
);
|
|
132
|
+
|
|
133
|
+
export const LibroCellExecutionTime: CellExecutionTimeProvider = forwardRef(
|
|
134
|
+
function LibroCellExecutionTime() {
|
|
135
|
+
return null;
|
|
136
|
+
},
|
|
137
|
+
);
|
|
138
|
+
|
|
139
|
+
export const LibroCellInputBottonBlank: CellInputBottonBlankProvider = forwardRef(
|
|
140
|
+
function LibroCellInputBottonBlank() {
|
|
141
|
+
return null;
|
|
142
|
+
},
|
|
143
|
+
);
|
|
144
|
+
|
|
145
|
+
export const LibroCellVisualization: CellOutputVisulizationProvider = forwardRef(
|
|
146
|
+
function LibroCellVisualization() {
|
|
147
|
+
return null;
|
|
148
|
+
},
|
|
149
|
+
);
|
|
150
|
+
|
|
151
|
+
const CellOutput: React.FC<{ cell: CellView }> = forwardRef(function CellOutput(
|
|
152
|
+
props: {
|
|
153
|
+
cell: CellView;
|
|
154
|
+
},
|
|
155
|
+
ref: React.ForwardedRef<HTMLDivElement>,
|
|
156
|
+
) {
|
|
157
|
+
const { cell } = props;
|
|
158
|
+
const outputCollapserRef = useRef<HTMLDivElement>(null);
|
|
159
|
+
const [collapserClickActive] = useConfigurationValue(CollapserClickActive);
|
|
160
|
+
if (!ExecutableCellView.is(cell)) {
|
|
161
|
+
return null;
|
|
162
|
+
}
|
|
163
|
+
if (
|
|
164
|
+
!isCellView(cell) ||
|
|
165
|
+
!ExecutableCellModel.is(cell.model) ||
|
|
166
|
+
!cell.outputArea?.length
|
|
167
|
+
) {
|
|
168
|
+
return null;
|
|
169
|
+
}
|
|
170
|
+
const handleCellOutputCollapser = () => {
|
|
171
|
+
if (ExecutableCellModel.is(cell.model) && collapserClickActive) {
|
|
172
|
+
cell.model.hasOutputHidden = !cell.model.hasOutputHidden;
|
|
173
|
+
}
|
|
174
|
+
};
|
|
175
|
+
const hasErrorOutputs = hasErrorOutput(cell);
|
|
176
|
+
return (
|
|
177
|
+
<div className="libro-cell-output-container" ref={ref}>
|
|
178
|
+
<div
|
|
179
|
+
className={`libro-cell-output-collapser ${hasErrorOutputs ? 'error' : ''} `}
|
|
180
|
+
ref={outputCollapserRef}
|
|
181
|
+
onClick={handleCellOutputCollapser}
|
|
182
|
+
/>
|
|
183
|
+
<CellOutputContent cell={cell} />
|
|
184
|
+
</div>
|
|
185
|
+
);
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
const HideCellContent: React.FC<{ cell: CellView }> = (props: { cell: CellView }) => {
|
|
189
|
+
const { cell } = props;
|
|
190
|
+
const cellCollapserRef = useRef<HTMLDivElement>(null);
|
|
191
|
+
const [collapserClickActive] = useConfigurationValue(CollapserClickActive);
|
|
192
|
+
|
|
193
|
+
const handleCellCollapser = () => {
|
|
194
|
+
if (collapserClickActive) {
|
|
195
|
+
cell.hasInputHidden = !cell.hasInputHidden;
|
|
196
|
+
}
|
|
197
|
+
};
|
|
198
|
+
const hasErrorOutputs = hasErrorOutput(cell);
|
|
199
|
+
return (
|
|
200
|
+
<>
|
|
201
|
+
<div
|
|
202
|
+
className={`libro-cell-collapser ${hasErrorOutputs ? 'error' : ''}`}
|
|
203
|
+
ref={cellCollapserRef}
|
|
204
|
+
onClick={handleCellCollapser}
|
|
205
|
+
/>
|
|
206
|
+
<div className="libro-cell-hidden">
|
|
207
|
+
<ContentMore />
|
|
208
|
+
</div>
|
|
209
|
+
</>
|
|
210
|
+
);
|
|
211
|
+
};
|
|
212
|
+
export const DndCellItemRender = forwardRef(function DndCellItemRender(
|
|
213
|
+
props: DndItemProps,
|
|
214
|
+
ref: React.ForwardedRef<HTMLDivElement>,
|
|
215
|
+
) {
|
|
216
|
+
const { isDrag, isMouseOverDragArea, cell } = props;
|
|
217
|
+
const [topToolbarVisible] = useConfigurationValue(CellTopToolbarSetting);
|
|
218
|
+
const [sideToolbarVisible] = useConfigurationValue(CellSideToolbarVisible);
|
|
219
|
+
|
|
220
|
+
const instance = useInject<LibroView>(ViewInstance);
|
|
221
|
+
const isActive = instance.activeCell?.id === cell.id;
|
|
222
|
+
const executable = ExecutableCellModel.is(cell.model);
|
|
223
|
+
const isCollapsible = CellCollapsible.is(cell);
|
|
224
|
+
const executeState =
|
|
225
|
+
ExecutableCellModel.is(cell.model) && !cell.model.executing
|
|
226
|
+
? cell.model.executeCount || ' '
|
|
227
|
+
: '*';
|
|
228
|
+
// const hasExecuteCount =
|
|
229
|
+
// ExecutableCellModel.is(cell.model) &&
|
|
230
|
+
// typeof cell.model.executeCount === 'number' &&
|
|
231
|
+
// cell.model.executeCount > 0;
|
|
232
|
+
const topToolbarArgs = useMemo(() => {
|
|
233
|
+
return [cell, instance, LibroToolbarArea.CellTop];
|
|
234
|
+
}, [cell, instance]);
|
|
235
|
+
|
|
236
|
+
const rightToolbarArgs = useMemo(() => {
|
|
237
|
+
return [cell, instance, LibroToolbarArea.CellRight];
|
|
238
|
+
}, [cell, instance]);
|
|
239
|
+
|
|
240
|
+
if (!isLibroCellModel(cell.model)) {
|
|
241
|
+
return null;
|
|
242
|
+
}
|
|
243
|
+
const hasCellHidden = cell.hasCellHidden();
|
|
244
|
+
const hasErrorOutputs = hasErrorOutput(cell);
|
|
245
|
+
|
|
246
|
+
const classNames = [
|
|
247
|
+
'libro-dnd-cell',
|
|
248
|
+
{ active: isActive },
|
|
249
|
+
{ 'command-mode': instance.model.commandMode },
|
|
250
|
+
{ 'edit-mode': !instance.model.commandMode },
|
|
251
|
+
{ error: hasErrorOutputs },
|
|
252
|
+
{
|
|
253
|
+
hidden: hasCellHidden,
|
|
254
|
+
},
|
|
255
|
+
];
|
|
256
|
+
if (cell.wrapperCls) {
|
|
257
|
+
classNames.push(cell.wrapperCls);
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
return (
|
|
261
|
+
<div
|
|
262
|
+
className={`libro-dnd-cell-border ${isActive ? 'active' : ''} ${
|
|
263
|
+
instance.model.commandMode ? 'command-mode' : ''
|
|
264
|
+
} ${hasErrorOutputs ? 'error' : ''}`}
|
|
265
|
+
>
|
|
266
|
+
<div className={classnames(classNames)}>
|
|
267
|
+
{topToolbarVisible && isActive && (
|
|
268
|
+
<div className="libro-cell-top-toolbar">
|
|
269
|
+
<ToolbarRender data={topToolbarArgs} />
|
|
270
|
+
</div>
|
|
271
|
+
)}
|
|
272
|
+
{executable && !isMouseOverDragArea && (
|
|
273
|
+
<div className="libro-execute-tooltip-area">
|
|
274
|
+
<pre className="libro-execute-state-tip">{`[${executeState}]:`}</pre>
|
|
275
|
+
</div>
|
|
276
|
+
)}
|
|
277
|
+
<div className="libro-dnd-cell-preview" ref={ref} />
|
|
278
|
+
{cell.hasCellHidden() && <HideCellContent cell={cell} />}
|
|
279
|
+
{!cell.hasCellHidden() && (
|
|
280
|
+
<>
|
|
281
|
+
{instance.collapserVisible && isCollapsible && (
|
|
282
|
+
<div
|
|
283
|
+
className="libro-markdown-collapser"
|
|
284
|
+
onClick={() => {
|
|
285
|
+
instance.collapseCell(cell, !cell.headingCollapsed);
|
|
286
|
+
}}
|
|
287
|
+
>
|
|
288
|
+
{cell.headingCollapsed ? <ArrowRight /> : <ArrowDown />}
|
|
289
|
+
</div>
|
|
290
|
+
)}
|
|
291
|
+
<CellInput cell={cell} />
|
|
292
|
+
<CellOutput cell={cell} />
|
|
293
|
+
</>
|
|
294
|
+
)}
|
|
295
|
+
{sideToolbarVisible && (
|
|
296
|
+
<div className="libro-cell-right-toolbar">
|
|
297
|
+
{isActive && !isDrag && instance.model.readOnly !== true && (
|
|
298
|
+
<ToolbarRender
|
|
299
|
+
data={rightToolbarArgs}
|
|
300
|
+
tooltip={{ placement: LibroToolbarArea.CellRight }}
|
|
301
|
+
/>
|
|
302
|
+
)}
|
|
303
|
+
</div>
|
|
304
|
+
)}
|
|
305
|
+
</div>
|
|
306
|
+
</div>
|
|
307
|
+
);
|
|
308
|
+
});
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import { useInject, ViewInstance } from '@difizen/mana-app';
|
|
2
|
+
import { ViewRender } from '@difizen/mana-app';
|
|
3
|
+
import type { CSSProperties, FC } from 'react';
|
|
4
|
+
import { useState, useEffect, memo } from 'react';
|
|
5
|
+
import type { XYCoord } from 'react-dnd';
|
|
6
|
+
import { useDragLayer } from 'react-dnd';
|
|
7
|
+
|
|
8
|
+
import type { CellService } from '../../cell/index.js';
|
|
9
|
+
import { LibroCellService } from '../../cell/index.js';
|
|
10
|
+
import type { CellView } from '../../libro-protocol.js';
|
|
11
|
+
import type { LibroView } from '../../libro-view.js';
|
|
12
|
+
|
|
13
|
+
export interface SelectionPreviewProps {
|
|
14
|
+
activeCell: CellView;
|
|
15
|
+
}
|
|
16
|
+
const layerStyles: CSSProperties = {
|
|
17
|
+
position: 'fixed',
|
|
18
|
+
pointerEvents: 'none',
|
|
19
|
+
zIndex: 1000,
|
|
20
|
+
left: 0,
|
|
21
|
+
top: 0,
|
|
22
|
+
width: '300px',
|
|
23
|
+
height: '50px',
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
const getItemStyles = (currentOffset: XYCoord | null) => {
|
|
27
|
+
if (!currentOffset) {
|
|
28
|
+
return {
|
|
29
|
+
display: 'none',
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const { x, y } = currentOffset;
|
|
34
|
+
|
|
35
|
+
const transform = `translate(${x}px, ${y}px)`;
|
|
36
|
+
return {
|
|
37
|
+
transform,
|
|
38
|
+
WebkitTransform: transform,
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
const MultipleSelectionPreview: FC<{ activeCell: CellView }> = ({ activeCell }) => {
|
|
43
|
+
const cellService = useInject<CellService>(LibroCellService);
|
|
44
|
+
const [multipleSelectionPreview, setMultipleSelectionPreview] = useState<CellView>();
|
|
45
|
+
useEffect(() => {
|
|
46
|
+
cellService
|
|
47
|
+
.getOrCreateView(activeCell.model.options, activeCell.parent.id)
|
|
48
|
+
.then((view) => {
|
|
49
|
+
setMultipleSelectionPreview(view);
|
|
50
|
+
return;
|
|
51
|
+
})
|
|
52
|
+
.catch(() => {
|
|
53
|
+
//
|
|
54
|
+
});
|
|
55
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
56
|
+
}, []);
|
|
57
|
+
|
|
58
|
+
return (
|
|
59
|
+
<div className="libro-dnd-multiple-selection-preview">
|
|
60
|
+
<div className="libro-dnd-active-selection">
|
|
61
|
+
{multipleSelectionPreview && <ViewRender view={multipleSelectionPreview} />}
|
|
62
|
+
</div>
|
|
63
|
+
<div className="libro-dnd-cascading-multiple-selection" />
|
|
64
|
+
</div>
|
|
65
|
+
);
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
export const MultipleSelectionPreviewMemo: FC<SelectionPreviewProps> = memo(
|
|
69
|
+
MultipleSelectionPreview,
|
|
70
|
+
);
|
|
71
|
+
|
|
72
|
+
const SingleSelectionDragPreview: FC<{ activeCell: CellView }> = ({ activeCell }) => {
|
|
73
|
+
const cellService = useInject<CellService>(LibroCellService);
|
|
74
|
+
const [singleSelectionPreview, setSingleSelectionPreview] = useState<CellView>();
|
|
75
|
+
useEffect(() => {
|
|
76
|
+
cellService
|
|
77
|
+
.getOrCreateView(
|
|
78
|
+
{
|
|
79
|
+
...activeCell.model.options,
|
|
80
|
+
modelId: activeCell.model.id,
|
|
81
|
+
singleSelectionDragPreview: true,
|
|
82
|
+
},
|
|
83
|
+
activeCell.parent.id,
|
|
84
|
+
)
|
|
85
|
+
.then((view) => {
|
|
86
|
+
setSingleSelectionPreview(view);
|
|
87
|
+
return;
|
|
88
|
+
})
|
|
89
|
+
.catch(() => {
|
|
90
|
+
//
|
|
91
|
+
});
|
|
92
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
93
|
+
}, []);
|
|
94
|
+
|
|
95
|
+
return (
|
|
96
|
+
<div className="libro-dnd-active-selection">
|
|
97
|
+
{singleSelectionPreview && <ViewRender view={singleSelectionPreview} />}
|
|
98
|
+
</div>
|
|
99
|
+
);
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
export const SingleSelectionPreviewMemo: FC<SelectionPreviewProps> = memo(
|
|
103
|
+
SingleSelectionDragPreview,
|
|
104
|
+
);
|
|
105
|
+
|
|
106
|
+
export const CustomDragLayer: FC = () => {
|
|
107
|
+
const { isDragging, item, currentOffset } = useDragLayer((monitor) => ({
|
|
108
|
+
item: monitor.getItem(),
|
|
109
|
+
itemType: monitor.getItemType(),
|
|
110
|
+
currentOffset: monitor.getClientOffset(),
|
|
111
|
+
isDragging: monitor.isDragging(),
|
|
112
|
+
}));
|
|
113
|
+
|
|
114
|
+
const instance = useInject<LibroView>(ViewInstance);
|
|
115
|
+
|
|
116
|
+
function renderItem() {
|
|
117
|
+
const isItemSelected =
|
|
118
|
+
instance.model.selections.findIndex((select) => select.id === item.cell.id) >= 0;
|
|
119
|
+
if (instance.model.selections.length !== 0 && isItemSelected) {
|
|
120
|
+
return (
|
|
121
|
+
<>
|
|
122
|
+
{instance.model.active && (
|
|
123
|
+
<MultipleSelectionPreviewMemo activeCell={instance.model.active} />
|
|
124
|
+
)}
|
|
125
|
+
</>
|
|
126
|
+
);
|
|
127
|
+
}
|
|
128
|
+
return (
|
|
129
|
+
<>
|
|
130
|
+
{instance.model.active && (
|
|
131
|
+
<SingleSelectionPreviewMemo activeCell={instance.model.active} />
|
|
132
|
+
)}
|
|
133
|
+
</>
|
|
134
|
+
);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
if (!isDragging) {
|
|
138
|
+
return null;
|
|
139
|
+
}
|
|
140
|
+
return (
|
|
141
|
+
<div className="libro-custom-drag-layer" style={layerStyles}>
|
|
142
|
+
<div style={getItemStyles(currentOffset)}>{renderItem()}</div>
|
|
143
|
+
</div>
|
|
144
|
+
);
|
|
145
|
+
};
|