@difizen/libro-core 0.1.1 → 0.1.2
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/es/add-cell/index.less +1 -1
- package/es/add-cell/libro-add-cell-slot-contribution.d.ts +1 -2
- package/es/add-cell/libro-add-cell-slot-contribution.d.ts.map +1 -1
- package/es/add-cell/libro-add-cell-slot-contribution.js +12 -6
- package/es/add-cell/libro-add-cell-view.d.ts +4 -4
- package/es/add-cell/libro-add-cell-view.d.ts.map +1 -1
- package/es/add-cell/libro-add-cell-view.js +4 -6
- package/es/cell/libro-cell-contribution.d.ts +1 -2
- package/es/cell/libro-cell-contribution.d.ts.map +1 -1
- package/es/cell/libro-cell-contribution.js +14 -8
- package/es/cell/libro-cell-model.d.ts +9 -0
- package/es/cell/libro-cell-model.d.ts.map +1 -1
- package/es/cell/libro-cell-model.js +53 -11
- package/es/cell/libro-cell-protocol.d.ts +2 -0
- package/es/cell/libro-cell-protocol.d.ts.map +1 -1
- package/es/cell/libro-cell-view.d.ts +6 -2
- package/es/cell/libro-cell-view.d.ts.map +1 -1
- package/es/cell/libro-cell-view.js +54 -24
- package/es/cell/libro-edit-cell-view.d.ts +6 -12
- package/es/cell/libro-edit-cell-view.d.ts.map +1 -1
- package/es/cell/libro-edit-cell-view.js +9 -4
- package/es/cell/libro-executable-cell-view.d.ts +2 -0
- package/es/cell/libro-executable-cell-view.d.ts.map +1 -1
- package/es/cell/libro-executable-cell-view.js +4 -1
- package/es/collapse-service.d.ts +1 -1
- package/es/collapse-service.d.ts.map +1 -1
- package/es/collapse-service.js +1 -1
- package/es/command/document-commands.d.ts +1 -2
- package/es/command/document-commands.d.ts.map +1 -1
- package/es/command/document-commands.js +3 -2
- package/es/command/kernel-command.d.ts.map +1 -1
- package/es/command/kernel-command.js +3 -0
- package/es/command/libro-command-contribution.d.ts +0 -1
- package/es/command/libro-command-contribution.d.ts.map +1 -1
- package/es/command/libro-command-contribution.js +179 -129
- package/es/command/libro-command-register.d.ts +0 -1
- package/es/command/libro-command-register.d.ts.map +1 -1
- package/es/command/libro-command-register.js +13 -7
- package/es/command/notebook-commands.d.ts.map +1 -1
- package/es/command/notebook-commands.js +17 -4
- package/es/components/cell-protocol.d.ts +5 -5
- package/es/components/cell-protocol.d.ts.map +1 -1
- package/es/components/dnd-cell-item-render.d.ts +6 -2
- package/es/components/dnd-cell-item-render.d.ts.map +1 -1
- package/es/components/dnd-cell-item-render.js +194 -89
- package/es/components/dnd-component/custom-drag-layer.d.ts +1 -1
- package/es/components/dnd-component/custom-drag-layer.d.ts.map +1 -1
- package/es/components/dnd-component/custom-drag-layer.js +3 -4
- package/es/components/dnd-component/default-dnd-content.d.ts +2 -1
- package/es/components/dnd-component/default-dnd-content.d.ts.map +1 -1
- package/es/components/dnd-component/default-dnd-content.js +100 -44
- package/es/components/dnd-component/dnd-context.js +1 -1
- package/es/components/dnd-component/dnd-list.d.ts +9 -5
- package/es/components/dnd-component/dnd-list.d.ts.map +1 -1
- package/es/components/dnd-component/dnd-list.js +93 -26
- package/es/components/dnd-component/index.d.ts +1 -1
- package/es/components/dnd-component/index.d.ts.map +1 -1
- package/es/components/dnd-component/index.js +2 -2
- package/es/components/dnd-component/index.less +8 -0
- package/es/components/dnd-component/overscanIndices-getter.d.ts +22 -0
- package/es/components/dnd-component/overscanIndices-getter.d.ts.map +1 -0
- package/es/components/dnd-component/overscanIndices-getter.js +58 -0
- package/es/components/dnd-component/virtualized-manager.d.ts +19 -0
- package/es/components/dnd-component/virtualized-manager.d.ts.map +1 -0
- package/es/components/dnd-component/virtualized-manager.js +60 -0
- package/es/components/index.d.ts +2 -2
- package/es/components/index.d.ts.map +1 -1
- package/es/components/index.js +2 -2
- package/es/components/libro-virtualized-render.d.ts +15 -0
- package/es/components/libro-virtualized-render.d.ts.map +1 -0
- package/es/components/libro-virtualized-render.js +174 -0
- package/es/content/index.d.ts +1 -0
- package/es/content/index.d.ts.map +1 -1
- package/es/content/index.js +2 -1
- package/es/content/libro-content-contribution.d.ts +2 -2
- package/es/content/libro-content-contribution.d.ts.map +1 -1
- package/es/content/libro-content-contribution.js +2 -3
- package/es/content/libro-content-module.d.ts.map +1 -1
- package/es/content/libro-content-module.js +3 -2
- package/es/content/libro-content-protocol.d.ts +5 -0
- package/es/content/libro-content-protocol.d.ts.map +1 -1
- package/es/content/libro-content-protocol.js +2 -1
- package/es/content/libro-content-service.d.ts +5 -3
- package/es/content/libro-content-service.d.ts.map +1 -1
- package/es/content/libro-content-service.js +36 -8
- package/es/content/libro-save-content-contribution.d.ts +6 -0
- package/es/content/libro-save-content-contribution.d.ts.map +1 -0
- package/es/content/libro-save-content-contribution.js +27 -0
- package/es/formatter/index.d.ts +6 -0
- package/es/formatter/index.d.ts.map +1 -0
- package/es/formatter/index.js +5 -0
- package/es/formatter/libro-formatter-json-contribution.d.ts +18 -0
- package/es/formatter/libro-formatter-json-contribution.d.ts.map +1 -0
- package/es/formatter/libro-formatter-json-contribution.js +41 -0
- package/es/formatter/libro-formatter-manager.d.ts +16 -0
- package/es/formatter/libro-formatter-manager.d.ts.map +1 -0
- package/es/formatter/libro-formatter-manager.js +86 -0
- package/es/formatter/libro-formatter-module.d.ts +3 -0
- package/es/formatter/libro-formatter-module.d.ts.map +1 -0
- package/es/formatter/libro-formatter-module.js +7 -0
- package/es/formatter/libro-formatter-protocol.d.ts +37 -0
- package/es/formatter/libro-formatter-protocol.d.ts.map +1 -0
- package/es/formatter/libro-formatter-protocol.js +18 -0
- package/es/formatter/libro-formatter-string-contribution.d.ts +18 -0
- package/es/formatter/libro-formatter-string-contribution.d.ts.map +1 -0
- package/es/formatter/libro-formatter-string-contribution.js +41 -0
- package/es/formatter/libro-formatter-trans-default-contribution.d.ts +7 -0
- package/es/formatter/libro-formatter-trans-default-contribution.d.ts.map +1 -0
- package/es/formatter/libro-formatter-trans-default-contribution.js +19 -0
- package/es/index.d.ts +5 -1
- package/es/index.d.ts.map +1 -1
- package/es/index.js +6 -2
- package/es/index.less +135 -58
- package/es/libro-context-key.d.ts.map +1 -1
- package/es/libro-model.d.ts +13 -2
- package/es/libro-model.d.ts.map +1 -1
- package/es/libro-model.js +149 -70
- package/es/libro-protocol.d.ts +44 -2
- package/es/libro-protocol.d.ts.map +1 -1
- package/es/libro-protocol.js +16 -3
- package/es/libro-service.d.ts +1 -1
- package/es/libro-service.d.ts.map +1 -1
- package/es/libro-service.js +29 -20
- package/es/{configuration/libro-configuration-contribution.d.ts → libro-setting-contribution.d.ts} +2 -2
- package/es/libro-setting-contribution.d.ts.map +1 -0
- package/es/{configuration/libro-configuration-contribution.js → libro-setting-contribution.js} +8 -9
- package/es/{configuration/libro-configuration.d.ts → libro-setting.d.ts} +3 -2
- package/es/libro-setting.d.ts.map +1 -0
- package/es/{configuration/libro-configuration.js → libro-setting.js} +17 -7
- package/es/libro-view.d.ts +21 -8
- package/es/libro-view.d.ts.map +1 -1
- package/es/libro-view.js +477 -338
- package/es/material-from-designer.d.ts +3 -0
- package/es/material-from-designer.d.ts.map +1 -1
- package/es/material-from-designer.js +112 -1
- package/es/module.d.ts.map +1 -1
- package/es/module.js +20 -5
- package/es/output/output-area.d.ts +3 -4
- package/es/output/output-area.d.ts.map +1 -1
- package/es/output/output-area.js +23 -16
- package/es/output/output-contribution.d.ts +0 -1
- package/es/output/output-contribution.d.ts.map +1 -1
- package/es/output/output-contribution.js +14 -9
- package/es/output/output-model.d.ts +2 -2
- package/es/output/output-model.d.ts.map +1 -1
- package/es/output/output-model.js +2 -2
- package/es/output/output-protocol.d.ts.map +1 -1
- package/es/output/output-protocol.js +0 -2
- package/es/settings/index.d.ts +5 -0
- package/es/settings/index.d.ts.map +1 -0
- package/es/settings/index.js +4 -0
- package/es/settings/index.less +3 -0
- package/es/settings/module.d.ts +3 -0
- package/es/settings/module.d.ts.map +1 -0
- package/es/settings/module.js +4 -0
- package/es/settings/setting-editor/configuration-panel-view.d.ts +13 -0
- package/es/settings/setting-editor/configuration-panel-view.d.ts.map +1 -0
- package/es/settings/setting-editor/configuration-panel-view.js +115 -0
- package/es/settings/setting-editor/configuration-render-contribution.d.ts +6 -0
- package/es/settings/setting-editor/configuration-render-contribution.d.ts.map +1 -0
- package/es/settings/setting-editor/configuration-render-contribution.js +77 -0
- package/es/settings/setting-editor/default-node-render.d.ts +9 -0
- package/es/settings/setting-editor/default-node-render.d.ts.map +1 -0
- package/es/settings/setting-editor/default-node-render.js +79 -0
- package/es/settings/setting-editor/index.d.ts +7 -0
- package/es/settings/setting-editor/index.d.ts.map +1 -0
- package/es/settings/setting-editor/index.js +6 -0
- package/es/settings/setting-editor/index.less +12 -0
- package/es/settings/setting-editor/module.d.ts +3 -0
- package/es/settings/setting-editor/module.d.ts.map +1 -0
- package/es/settings/setting-editor/module.js +7 -0
- package/es/settings/setting-editor/setting-editor-view.d.ts +15 -0
- package/es/settings/setting-editor/setting-editor-view.d.ts.map +1 -0
- package/es/settings/setting-editor/setting-editor-view.js +169 -0
- package/es/settings/setting-editor/setting-tree-service.d.ts +9 -0
- package/es/settings/setting-editor/setting-tree-service.d.ts.map +1 -0
- package/es/settings/setting-editor/setting-tree-service.js +118 -0
- package/es/settings/setting-editor/setting-tree-view.d.ts +19 -0
- package/es/settings/setting-editor/setting-tree-view.d.ts.map +1 -0
- package/es/settings/setting-editor/setting-tree-view.js +88 -0
- package/es/settings/settings-contribution.d.ts +7 -0
- package/es/settings/settings-contribution.d.ts.map +1 -0
- package/es/settings/settings-contribution.js +36 -0
- package/es/settings/settings-modal.d.ts +5 -0
- package/es/settings/settings-modal.d.ts.map +1 -0
- package/es/settings/settings-modal.js +53 -0
- package/es/settings/settings-modal.less +3 -0
- package/es/settings/settings-protocol.d.ts +4 -0
- package/es/settings/settings-protocol.d.ts.map +1 -0
- package/es/settings/settings-protocol.js +5 -0
- package/es/slot/libro-slot-manager.d.ts +2 -2
- package/es/slot/libro-slot-manager.d.ts.map +1 -1
- package/es/slot/libro-slot-manager.js +14 -8
- package/es/slot/libro-slot-view.d.ts +3 -3
- package/es/slot/libro-slot-view.d.ts.map +1 -1
- package/es/slot/libro-slot-view.js +2 -2
- package/es/theme/libro-color-registry.d.ts.map +1 -1
- package/es/theme/libro-color-registry.js +7 -0
- package/es/toolbar/all-outputs-scroll-icon.d.ts +3 -0
- package/es/toolbar/all-outputs-scroll-icon.d.ts.map +1 -0
- package/es/toolbar/all-outputs-scroll-icon.js +10 -0
- package/es/toolbar/libro-toolbar.d.ts +2 -1
- package/es/toolbar/libro-toolbar.d.ts.map +1 -1
- package/es/toolbar/libro-toolbar.js +44 -8
- package/es/toolbar/restart-clear-outputs-modal.d.ts +1 -2
- package/es/toolbar/restart-clear-outputs-modal.d.ts.map +1 -1
- package/es/toolbar/restart-clear-outputs-modal.js +2 -2
- package/es/toolbar/shutdown-modal.d.ts +1 -2
- package/es/toolbar/shutdown-modal.d.ts.map +1 -1
- package/es/toolbar/shutdown-modal.js +2 -2
- package/es/toolbar/side-toolar-more-select.d.ts.map +1 -1
- package/es/toolbar/side-toolar-more-select.js +2 -2
- package/es/virtualized-manager-helper.d.ts +11 -0
- package/es/virtualized-manager-helper.d.ts.map +1 -0
- package/es/virtualized-manager-helper.js +51 -0
- package/es/virtualized-manager.d.ts +19 -0
- package/es/virtualized-manager.d.ts.map +1 -0
- package/es/virtualized-manager.js +61 -0
- package/package.json +9 -6
- package/src/add-cell/index.less +1 -1
- package/src/add-cell/libro-add-cell-slot-contribution.ts +1 -4
- package/src/add-cell/libro-add-cell-view.tsx +13 -6
- package/src/cell/libro-cell-contribution.ts +2 -6
- package/src/cell/libro-cell-model.ts +57 -4
- package/src/cell/libro-cell-protocol.ts +2 -0
- package/src/cell/libro-cell-view.tsx +21 -9
- package/src/cell/libro-edit-cell-view.tsx +10 -9
- package/src/cell/libro-executable-cell-view.ts +6 -1
- package/src/collapse-service.ts +1 -1
- package/src/command/document-commands.ts +3 -5
- package/src/command/kernel-command.ts +3 -0
- package/src/command/libro-command-contribution.ts +107 -91
- package/src/command/libro-command-register.ts +1 -4
- package/src/command/notebook-commands.ts +16 -3
- package/src/components/cell-protocol.ts +5 -5
- package/src/components/dnd-cell-item-render.tsx +239 -92
- package/src/components/dnd-component/custom-drag-layer.tsx +5 -6
- package/src/components/dnd-component/default-dnd-content.tsx +113 -42
- package/src/components/dnd-component/dnd-context.tsx +1 -1
- package/src/components/dnd-component/dnd-list.tsx +135 -43
- package/src/components/dnd-component/index.less +8 -0
- package/src/components/dnd-component/index.tsx +1 -1
- package/src/components/dnd-component/overscanIndices-getter.ts +92 -0
- package/src/components/dnd-component/virtualized-manager.ts +34 -0
- package/src/components/index.ts +2 -2
- package/src/components/libro-virtualized-render.tsx +178 -0
- package/src/content/index.ts +1 -0
- package/src/content/libro-content-contribution.ts +2 -3
- package/src/content/libro-content-module.ts +11 -3
- package/src/content/libro-content-protocol.ts +6 -0
- package/src/content/libro-content-service.ts +26 -8
- package/src/content/libro-save-content-contribution.ts +12 -0
- package/src/formatter/index.ts +5 -0
- package/src/formatter/libro-formatter-json-contribution.ts +42 -0
- package/src/formatter/libro-formatter-manager.ts +85 -0
- package/src/formatter/libro-formatter-module.ts +19 -0
- package/src/formatter/libro-formatter-protocol.ts +63 -0
- package/src/formatter/libro-formatter-string-contribution.ts +41 -0
- package/src/formatter/libro-formatter-trans-default-contribution.ts +15 -0
- package/src/index.less +135 -58
- package/src/index.tsx +6 -1
- package/src/libro-context-key.ts +3 -3
- package/src/libro-model.ts +87 -23
- package/src/libro-protocol.ts +81 -4
- package/src/libro-service.ts +4 -13
- package/src/{configuration/libro-configuration-contribution.ts → libro-setting-contribution.ts} +7 -8
- package/src/{configuration/libro-configuration.ts → libro-setting.ts} +18 -7
- package/src/libro-view.tsx +273 -141
- package/src/material-from-designer.tsx +93 -1
- package/src/module.ts +29 -7
- package/src/output/output-area.tsx +18 -12
- package/src/output/output-contribution.ts +2 -6
- package/src/output/output-model.tsx +3 -3
- package/src/output/output-protocol.ts +0 -1
- package/src/settings/index.less +3 -0
- package/src/settings/index.ts +4 -0
- package/src/settings/module.ts +8 -0
- package/src/settings/setting-editor/configuration-panel-view.tsx +89 -0
- package/src/settings/setting-editor/configuration-render-contribution.ts +81 -0
- package/src/settings/setting-editor/default-node-render.tsx +65 -0
- package/src/settings/setting-editor/index.less +12 -0
- package/src/settings/setting-editor/index.ts +6 -0
- package/src/settings/setting-editor/module.ts +17 -0
- package/src/settings/setting-editor/setting-editor-view.tsx +93 -0
- package/src/settings/setting-editor/setting-tree-service.ts +82 -0
- package/src/settings/setting-editor/setting-tree-view.tsx +95 -0
- package/src/settings/settings-contribution.tsx +24 -0
- package/src/settings/settings-modal.less +3 -0
- package/src/settings/settings-modal.tsx +50 -0
- package/src/settings/settings-protocol.ts +7 -0
- package/src/slot/libro-slot-manager.ts +1 -3
- package/src/slot/libro-slot-view.tsx +2 -5
- package/src/theme/libro-color-registry.ts +6 -0
- package/src/toolbar/all-outputs-scroll-icon.tsx +19 -0
- package/src/toolbar/libro-toolbar.tsx +30 -5
- package/src/toolbar/restart-clear-outputs-modal.tsx +3 -3
- package/src/toolbar/shutdown-modal.tsx +3 -3
- package/src/toolbar/side-toolar-more-select.tsx +2 -1
- package/src/virtualized-manager-helper.ts +29 -0
- package/src/virtualized-manager.ts +34 -0
- package/es/configuration/libro-configuration-contribution.d.ts.map +0 -1
- package/es/configuration/libro-configuration.d.ts.map +0 -1
|
@@ -1,15 +1,19 @@
|
|
|
1
|
-
|
|
1
|
+
/* eslint-disable react-hooks/exhaustive-deps */
|
|
2
2
|
import {
|
|
3
|
+
useConfigurationValue,
|
|
4
|
+
CommandRegistry,
|
|
5
|
+
equals,
|
|
3
6
|
ToolbarRender,
|
|
4
7
|
useInject,
|
|
5
8
|
useObserve,
|
|
6
9
|
ViewInstance,
|
|
7
10
|
ViewRender,
|
|
8
11
|
} from '@difizen/mana-app';
|
|
12
|
+
import { Tooltip } from 'antd';
|
|
9
13
|
import classnames from 'classnames';
|
|
10
|
-
import
|
|
14
|
+
import type { FC } from 'react';
|
|
15
|
+
import React, { forwardRef, memo, useLayoutEffect, useMemo, useRef } from 'react';
|
|
11
16
|
|
|
12
|
-
import '../index.less';
|
|
13
17
|
import {
|
|
14
18
|
EditorCellView,
|
|
15
19
|
ExecutableCellModel,
|
|
@@ -17,26 +21,36 @@ import {
|
|
|
17
21
|
isLibroCellModel,
|
|
18
22
|
} from '../cell/index.js';
|
|
19
23
|
import { CellCollapsible } from '../collapse-service.js';
|
|
24
|
+
import { NotebookCommands } from '../command/index.js';
|
|
25
|
+
import '../index.less';
|
|
26
|
+
import type { CellView, DndItemProps } from '../libro-protocol.js';
|
|
27
|
+
import { isCellView, LibroToolbarArea } from '../libro-protocol.js';
|
|
20
28
|
import {
|
|
21
29
|
CellSideToolbarVisible,
|
|
22
30
|
CellTopToolbarSetting,
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
import { LibroToolbarArea, isCellView } from '../libro-protocol.js';
|
|
31
|
+
CollapserClickActive,
|
|
32
|
+
OutputScrollBtnVisiable,
|
|
33
|
+
} from '../libro-setting.js';
|
|
27
34
|
import type { LibroView } from '../libro-view.js';
|
|
28
|
-
import {
|
|
35
|
+
import {
|
|
36
|
+
ArrowDown,
|
|
37
|
+
ArrowRight,
|
|
38
|
+
ContentMore,
|
|
39
|
+
DisableOutputScroll,
|
|
40
|
+
EnableOutputScroll,
|
|
41
|
+
} from '../material-from-designer.js';
|
|
29
42
|
import { hasErrorOutput } from '../output/index.js';
|
|
30
43
|
|
|
31
44
|
import {
|
|
32
|
-
CellInputBottonBlankProvider,
|
|
33
45
|
CellExecutionTimeProvider,
|
|
46
|
+
CellInputBottonBlankProvider,
|
|
34
47
|
CellOutputVisulizationProvider,
|
|
35
48
|
} from './cell-protocol.js';
|
|
36
49
|
|
|
37
50
|
const CellInputContent = memo(function CellInputContent(props: { cell: CellView }) {
|
|
38
51
|
const { cell } = props;
|
|
39
52
|
const observableCell = useObserve(cell);
|
|
53
|
+
|
|
40
54
|
const CellExecutionTime = useInject<CellExecutionTimeProvider>(
|
|
41
55
|
CellExecutionTimeProvider,
|
|
42
56
|
);
|
|
@@ -63,39 +77,54 @@ const CellInputContent = memo(function CellInputContent(props: { cell: CellView
|
|
|
63
77
|
</div>
|
|
64
78
|
);
|
|
65
79
|
});
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
80
|
+
|
|
81
|
+
interface CellInputProps {
|
|
82
|
+
cell: CellView;
|
|
83
|
+
}
|
|
84
|
+
const CellInputInnner = forwardRef(function CellInput(
|
|
85
|
+
props: CellInputProps,
|
|
70
86
|
ref: React.ForwardedRef<HTMLDivElement>,
|
|
71
87
|
) {
|
|
72
88
|
const { cell } = props;
|
|
89
|
+
const observableCell = useObserve(cell);
|
|
73
90
|
const inputCollapserRef = useRef<HTMLDivElement>(null);
|
|
74
|
-
const [collapserClickActive] = useConfigurationValue(
|
|
91
|
+
const [collapserClickActive] = useConfigurationValue(CollapserClickActive);
|
|
75
92
|
const handleCellInputCollapser = () => {
|
|
76
93
|
if (collapserClickActive) {
|
|
77
|
-
|
|
94
|
+
observableCell.hasInputHidden = !observableCell.hasInputHidden;
|
|
78
95
|
}
|
|
79
96
|
};
|
|
80
|
-
const hasErrorOutputs = EditorCellView.is(
|
|
81
|
-
|
|
97
|
+
const hasErrorOutputs = EditorCellView.is(observableCell)
|
|
98
|
+
? hasErrorOutput(observableCell)
|
|
99
|
+
: false;
|
|
100
|
+
// TODO: 性能!
|
|
101
|
+
// const isFirstCell = cell.parent.model.cells.indexOf(cell) === 0 ? true : false;
|
|
102
|
+
const isFirstCell = useMemo(() => {
|
|
103
|
+
return observableCell.parent.model.cells[0] &&
|
|
104
|
+
equals(observableCell.parent.model.cells[0], observableCell)
|
|
105
|
+
? true
|
|
106
|
+
: false;
|
|
107
|
+
}, [observableCell]);
|
|
108
|
+
|
|
82
109
|
return (
|
|
83
110
|
<div className="libro-cell-container" tabIndex={10} ref={ref}>
|
|
84
111
|
<div
|
|
85
|
-
className={`libro-cell-input-collapser ${isFirstCell ? '
|
|
112
|
+
className={`libro-cell-input-collapser ${isFirstCell ? 'firstCell' : ''} ${
|
|
86
113
|
hasErrorOutputs ? 'error' : ''
|
|
87
114
|
} `}
|
|
88
115
|
ref={inputCollapserRef}
|
|
89
116
|
onClick={handleCellInputCollapser}
|
|
90
117
|
/>
|
|
91
|
-
<CellInputContent cell={
|
|
118
|
+
<CellInputContent cell={observableCell} />
|
|
92
119
|
</div>
|
|
93
120
|
);
|
|
94
121
|
});
|
|
122
|
+
const CellInput: FC<CellInputProps> = memo<CellInputProps>(CellInputInnner);
|
|
95
123
|
|
|
96
124
|
export const CellOutputContent: React.FC<{ cell: CellView }> = memo(
|
|
97
125
|
function CellOutputContent(props: { cell: CellView }) {
|
|
98
126
|
const { cell } = props;
|
|
127
|
+
|
|
99
128
|
const observableCell = useObserve(cell);
|
|
100
129
|
const CellOutputVisulization = useInject<CellOutputVisulizationProvider>(
|
|
101
130
|
CellOutputVisulizationProvider,
|
|
@@ -112,7 +141,7 @@ export const CellOutputContent: React.FC<{ cell: CellView }> = memo(
|
|
|
112
141
|
const hasOutputsScrolled = observableCell.model.hasOutputsScrolled;
|
|
113
142
|
|
|
114
143
|
const isHidden = observableCell.model.hasOutputHidden;
|
|
115
|
-
if (isHidden
|
|
144
|
+
if (isHidden) {
|
|
116
145
|
return (
|
|
117
146
|
<div className="libro-cell-output-hidden">
|
|
118
147
|
<ContentMore />
|
|
@@ -155,8 +184,47 @@ const CellOutput: React.FC<{ cell: CellView }> = forwardRef(function CellOutput(
|
|
|
155
184
|
ref: React.ForwardedRef<HTMLDivElement>,
|
|
156
185
|
) {
|
|
157
186
|
const { cell } = props;
|
|
187
|
+
const outputRef = useRef<HTMLDivElement>(null);
|
|
158
188
|
const outputCollapserRef = useRef<HTMLDivElement>(null);
|
|
159
|
-
const [
|
|
189
|
+
const [collapserClickActive] = useConfigurationValue(CollapserClickActive);
|
|
190
|
+
const [outputScrollBtnVisiable] = useConfigurationValue(OutputScrollBtnVisiable);
|
|
191
|
+
const command = useInject(CommandRegistry);
|
|
192
|
+
|
|
193
|
+
const isExecutingRef = useRef<boolean | null>(null);
|
|
194
|
+
|
|
195
|
+
let executing = false;
|
|
196
|
+
if (ExecutableCellModel.is(cell.model)) {
|
|
197
|
+
executing = cell.model.executing;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
useLayoutEffect(() => {
|
|
201
|
+
isExecutingRef.current = !!executing;
|
|
202
|
+
}, [executing]);
|
|
203
|
+
|
|
204
|
+
useLayoutEffect(() => {
|
|
205
|
+
if (!outputRef || !isExecutingRef || !outputRef?.current) {
|
|
206
|
+
return () => {
|
|
207
|
+
//
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
const el = outputRef?.current;
|
|
211
|
+
|
|
212
|
+
const resizeObserver = new ResizeObserver((entries) => {
|
|
213
|
+
entries.forEach(() => {
|
|
214
|
+
const outputAreaHeight = outputRef?.current?.clientHeight || 0;
|
|
215
|
+
if (isExecutingRef.current && outputAreaHeight > 495) {
|
|
216
|
+
command.executeCommand(NotebookCommands['EnableOutputScrolling'].id);
|
|
217
|
+
}
|
|
218
|
+
});
|
|
219
|
+
});
|
|
220
|
+
|
|
221
|
+
resizeObserver.observe(el as HTMLElement);
|
|
222
|
+
return () => {
|
|
223
|
+
resizeObserver.unobserve(el as HTMLElement);
|
|
224
|
+
resizeObserver.disconnect();
|
|
225
|
+
};
|
|
226
|
+
}, [outputRef.current, cell, isExecutingRef]);
|
|
227
|
+
|
|
160
228
|
if (!ExecutableCellView.is(cell)) {
|
|
161
229
|
return null;
|
|
162
230
|
}
|
|
@@ -168,19 +236,53 @@ const CellOutput: React.FC<{ cell: CellView }> = forwardRef(function CellOutput(
|
|
|
168
236
|
return null;
|
|
169
237
|
}
|
|
170
238
|
const handleCellOutputCollapser = () => {
|
|
171
|
-
if (ExecutableCellModel.is(cell.model) &&
|
|
239
|
+
if (ExecutableCellModel.is(cell.model) && collapserClickActive) {
|
|
172
240
|
cell.model.hasOutputHidden = !cell.model.hasOutputHidden;
|
|
173
241
|
}
|
|
174
242
|
};
|
|
175
|
-
|
|
243
|
+
|
|
244
|
+
const handleOutputScroll = () => {
|
|
245
|
+
if (!ExecutableCellModel.is(cell.model)) {
|
|
246
|
+
return;
|
|
247
|
+
}
|
|
248
|
+
if (cell.model.hasOutputsScrolled) {
|
|
249
|
+
command.executeCommand(NotebookCommands['DisableOutputScrolling'].id);
|
|
250
|
+
} else {
|
|
251
|
+
command.executeCommand(NotebookCommands['EnableOutputScrolling'].id);
|
|
252
|
+
}
|
|
253
|
+
};
|
|
176
254
|
return (
|
|
177
255
|
<div className="libro-cell-output-container" ref={ref}>
|
|
178
|
-
<div
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
256
|
+
<div ref={outputRef}>
|
|
257
|
+
<div
|
|
258
|
+
className={'libro-cell-output-collapser'}
|
|
259
|
+
ref={outputCollapserRef}
|
|
260
|
+
onClick={handleCellOutputCollapser}
|
|
261
|
+
/>
|
|
262
|
+
{outputScrollBtnVisiable && (
|
|
263
|
+
<div className="libro-cell-output-scroll">
|
|
264
|
+
<Tooltip
|
|
265
|
+
title={`${
|
|
266
|
+
cell.model.hasOutputsScrolled
|
|
267
|
+
? '取消固定 Output 高度'
|
|
268
|
+
: '固定 Output 高度'
|
|
269
|
+
}`}
|
|
270
|
+
>
|
|
271
|
+
<div
|
|
272
|
+
className="libro-cell-output-scroll-button "
|
|
273
|
+
onClick={handleOutputScroll}
|
|
274
|
+
>
|
|
275
|
+
{cell.model.hasOutputsScrolled ? (
|
|
276
|
+
<DisableOutputScroll />
|
|
277
|
+
) : (
|
|
278
|
+
<EnableOutputScroll />
|
|
279
|
+
)}
|
|
280
|
+
</div>
|
|
281
|
+
</Tooltip>
|
|
282
|
+
</div>
|
|
283
|
+
)}
|
|
284
|
+
<CellOutputContent cell={cell} />
|
|
285
|
+
</div>
|
|
184
286
|
</div>
|
|
185
287
|
);
|
|
186
288
|
});
|
|
@@ -188,7 +290,7 @@ const CellOutput: React.FC<{ cell: CellView }> = forwardRef(function CellOutput(
|
|
|
188
290
|
const HideCellContent: React.FC<{ cell: CellView }> = (props: { cell: CellView }) => {
|
|
189
291
|
const { cell } = props;
|
|
190
292
|
const cellCollapserRef = useRef<HTMLDivElement>(null);
|
|
191
|
-
const [collapserClickActive] = useConfigurationValue(
|
|
293
|
+
const [collapserClickActive] = useConfigurationValue(CollapserClickActive);
|
|
192
294
|
|
|
193
295
|
const handleCellCollapser = () => {
|
|
194
296
|
if (collapserClickActive) {
|
|
@@ -209,26 +311,74 @@ const HideCellContent: React.FC<{ cell: CellView }> = (props: { cell: CellView }
|
|
|
209
311
|
</>
|
|
210
312
|
);
|
|
211
313
|
};
|
|
212
|
-
|
|
314
|
+
|
|
315
|
+
const ExecuteTooltipArea = memo(function ExecuteTooltipArea(props: {
|
|
316
|
+
isMouseOverDragArea: boolean | undefined;
|
|
317
|
+
cell: CellView;
|
|
318
|
+
}) {
|
|
319
|
+
const { isMouseOverDragArea, cell } = props;
|
|
320
|
+
const observableCell = useObserve(cell);
|
|
321
|
+
|
|
322
|
+
const executable = ExecutableCellModel.is(observableCell.model);
|
|
323
|
+
const executeState =
|
|
324
|
+
ExecutableCellModel.is(observableCell.model) && !observableCell.model.executing
|
|
325
|
+
? observableCell.model.executeCount || ' '
|
|
326
|
+
: '*';
|
|
327
|
+
return (
|
|
328
|
+
<>
|
|
329
|
+
{executable && !isMouseOverDragArea && (
|
|
330
|
+
<div className="libro-execute-tooltip-area">
|
|
331
|
+
<pre className="libro-execute-state-tip">{`[${executeState}]:`}</pre>
|
|
332
|
+
</div>
|
|
333
|
+
)}
|
|
334
|
+
</>
|
|
335
|
+
);
|
|
336
|
+
});
|
|
337
|
+
|
|
338
|
+
export const DndCellItemContent = memo(function DndCellItemContent(props: {
|
|
339
|
+
cell: CellView;
|
|
340
|
+
}) {
|
|
341
|
+
const instance = useInject<LibroView>(ViewInstance);
|
|
342
|
+
const { cell } = props;
|
|
343
|
+
const observableCell = useObserve(cell);
|
|
344
|
+
const isCollapsible = CellCollapsible.is(observableCell);
|
|
345
|
+
const hasCellHidden = useMemo(() => {
|
|
346
|
+
return observableCell.hasCellHidden();
|
|
347
|
+
}, [observableCell]);
|
|
348
|
+
|
|
349
|
+
return (
|
|
350
|
+
<>
|
|
351
|
+
{hasCellHidden && <HideCellContent cell={observableCell} />}
|
|
352
|
+
{!hasCellHidden && (
|
|
353
|
+
<>
|
|
354
|
+
{instance.collapserVisible && isCollapsible && (
|
|
355
|
+
<div
|
|
356
|
+
className="libro-markdown-collapser"
|
|
357
|
+
onClick={() => {
|
|
358
|
+
instance.collapseCell(observableCell, !observableCell.headingCollapsed);
|
|
359
|
+
}}
|
|
360
|
+
>
|
|
361
|
+
{observableCell.headingCollapsed ? <ArrowRight /> : <ArrowDown />}
|
|
362
|
+
</div>
|
|
363
|
+
)}
|
|
364
|
+
<CellInput cell={observableCell} />
|
|
365
|
+
<CellOutput cell={observableCell} />
|
|
366
|
+
</>
|
|
367
|
+
)}
|
|
368
|
+
</>
|
|
369
|
+
);
|
|
370
|
+
});
|
|
371
|
+
|
|
372
|
+
export const DndCellItemContainer = memo(function DndCellItemContainer(
|
|
213
373
|
props: DndItemProps,
|
|
214
|
-
ref: React.ForwardedRef<HTMLDivElement>,
|
|
215
374
|
) {
|
|
216
375
|
const { isDrag, isMouseOverDragArea, cell } = props;
|
|
376
|
+
|
|
217
377
|
const [topToolbarVisible] = useConfigurationValue(CellTopToolbarSetting);
|
|
218
378
|
const [sideToolbarVisible] = useConfigurationValue(CellSideToolbarVisible);
|
|
219
379
|
|
|
220
380
|
const instance = useInject<LibroView>(ViewInstance);
|
|
221
381
|
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
382
|
const topToolbarArgs = useMemo(() => {
|
|
233
383
|
return [cell, instance, LibroToolbarArea.CellTop];
|
|
234
384
|
}, [cell, instance]);
|
|
@@ -236,12 +386,44 @@ export const DndCellItemRender = forwardRef(function DndCellItemRender(
|
|
|
236
386
|
const rightToolbarArgs = useMemo(() => {
|
|
237
387
|
return [cell, instance, LibroToolbarArea.CellRight];
|
|
238
388
|
}, [cell, instance]);
|
|
239
|
-
|
|
240
389
|
if (!isLibroCellModel(cell.model)) {
|
|
241
390
|
return null;
|
|
242
391
|
}
|
|
243
|
-
|
|
244
|
-
|
|
392
|
+
|
|
393
|
+
return (
|
|
394
|
+
<>
|
|
395
|
+
{topToolbarVisible && isActive && (
|
|
396
|
+
<div className="libro-cell-top-toolbar">
|
|
397
|
+
<ToolbarRender data={topToolbarArgs} />
|
|
398
|
+
</div>
|
|
399
|
+
)}
|
|
400
|
+
<ExecuteTooltipArea cell={cell} isMouseOverDragArea={isMouseOverDragArea} />
|
|
401
|
+
<DndCellItemContent cell={cell} />
|
|
402
|
+
{sideToolbarVisible && (
|
|
403
|
+
<div className="libro-cell-right-toolbar">
|
|
404
|
+
{isActive && !isDrag && instance.model.readOnly !== true && (
|
|
405
|
+
<ToolbarRender
|
|
406
|
+
data={rightToolbarArgs}
|
|
407
|
+
tooltip={{ placement: LibroToolbarArea.CellRight }}
|
|
408
|
+
/>
|
|
409
|
+
)}
|
|
410
|
+
</div>
|
|
411
|
+
)}
|
|
412
|
+
</>
|
|
413
|
+
);
|
|
414
|
+
});
|
|
415
|
+
const DndCellItemRenderInner = forwardRef(function DndCellItemRender(
|
|
416
|
+
props: DndItemProps,
|
|
417
|
+
ref: React.ForwardedRef<HTMLDivElement>,
|
|
418
|
+
) {
|
|
419
|
+
const { isDrag, isMouseOverDragArea, cell, isDragOver } = props;
|
|
420
|
+
const observableCell = useObserve(cell);
|
|
421
|
+
const instance = useInject<LibroView>(ViewInstance);
|
|
422
|
+
const isActive = instance.activeCell?.id === observableCell.id;
|
|
423
|
+
const hasErrorOutputs = hasErrorOutput(observableCell);
|
|
424
|
+
const hasCellHidden = useMemo(() => {
|
|
425
|
+
return observableCell.hasCellHidden();
|
|
426
|
+
}, [observableCell]);
|
|
245
427
|
|
|
246
428
|
const classNames = [
|
|
247
429
|
'libro-dnd-cell',
|
|
@@ -253,56 +435,21 @@ export const DndCellItemRender = forwardRef(function DndCellItemRender(
|
|
|
253
435
|
hidden: hasCellHidden,
|
|
254
436
|
},
|
|
255
437
|
];
|
|
256
|
-
if (
|
|
257
|
-
classNames.push(
|
|
438
|
+
if (observableCell.wrapperCls) {
|
|
439
|
+
classNames.push(observableCell.wrapperCls);
|
|
258
440
|
}
|
|
259
|
-
|
|
260
441
|
return (
|
|
261
|
-
<div
|
|
262
|
-
className={
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
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
|
-
)}
|
|
442
|
+
<div className="libro-dnd-cell-border">
|
|
443
|
+
<div className={classnames(classNames)} ref={ref}>
|
|
444
|
+
<DndCellItemContainer
|
|
445
|
+
cell={observableCell}
|
|
446
|
+
isDrag={isDrag}
|
|
447
|
+
isDragOver={isDragOver}
|
|
448
|
+
isMouseOverDragArea={isMouseOverDragArea}
|
|
449
|
+
// ref={ref}
|
|
450
|
+
/>
|
|
305
451
|
</div>
|
|
306
452
|
</div>
|
|
307
453
|
);
|
|
308
454
|
});
|
|
455
|
+
export const DndCellItemRender = memo(DndCellItemRenderInner);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
/* eslint-disable react-hooks/exhaustive-deps */
|
|
1
2
|
import { useInject, ViewInstance } from '@difizen/mana-app';
|
|
2
3
|
import { ViewRender } from '@difizen/mana-app';
|
|
3
|
-
import type {
|
|
4
|
+
import type { FC, CSSProperties } from 'react';
|
|
4
5
|
import { useState, useEffect, memo } from 'react';
|
|
5
6
|
import type { XYCoord } from 'react-dnd';
|
|
6
7
|
import { useDragLayer } from 'react-dnd';
|
|
@@ -49,10 +50,9 @@ const MultipleSelectionPreview: FC<{ activeCell: CellView }> = ({ activeCell })
|
|
|
49
50
|
setMultipleSelectionPreview(view);
|
|
50
51
|
return;
|
|
51
52
|
})
|
|
52
|
-
.catch(() => {
|
|
53
|
+
.catch((e) => {
|
|
53
54
|
//
|
|
54
55
|
});
|
|
55
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
56
56
|
}, []);
|
|
57
57
|
|
|
58
58
|
return (
|
|
@@ -86,10 +86,9 @@ const SingleSelectionDragPreview: FC<{ activeCell: CellView }> = ({ activeCell }
|
|
|
86
86
|
setSingleSelectionPreview(view);
|
|
87
87
|
return;
|
|
88
88
|
})
|
|
89
|
-
.catch(() => {
|
|
89
|
+
.catch((e) => {
|
|
90
90
|
//
|
|
91
91
|
});
|
|
92
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
93
92
|
}, []);
|
|
94
93
|
|
|
95
94
|
return (
|
|
@@ -103,7 +102,7 @@ export const SingleSelectionPreviewMemo: FC<SelectionPreviewProps> = memo(
|
|
|
103
102
|
SingleSelectionDragPreview,
|
|
104
103
|
);
|
|
105
104
|
|
|
106
|
-
export const CustomDragLayer
|
|
105
|
+
export const CustomDragLayer = () => {
|
|
107
106
|
const { isDragging, item, currentOffset } = useDragLayer((monitor) => ({
|
|
108
107
|
item: monitor.getItem(),
|
|
109
108
|
itemType: monitor.getItemType(),
|