@difizen/libro-core 0.1.1 → 0.1.3
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
package/src/libro-view.tsx
CHANGED
|
@@ -1,44 +1,53 @@
|
|
|
1
1
|
import { ToTopOutlined } from '@ant-design/icons';
|
|
2
|
-
import { concatMultilineString } from '@difizen/libro-common';
|
|
3
|
-
import { ConfigurationService, useConfigurationValue } from '@difizen/mana-app';
|
|
4
|
-
import { getOrigin, prop, watch } from '@difizen/mana-app';
|
|
5
|
-
import { Deferred, Disposable, DisposableCollection, Emitter } from '@difizen/mana-app';
|
|
6
2
|
import {
|
|
7
|
-
|
|
8
|
-
|
|
3
|
+
concatMultilineString,
|
|
4
|
+
copy2clipboard,
|
|
5
|
+
readFromClipboard,
|
|
6
|
+
} from '@difizen/libro-common';
|
|
7
|
+
import {
|
|
8
|
+
equals,
|
|
9
|
+
useInject,
|
|
10
|
+
inject,
|
|
11
|
+
transient,
|
|
9
12
|
BaseView,
|
|
13
|
+
Slot,
|
|
10
14
|
view,
|
|
11
15
|
ViewInstance,
|
|
16
|
+
ViewManager,
|
|
12
17
|
ViewOption,
|
|
18
|
+
Deferred,
|
|
19
|
+
Disposable,
|
|
20
|
+
DisposableCollection,
|
|
21
|
+
Emitter,
|
|
22
|
+
getOrigin,
|
|
23
|
+
prop,
|
|
24
|
+
watch,
|
|
25
|
+
ConfigurationService,
|
|
26
|
+
useConfigurationValue,
|
|
13
27
|
} from '@difizen/mana-app';
|
|
14
|
-
import {
|
|
15
|
-
import { Spin, Button, FloatButton } from 'antd';
|
|
28
|
+
import { BackTop, Button, Spin } from 'antd';
|
|
16
29
|
import type { FC, ForwardRefExoticComponent, RefAttributes } from 'react';
|
|
17
|
-
import {
|
|
30
|
+
import { forwardRef, memo, useCallback, useEffect, useRef } from 'react';
|
|
18
31
|
import { v4 } from 'uuid';
|
|
19
32
|
|
|
20
33
|
import {
|
|
21
34
|
CellService,
|
|
35
|
+
EditorCellView,
|
|
22
36
|
ExecutableCellModel,
|
|
23
37
|
ExecutableCellView,
|
|
24
|
-
EditorCellView,
|
|
25
38
|
} from './cell/index.js';
|
|
39
|
+
import type { LibroCell } from './cell/index.js';
|
|
40
|
+
import type { LibroCellModel } from './cell/libro-cell-model.js';
|
|
26
41
|
import { CollapseServiceFactory } from './collapse-service.js';
|
|
27
42
|
import type { CollapseService } from './collapse-service.js';
|
|
28
43
|
import {
|
|
29
44
|
CustomDragLayer,
|
|
30
|
-
|
|
45
|
+
DndCellContainer,
|
|
31
46
|
DndCellItemRender,
|
|
32
47
|
DndContext,
|
|
33
48
|
DndList,
|
|
34
49
|
} from './components/index.js';
|
|
35
50
|
import { LibroViewHeader } from './components/libro-view-header.js';
|
|
36
|
-
import {
|
|
37
|
-
AutoInsertWhenNoCell,
|
|
38
|
-
EnterEditModeWhenAddCell,
|
|
39
|
-
HeaderToolbarVisible,
|
|
40
|
-
RightContentFixed,
|
|
41
|
-
} from './configuration/libro-configuration.js';
|
|
42
51
|
import { LirboContextKey } from './libro-context-key.js';
|
|
43
52
|
import { LibroModel } from './libro-model.js';
|
|
44
53
|
import { NotebookService, notebookViewFactoryId } from './libro-protocol.js';
|
|
@@ -52,11 +61,25 @@ import type {
|
|
|
52
61
|
NotebookOption,
|
|
53
62
|
} from './libro-protocol.js';
|
|
54
63
|
import { LibroService } from './libro-service.js';
|
|
64
|
+
import {
|
|
65
|
+
AutoInsertWhenNoCell,
|
|
66
|
+
EnterEditModeWhenAddCell,
|
|
67
|
+
HeaderToolbarVisible,
|
|
68
|
+
RightContentFixed,
|
|
69
|
+
} from './libro-setting.js';
|
|
55
70
|
import { LibroSlotManager, LibroSlotView } from './slot/index.js';
|
|
71
|
+
import { VirtualizedManagerHelper } from './virtualized-manager-helper.js';
|
|
72
|
+
import type { VirtualizedManager } from './virtualized-manager.js';
|
|
56
73
|
import './index.less';
|
|
57
74
|
|
|
75
|
+
export interface ClipboardType {
|
|
76
|
+
action: 'copy' | 'cut';
|
|
77
|
+
cells: LibroCell[];
|
|
78
|
+
}
|
|
79
|
+
|
|
58
80
|
export const LibroContentComponent = memo(function LibroContentComponent() {
|
|
59
81
|
const libroSlotManager = useInject(LibroSlotManager);
|
|
82
|
+
const ref = useRef<HTMLDivElement | null>(null);
|
|
60
83
|
const libroViewTopRef = useRef<HTMLDivElement>(null);
|
|
61
84
|
const libroViewRightContentRef = useRef<HTMLDivElement>(null);
|
|
62
85
|
const libroViewLeftContentRef = useRef<HTMLDivElement>(null);
|
|
@@ -67,6 +90,7 @@ export const LibroContentComponent = memo(function LibroContentComponent() {
|
|
|
67
90
|
const [rightContentFixed] = useConfigurationValue(RightContentFixed);
|
|
68
91
|
|
|
69
92
|
const handleScroll = useCallback(() => {
|
|
93
|
+
instance.cellScrollEmitter.fire();
|
|
70
94
|
const cellRightToolbar = instance.container?.current?.getElementsByClassName(
|
|
71
95
|
'libro-cell-right-toolbar',
|
|
72
96
|
)[instance.model.activeIndex] as HTMLDivElement;
|
|
@@ -133,7 +157,7 @@ export const LibroContentComponent = memo(function LibroContentComponent() {
|
|
|
133
157
|
<div className="libro-view-content-left" ref={libroViewLeftContentRef}>
|
|
134
158
|
<DndContext>
|
|
135
159
|
<CustomDragLayer />
|
|
136
|
-
<DndList libroView={instance}>
|
|
160
|
+
<DndList libroView={instance} ref={ref}>
|
|
137
161
|
<Slot
|
|
138
162
|
name={libroSlotManager.getSlotName(instance, 'list')}
|
|
139
163
|
slotView={LibroSlotView}
|
|
@@ -148,11 +172,11 @@ export const LibroContentComponent = memo(function LibroContentComponent() {
|
|
|
148
172
|
slotView={LibroSlotView}
|
|
149
173
|
/>
|
|
150
174
|
</div>
|
|
151
|
-
<
|
|
175
|
+
<BackTop target={() => libroViewContentRef.current || document}>
|
|
152
176
|
<div className="libro-totop-button">
|
|
153
177
|
<Button shape="circle" icon={<ToTopOutlined />} />
|
|
154
178
|
</div>
|
|
155
|
-
</
|
|
179
|
+
</BackTop>
|
|
156
180
|
<Slot
|
|
157
181
|
name={libroSlotManager.getSlotName(instance, 'content')}
|
|
158
182
|
slotView={LibroSlotView}
|
|
@@ -166,74 +190,85 @@ export const LibroContentComponent = memo(function LibroContentComponent() {
|
|
|
166
190
|
);
|
|
167
191
|
});
|
|
168
192
|
|
|
169
|
-
export const LibroRender = forwardRef<HTMLDivElement>(
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
const libroService = useInject(LibroService);
|
|
193
|
+
export const LibroRender = forwardRef<HTMLDivElement>(function LibroRender(props, ref) {
|
|
194
|
+
const instance = useInject<LibroView>(ViewInstance);
|
|
195
|
+
const libroService = useInject(LibroService);
|
|
173
196
|
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
197
|
+
const handleMouseDown = useCallback(
|
|
198
|
+
(e: React.MouseEvent<HTMLDivElement>) => {
|
|
199
|
+
if (e.defaultPrevented) {
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
202
|
+
if (!instance.model.commandMode) {
|
|
203
|
+
instance.enterCommandMode(true);
|
|
204
|
+
}
|
|
205
|
+
},
|
|
206
|
+
[instance],
|
|
207
|
+
);
|
|
185
208
|
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
209
|
+
const handFocus = useCallback(
|
|
210
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
211
|
+
(e: React.FocusEvent<HTMLDivElement>) => {
|
|
212
|
+
if (!equals(libroService.active, instance)) {
|
|
213
|
+
libroService.active = instance;
|
|
214
|
+
}
|
|
215
|
+
if (!equals(libroService.focus, instance)) {
|
|
216
|
+
libroService.focus = instance;
|
|
217
|
+
}
|
|
218
|
+
},
|
|
219
|
+
[instance, libroService],
|
|
220
|
+
);
|
|
198
221
|
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
222
|
+
const handBlur = useCallback(
|
|
223
|
+
(e: React.FocusEvent<HTMLDivElement>) => {
|
|
224
|
+
if (typeof ref === 'function') {
|
|
225
|
+
return;
|
|
226
|
+
}
|
|
227
|
+
if (ref?.current?.contains(e.relatedTarget)) {
|
|
228
|
+
const dndDom = ref?.current?.getElementsByClassName(
|
|
229
|
+
'libro-dnd-cells-container',
|
|
230
|
+
)[0];
|
|
231
|
+
if (!dndDom?.contains(e.relatedTarget) && instance.model.readOnly) {
|
|
232
|
+
instance.selectCell(undefined);
|
|
205
233
|
}
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
|
|
234
|
+
} else {
|
|
235
|
+
instance.enterCommandMode(false);
|
|
236
|
+
libroService.focus = undefined;
|
|
237
|
+
instance.onBlurEmitter.fire('');
|
|
238
|
+
if (instance.model.readOnly) {
|
|
239
|
+
instance.selectCell(undefined);
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
},
|
|
243
|
+
[instance, libroService, ref],
|
|
244
|
+
);
|
|
209
245
|
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
);
|
|
246
|
+
return (
|
|
247
|
+
<div
|
|
248
|
+
className={`${instance.model.libroViewClass} libro-view`}
|
|
249
|
+
onMouseDown={handleMouseDown}
|
|
250
|
+
ref={ref}
|
|
251
|
+
tabIndex={0}
|
|
252
|
+
onFocus={handFocus}
|
|
253
|
+
onBlur={handBlur}
|
|
254
|
+
>
|
|
255
|
+
<LibroContentComponent />
|
|
256
|
+
</div>
|
|
257
|
+
);
|
|
258
|
+
});
|
|
224
259
|
|
|
225
260
|
@transient()
|
|
226
261
|
@view(notebookViewFactoryId)
|
|
227
262
|
export class LibroView extends BaseView implements NotebookView {
|
|
228
263
|
protected override toDispose = new DisposableCollection();
|
|
229
264
|
model: NotebookModel;
|
|
230
|
-
headerRender: FC = LibroViewHeader;
|
|
231
|
-
loadingRender: FC = () => (
|
|
265
|
+
headerRender: FC<any> = LibroViewHeader;
|
|
266
|
+
loadingRender: FC<any> = () => (
|
|
232
267
|
<div className="libro-loading">
|
|
233
268
|
<Spin />
|
|
234
269
|
</div>
|
|
235
270
|
);
|
|
236
|
-
dndContentRender: FC<DndContentProps> =
|
|
271
|
+
dndContentRender: FC<DndContentProps> = DndCellContainer;
|
|
237
272
|
dndItemRender: ForwardRefExoticComponent<
|
|
238
273
|
DndItemProps & RefAttributes<HTMLDivElement>
|
|
239
274
|
> = DndCellItemRender;
|
|
@@ -254,6 +289,9 @@ export class LibroView extends BaseView implements NotebookView {
|
|
|
254
289
|
|
|
255
290
|
@inject(ViewManager) protected viewManager: ViewManager;
|
|
256
291
|
@inject(ConfigurationService) protected configurationService: ConfigurationService;
|
|
292
|
+
|
|
293
|
+
protected virtualizedManager: VirtualizedManager;
|
|
294
|
+
protected virtualizedManagerHelper: VirtualizedManagerHelper;
|
|
257
295
|
protected notebookService: NotebookService;
|
|
258
296
|
protected collapseService: CollapseService;
|
|
259
297
|
isDragging = false;
|
|
@@ -261,6 +299,9 @@ export class LibroView extends BaseView implements NotebookView {
|
|
|
261
299
|
@prop()
|
|
262
300
|
collapserVisible = false;
|
|
263
301
|
|
|
302
|
+
@prop()
|
|
303
|
+
outputsScroll = false;
|
|
304
|
+
|
|
264
305
|
get hasModal() {
|
|
265
306
|
return this.model.cells.some((item) => item.hasModal);
|
|
266
307
|
}
|
|
@@ -278,6 +319,11 @@ export class LibroView extends BaseView implements NotebookView {
|
|
|
278
319
|
return this.runCellEmitter.event;
|
|
279
320
|
}
|
|
280
321
|
|
|
322
|
+
cellScrollEmitter = new Emitter<void>();
|
|
323
|
+
get onCellScroll() {
|
|
324
|
+
return this.cellScrollEmitter.event;
|
|
325
|
+
}
|
|
326
|
+
|
|
281
327
|
protected initializedDefer = new Deferred<void>();
|
|
282
328
|
|
|
283
329
|
get initialized() {
|
|
@@ -288,6 +334,8 @@ export class LibroView extends BaseView implements NotebookView {
|
|
|
288
334
|
@inject(ViewOption) options: NotebookOption,
|
|
289
335
|
@inject(CollapseServiceFactory) collapseServiceFactory: CollapseServiceFactory,
|
|
290
336
|
@inject(NotebookService) notebookService: NotebookService,
|
|
337
|
+
@inject(VirtualizedManagerHelper)
|
|
338
|
+
virtualizedManagerHelper: VirtualizedManagerHelper,
|
|
291
339
|
) {
|
|
292
340
|
super();
|
|
293
341
|
if (options.id) {
|
|
@@ -297,6 +345,8 @@ export class LibroView extends BaseView implements NotebookView {
|
|
|
297
345
|
this.model = this.notebookService.getOrCreateModel(options);
|
|
298
346
|
this.collapseService = collapseServiceFactory({ view: this });
|
|
299
347
|
this.collapserVisible = this.collapseService.collapserVisible;
|
|
348
|
+
this.virtualizedManagerHelper = virtualizedManagerHelper;
|
|
349
|
+
this.virtualizedManager = virtualizedManagerHelper.getOrCreate(this.model);
|
|
300
350
|
|
|
301
351
|
this.initialize();
|
|
302
352
|
this.initView();
|
|
@@ -331,7 +381,7 @@ export class LibroView extends BaseView implements NotebookView {
|
|
|
331
381
|
}
|
|
332
382
|
return;
|
|
333
383
|
})
|
|
334
|
-
.catch(() => {
|
|
384
|
+
.catch((e) => {
|
|
335
385
|
//
|
|
336
386
|
});
|
|
337
387
|
await this.insertCells(options);
|
|
@@ -350,12 +400,13 @@ export class LibroView extends BaseView implements NotebookView {
|
|
|
350
400
|
}
|
|
351
401
|
return;
|
|
352
402
|
})
|
|
353
|
-
.catch(() => {
|
|
403
|
+
.catch((e) => {
|
|
354
404
|
//
|
|
355
405
|
});
|
|
356
406
|
this.toDispose.push(
|
|
357
407
|
watch(this.model, 'cells', () => {
|
|
358
408
|
this.model.onChange?.();
|
|
409
|
+
this.model.onSourceChange?.();
|
|
359
410
|
}),
|
|
360
411
|
);
|
|
361
412
|
this.initializedDefer.resolve();
|
|
@@ -367,6 +418,13 @@ export class LibroView extends BaseView implements NotebookView {
|
|
|
367
418
|
override onViewMount = () => {
|
|
368
419
|
this.libroService.active = this;
|
|
369
420
|
this.libroSlotManager.setup(this);
|
|
421
|
+
|
|
422
|
+
// this.libroService.libroPerformanceStatistics.setRenderEnd(new Date());
|
|
423
|
+
|
|
424
|
+
// console.log(
|
|
425
|
+
// '[performance] render Time: ',
|
|
426
|
+
// this.libroService.libroPerformanceStatistics.getRenderTime(),
|
|
427
|
+
// );
|
|
370
428
|
};
|
|
371
429
|
|
|
372
430
|
override onViewUnmount = () => {
|
|
@@ -411,7 +469,7 @@ export class LibroView extends BaseView implements NotebookView {
|
|
|
411
469
|
this.model.insertCells(cellView, position);
|
|
412
470
|
};
|
|
413
471
|
|
|
414
|
-
selectCell = (cell
|
|
472
|
+
selectCell = (cell?: CellView) => {
|
|
415
473
|
this.model.active = cell;
|
|
416
474
|
this.model.selectCell(cell);
|
|
417
475
|
};
|
|
@@ -430,6 +488,10 @@ export class LibroView extends BaseView implements NotebookView {
|
|
|
430
488
|
return this.model.active;
|
|
431
489
|
}
|
|
432
490
|
|
|
491
|
+
get activeCellIndex(): number {
|
|
492
|
+
return this.model.activeIndex;
|
|
493
|
+
}
|
|
494
|
+
|
|
433
495
|
findCellIndex = (cell: CellView) => {
|
|
434
496
|
const cellList = this.model.getCells();
|
|
435
497
|
if (cell) {
|
|
@@ -465,7 +527,7 @@ export class LibroView extends BaseView implements NotebookView {
|
|
|
465
527
|
}
|
|
466
528
|
return;
|
|
467
529
|
})
|
|
468
|
-
.catch(() => {
|
|
530
|
+
.catch((e) => {
|
|
469
531
|
//
|
|
470
532
|
});
|
|
471
533
|
} else {
|
|
@@ -486,7 +548,7 @@ export class LibroView extends BaseView implements NotebookView {
|
|
|
486
548
|
}
|
|
487
549
|
return;
|
|
488
550
|
})
|
|
489
|
-
.catch(() => {
|
|
551
|
+
.catch((e) => {
|
|
490
552
|
//
|
|
491
553
|
});
|
|
492
554
|
}
|
|
@@ -565,14 +627,11 @@ export class LibroView extends BaseView implements NotebookView {
|
|
|
565
627
|
this.enterEditMode();
|
|
566
628
|
return;
|
|
567
629
|
})
|
|
568
|
-
.catch(() => {
|
|
630
|
+
.catch((e) => {
|
|
569
631
|
//
|
|
570
632
|
});
|
|
571
633
|
}
|
|
572
634
|
this.runCells(toRunCells);
|
|
573
|
-
if (this.activeCell) {
|
|
574
|
-
this.model.scrollToView(this.activeCell);
|
|
575
|
-
}
|
|
576
635
|
} else {
|
|
577
636
|
const selectIndex = this.findCellIndex(cell);
|
|
578
637
|
if (selectIndex >= 0 && selectIndex < this.model.cells.length - 1) {
|
|
@@ -587,14 +646,24 @@ export class LibroView extends BaseView implements NotebookView {
|
|
|
587
646
|
this.enterEditMode();
|
|
588
647
|
return;
|
|
589
648
|
})
|
|
590
|
-
.catch(() => {
|
|
649
|
+
.catch((e) => {
|
|
591
650
|
//
|
|
592
651
|
});
|
|
593
652
|
}
|
|
594
653
|
this.runCells([cell]);
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
654
|
+
}
|
|
655
|
+
if (this.virtualizedManager.isVirtualized) {
|
|
656
|
+
setTimeout(() => {
|
|
657
|
+
if (this.activeCell) {
|
|
658
|
+
this.model.scrollToCellView({ cellIndex: this.activeCellIndex });
|
|
659
|
+
}
|
|
660
|
+
});
|
|
661
|
+
} else {
|
|
662
|
+
setTimeout(() => {
|
|
663
|
+
if (this.activeCell) {
|
|
664
|
+
this.model.scrollToView(this.activeCell);
|
|
665
|
+
}
|
|
666
|
+
});
|
|
598
667
|
}
|
|
599
668
|
};
|
|
600
669
|
|
|
@@ -684,62 +753,61 @@ export class LibroView extends BaseView implements NotebookView {
|
|
|
684
753
|
|
|
685
754
|
copyCell = (cell: CellView) => {
|
|
686
755
|
if (this.model.selections.length !== 0 && this.isSelected(cell)) {
|
|
687
|
-
|
|
688
|
-
|
|
756
|
+
const clipboard: ClipboardType = {
|
|
757
|
+
action: 'copy',
|
|
758
|
+
cells: this.model.selections.map((selection) => selection.toJSONWithoutId()),
|
|
759
|
+
};
|
|
760
|
+
copy2clipboard(JSON.stringify(clipboard));
|
|
689
761
|
} else {
|
|
690
|
-
|
|
762
|
+
const clipboard: ClipboardType = {
|
|
763
|
+
action: 'copy',
|
|
764
|
+
cells: [cell.toJSONWithoutId()],
|
|
765
|
+
};
|
|
766
|
+
copy2clipboard(JSON.stringify(clipboard));
|
|
691
767
|
}
|
|
692
|
-
this.model.lastClipboardInteraction = 'copy';
|
|
693
768
|
};
|
|
694
769
|
|
|
695
770
|
cutCell = (cell: CellView) => {
|
|
696
771
|
if (this.model.selections.length !== 0 && this.isSelected(cell)) {
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
772
|
+
const clipboard: ClipboardType = {
|
|
773
|
+
action: 'cut',
|
|
774
|
+
cells: this.model.selections.map((selection) => selection.toJSONWithoutId()),
|
|
775
|
+
};
|
|
776
|
+
copy2clipboard(JSON.stringify(clipboard));
|
|
777
|
+
for (const cutCell of this.model.selections) {
|
|
700
778
|
this.deleteCell(cutCell);
|
|
701
779
|
}
|
|
702
780
|
} else {
|
|
703
|
-
|
|
781
|
+
const clipboard: ClipboardType = {
|
|
782
|
+
action: 'cut',
|
|
783
|
+
cells: [cell.toJSONWithoutId()],
|
|
784
|
+
};
|
|
785
|
+
copy2clipboard(JSON.stringify(clipboard));
|
|
786
|
+
|
|
704
787
|
this.deleteCell(cell);
|
|
705
788
|
}
|
|
706
|
-
this.model.lastClipboardInteraction = 'cut';
|
|
707
789
|
};
|
|
708
790
|
|
|
709
|
-
pasteCell = (cell: CellView) => {
|
|
710
|
-
|
|
791
|
+
pasteCell = async (cell: CellView) => {
|
|
792
|
+
const pasteIndex = this.model.getCells().findIndex((item) => {
|
|
711
793
|
return equals(item, cell);
|
|
712
794
|
});
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
}
|
|
727
|
-
} else {
|
|
728
|
-
const cellOptions = pasteCells.toJSONWithoutId();
|
|
729
|
-
this.addCell({ id: v4(), cell: cellOptions }, pasteIndex + 1);
|
|
730
|
-
}
|
|
731
|
-
} else {
|
|
732
|
-
if (Array.isArray(pasteCells)) {
|
|
733
|
-
for (const pasteCell of pasteCells) {
|
|
734
|
-
this.model.addCell(pasteCell, pasteIndex + 1);
|
|
735
|
-
this.model.deletedCells.splice(this.model.deletedCells.indexOf(pasteCell), 1);
|
|
736
|
-
pasteIndex++;
|
|
737
|
-
}
|
|
738
|
-
} else {
|
|
739
|
-
this.model.addCell(pasteCells, pasteIndex + 1);
|
|
740
|
-
this.model.deletedCells.splice(this.model.deletedCells.indexOf(pasteCells), 1);
|
|
795
|
+
try {
|
|
796
|
+
const pasteValue = JSON.parse(await readFromClipboard()) as ClipboardType;
|
|
797
|
+
if (pasteValue.action === 'copy' || pasteValue.action === 'cut') {
|
|
798
|
+
this.insertCells(
|
|
799
|
+
pasteValue.cells.map((item) => {
|
|
800
|
+
return {
|
|
801
|
+
id: v4(),
|
|
802
|
+
cell: item,
|
|
803
|
+
};
|
|
804
|
+
}),
|
|
805
|
+
pasteIndex + 1,
|
|
806
|
+
);
|
|
807
|
+
return;
|
|
741
808
|
}
|
|
742
|
-
|
|
809
|
+
} catch (e) {
|
|
810
|
+
console.error(e);
|
|
743
811
|
}
|
|
744
812
|
};
|
|
745
813
|
|
|
@@ -748,10 +816,7 @@ export class LibroView extends BaseView implements NotebookView {
|
|
|
748
816
|
return equals(item, cell);
|
|
749
817
|
});
|
|
750
818
|
const pasteCells = getOrigin(this.model.clipboard);
|
|
751
|
-
if (!this.model.lastClipboardInteraction) {
|
|
752
|
-
return;
|
|
753
|
-
}
|
|
754
|
-
if (!pasteCells) {
|
|
819
|
+
if (!this.model.lastClipboardInteraction || !pasteCells) {
|
|
755
820
|
return;
|
|
756
821
|
}
|
|
757
822
|
if (this.model.lastClipboardInteraction === 'copy') {
|
|
@@ -787,15 +852,31 @@ export class LibroView extends BaseView implements NotebookView {
|
|
|
787
852
|
if (this.model.selections.length !== 0 && this.isSelected(cell)) {
|
|
788
853
|
for (const selectedCell of this.model.selections) {
|
|
789
854
|
const cellOptions: CellOptions = {
|
|
790
|
-
cell: {
|
|
855
|
+
cell: {
|
|
856
|
+
cell_type: type,
|
|
857
|
+
source: selectedCell.model.source,
|
|
858
|
+
metadata: {
|
|
859
|
+
...selectedCell.model.metadata,
|
|
860
|
+
libroFormatter: (selectedCell.model as LibroCellModel).libroFormatType,
|
|
861
|
+
},
|
|
862
|
+
},
|
|
791
863
|
};
|
|
792
864
|
const cellView = await this.getCellViewByOption(cellOptions);
|
|
793
865
|
this.model.invertCell(cellView, cellIndex);
|
|
794
866
|
}
|
|
795
867
|
} else {
|
|
796
868
|
const cellOptions: CellOptions = {
|
|
797
|
-
cell: {
|
|
869
|
+
cell: {
|
|
870
|
+
cell_type: type,
|
|
871
|
+
source: cell.model.source,
|
|
872
|
+
metadata: {
|
|
873
|
+
...cell.model.metadata,
|
|
874
|
+
libroFormatter: (cell.model as LibroCellModel).libroFormatType,
|
|
875
|
+
libroCellType: type,
|
|
876
|
+
},
|
|
877
|
+
},
|
|
798
878
|
};
|
|
879
|
+
|
|
799
880
|
const cellView = await this.getCellViewByOption(cellOptions);
|
|
800
881
|
this.model.invertCell(cellView, cellIndex);
|
|
801
882
|
}
|
|
@@ -809,21 +890,27 @@ export class LibroView extends BaseView implements NotebookView {
|
|
|
809
890
|
ExecutableCellModel.is(selectedCell.model)
|
|
810
891
|
) {
|
|
811
892
|
selectedCell.clearExecution();
|
|
893
|
+
selectedCell.model.executing = false;
|
|
812
894
|
selectedCell.model.hasOutputHidden = false;
|
|
813
895
|
}
|
|
814
896
|
}
|
|
815
897
|
} else {
|
|
816
898
|
if (ExecutableCellView.is(cell) && ExecutableCellModel.is(cell.model)) {
|
|
817
899
|
cell.clearExecution();
|
|
900
|
+
cell.model.executing = false;
|
|
818
901
|
cell.model.hasOutputHidden = false;
|
|
819
902
|
}
|
|
820
903
|
}
|
|
821
904
|
};
|
|
822
905
|
|
|
823
906
|
clearAllOutputs = () => {
|
|
907
|
+
if (this.virtualizedManager.isVirtualized) {
|
|
908
|
+
this.model.scrollToCellView({ cellIndex: 0 });
|
|
909
|
+
} // 清空所有 cell滚动到最上面
|
|
824
910
|
for (const cell of this.model.cells) {
|
|
825
911
|
if (ExecutableCellView.is(cell) && ExecutableCellModel.is(cell.model)) {
|
|
826
912
|
cell.clearExecution();
|
|
913
|
+
cell.model.executing = false;
|
|
827
914
|
cell.model.hasOutputHidden = false;
|
|
828
915
|
}
|
|
829
916
|
}
|
|
@@ -933,7 +1020,7 @@ export class LibroView extends BaseView implements NotebookView {
|
|
|
933
1020
|
* Whether a cell is selected.
|
|
934
1021
|
*/
|
|
935
1022
|
isSelected(cell: CellView): boolean {
|
|
936
|
-
if (this.activeCell
|
|
1023
|
+
if (equals(this.activeCell, cell)) {
|
|
937
1024
|
return true;
|
|
938
1025
|
}
|
|
939
1026
|
if (this.model.selections.length !== 0) {
|
|
@@ -954,7 +1041,11 @@ export class LibroView extends BaseView implements NotebookView {
|
|
|
954
1041
|
if (this.findCellIndex(this.activeCell) > 0) {
|
|
955
1042
|
this.extendContiguousSelectionTo(activeIndex - 1);
|
|
956
1043
|
}
|
|
957
|
-
this.
|
|
1044
|
+
if (this.virtualizedManager.isVirtualized) {
|
|
1045
|
+
this.model.scrollToCellView({ cellIndex: this.activeCellIndex });
|
|
1046
|
+
} else {
|
|
1047
|
+
this.model.scrollToView(this.activeCell);
|
|
1048
|
+
}
|
|
958
1049
|
}
|
|
959
1050
|
};
|
|
960
1051
|
|
|
@@ -963,7 +1054,11 @@ export class LibroView extends BaseView implements NotebookView {
|
|
|
963
1054
|
if (this.findCellIndex(this.activeCell) > 0) {
|
|
964
1055
|
this.extendContiguousSelectionTo(0);
|
|
965
1056
|
}
|
|
966
|
-
this.
|
|
1057
|
+
if (this.virtualizedManager.isVirtualized) {
|
|
1058
|
+
this.model.scrollToCellView({ cellIndex: this.activeCellIndex });
|
|
1059
|
+
} else {
|
|
1060
|
+
this.model.scrollToView(this.activeCell);
|
|
1061
|
+
}
|
|
967
1062
|
}
|
|
968
1063
|
};
|
|
969
1064
|
|
|
@@ -977,7 +1072,11 @@ export class LibroView extends BaseView implements NotebookView {
|
|
|
977
1072
|
if (this.findCellIndex(this.activeCell) >= 0) {
|
|
978
1073
|
this.extendContiguousSelectionTo(activeIndex + 1);
|
|
979
1074
|
}
|
|
980
|
-
this.
|
|
1075
|
+
if (this.virtualizedManager.isVirtualized) {
|
|
1076
|
+
this.model.scrollToCellView({ cellIndex: this.activeCellIndex });
|
|
1077
|
+
} else {
|
|
1078
|
+
this.model.scrollToView(this.activeCell);
|
|
1079
|
+
}
|
|
981
1080
|
}
|
|
982
1081
|
};
|
|
983
1082
|
|
|
@@ -986,7 +1085,11 @@ export class LibroView extends BaseView implements NotebookView {
|
|
|
986
1085
|
if (this.findCellIndex(this.activeCell) > 0) {
|
|
987
1086
|
this.extendContiguousSelectionTo(this.model.cells.length - 1);
|
|
988
1087
|
}
|
|
989
|
-
this.
|
|
1088
|
+
if (this.virtualizedManager.isVirtualized) {
|
|
1089
|
+
this.model.scrollToCellView({ cellIndex: this.activeCellIndex });
|
|
1090
|
+
} else {
|
|
1091
|
+
this.model.scrollToView(this.activeCell);
|
|
1092
|
+
}
|
|
990
1093
|
}
|
|
991
1094
|
};
|
|
992
1095
|
|
|
@@ -1090,6 +1193,7 @@ export class LibroView extends BaseView implements NotebookView {
|
|
|
1090
1193
|
};
|
|
1091
1194
|
|
|
1092
1195
|
disableOutputScrolling = (cell: CellView) => {
|
|
1196
|
+
this.outputsScroll = false;
|
|
1093
1197
|
if (this.model.selections.length !== 0 && this.isSelected(cell)) {
|
|
1094
1198
|
for (const selectedCell of this.model.selections) {
|
|
1095
1199
|
if (ExecutableCellModel.is(selectedCell.model)) {
|
|
@@ -1103,6 +1207,24 @@ export class LibroView extends BaseView implements NotebookView {
|
|
|
1103
1207
|
}
|
|
1104
1208
|
};
|
|
1105
1209
|
|
|
1210
|
+
disableAllOutputScrolling = () => {
|
|
1211
|
+
this.outputsScroll = false;
|
|
1212
|
+
for (const cell of this.model.cells) {
|
|
1213
|
+
if (ExecutableCellModel.is(cell.model)) {
|
|
1214
|
+
cell.model.hasOutputsScrolled = false;
|
|
1215
|
+
}
|
|
1216
|
+
}
|
|
1217
|
+
};
|
|
1218
|
+
|
|
1219
|
+
enableAllOutputScrolling = () => {
|
|
1220
|
+
this.outputsScroll = true;
|
|
1221
|
+
for (const cell of this.model.cells) {
|
|
1222
|
+
if (ExecutableCellModel.is(cell.model)) {
|
|
1223
|
+
cell.model.hasOutputsScrolled = true;
|
|
1224
|
+
}
|
|
1225
|
+
}
|
|
1226
|
+
};
|
|
1227
|
+
|
|
1106
1228
|
disposed = false;
|
|
1107
1229
|
|
|
1108
1230
|
override dispose() {
|
|
@@ -1136,7 +1258,11 @@ export class LibroView extends BaseView implements NotebookView {
|
|
|
1136
1258
|
if (newSelectedCell) {
|
|
1137
1259
|
this.model.selectCell(newSelectedCell);
|
|
1138
1260
|
this.model.selections = [];
|
|
1139
|
-
this.
|
|
1261
|
+
if (this.virtualizedManager.isVirtualized) {
|
|
1262
|
+
this.model.scrollToCellView({ cellIndex: this.activeCellIndex });
|
|
1263
|
+
} else {
|
|
1264
|
+
this.model.scrollToView(newSelectedCell);
|
|
1265
|
+
}
|
|
1140
1266
|
}
|
|
1141
1267
|
};
|
|
1142
1268
|
|
|
@@ -1145,7 +1271,11 @@ export class LibroView extends BaseView implements NotebookView {
|
|
|
1145
1271
|
if (newSelectedCell) {
|
|
1146
1272
|
this.model.selectCell(newSelectedCell);
|
|
1147
1273
|
this.model.selections = [];
|
|
1148
|
-
this.
|
|
1274
|
+
if (this.virtualizedManager.isVirtualized) {
|
|
1275
|
+
this.model.scrollToCellView({ cellIndex: this.activeCellIndex });
|
|
1276
|
+
} else {
|
|
1277
|
+
this.model.scrollToView(newSelectedCell);
|
|
1278
|
+
}
|
|
1149
1279
|
}
|
|
1150
1280
|
};
|
|
1151
1281
|
|
|
@@ -1254,12 +1384,14 @@ export class LibroView extends BaseView implements NotebookView {
|
|
|
1254
1384
|
splitCell = async (cell: CellView) => {
|
|
1255
1385
|
const index = this.findCellIndex(cell);
|
|
1256
1386
|
if (EditorCellView.is(cell)) {
|
|
1257
|
-
const selections = cell.getSelections();
|
|
1387
|
+
const selections = cell.editor?.getSelections() ?? [];
|
|
1258
1388
|
const offsets = [0];
|
|
1259
1389
|
for (let i = 0; i < selections.length; i++) {
|
|
1260
1390
|
// append start and end to handle selections
|
|
1261
1391
|
// cursors will have same start and end
|
|
1262
|
-
const
|
|
1392
|
+
const select = selections[i];
|
|
1393
|
+
const start = cell.editor?.getOffsetAt(select.start) ?? 0;
|
|
1394
|
+
const end = cell.editor?.getOffsetAt(select.end) ?? 0;
|
|
1263
1395
|
if (start < end) {
|
|
1264
1396
|
offsets.push(start);
|
|
1265
1397
|
offsets.push(end);
|