@difizen/libro-core 0.0.0-snapshot-20241017072317
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 +280 -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 +11 -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 +59 -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 +121 -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 +12 -0
- package/es/cell/libro-cell-contribution.d.ts.map +1 -0
- package/es/cell/libro-cell-contribution.js +47 -0
- package/es/cell/libro-cell-model.d.ts +29 -0
- package/es/cell/libro-cell-model.d.ts.map +1 -0
- package/es/cell/libro-cell-model.js +130 -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 +44 -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 +245 -0
- package/es/cell/libro-cell-view.d.ts +74 -0
- package/es/cell/libro-cell-view.d.ts.map +1 -0
- package/es/cell/libro-cell-view.js +239 -0
- package/es/cell/libro-edit-cell-view.d.ts +44 -0
- package/es/cell/libro-edit-cell-view.d.ts.map +1 -0
- package/es/cell/libro-edit-cell-view.js +256 -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 +34 -0
- package/es/cell/libro-executable-cell-view.d.ts.map +1 -0
- package/es/cell/libro-executable-cell-view.js +74 -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 +5 -0
- package/es/command/document-commands.d.ts.map +1 -0
- package/es/command/document-commands.js +21 -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 +40 -0
- package/es/command/libro-command-contribution.d.ts +13 -0
- package/es/command/libro-command-contribution.d.ts.map +1 -0
- package/es/command/libro-command-contribution.js +1842 -0
- package/es/command/libro-command-register.d.ts +21 -0
- package/es/command/libro-command-register.d.ts.map +1 -0
- package/es/command/libro-command-register.js +111 -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 +472 -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 +16 -0
- package/es/components/dnd-cell-item-render.d.ts.map +1 -0
- package/es/components/dnd-cell-item-render.js +364 -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 +140 -0
- package/es/components/dnd-component/default-dnd-content.d.ts +11 -0
- package/es/components/dnd-component/default-dnd-content.d.ts.map +1 -0
- package/es/components/dnd-component/default-dnd-content.js +292 -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 +14 -0
- package/es/components/dnd-component/dnd-list.d.ts.map +1 -0
- package/es/components/dnd-component/dnd-list.js +182 -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/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 +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/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 +6 -0
- package/es/content/index.d.ts.map +1 -0
- package/es/content/index.js +5 -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 +31 -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 +6 -0
- package/es/content/libro-content-protocol.d.ts +13 -0
- package/es/content/libro-content-protocol.d.ts.map +1 -0
- package/es/content/libro-content-protocol.js +3 -0
- package/es/content/libro-content-service.d.ts +11 -0
- package/es/content/libro-content-service.d.ts.map +1 -0
- package/es/content/libro-content-service.js +63 -0
- 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 +26 -0
- package/es/index.d.ts.map +1 -0
- package/es/index.js +25 -0
- package/es/index.less +781 -0
- package/es/libro-context-key.d.ts +26 -0
- package/es/libro-context-key.d.ts.map +1 -0
- package/es/libro-context-key.js +84 -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 +145 -0
- package/es/libro-model.d.ts.map +1 -0
- package/es/libro-model.js +921 -0
- package/es/libro-protocol.d.ts +315 -0
- package/es/libro-protocol.d.ts.map +1 -0
- package/es/libro-protocol.js +47 -0
- package/es/libro-service.d.ts +69 -0
- package/es/libro-service.d.ts.map +1 -0
- package/es/libro-service.js +303 -0
- package/es/libro-setting-contribution.d.ts +5 -0
- package/es/libro-setting-contribution.d.ts.map +1 -0
- package/es/libro-setting-contribution.js +23 -0
- package/es/libro-setting.d.ts +12 -0
- package/es/libro-setting.d.ts.map +1 -0
- package/es/libro-setting.js +101 -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 +170 -0
- package/es/libro-view.d.ts.map +1 -0
- package/es/libro-view.js +2077 -0
- package/es/libro-workspace-service.d.ts +17 -0
- package/es/libro-workspace-service.d.ts.map +1 -0
- package/es/libro-workspace-service.js +36 -0
- package/es/material-from-designer.d.ts +31 -0
- package/es/material-from-designer.d.ts.map +1 -0
- package/es/material-from-designer.js +697 -0
- package/es/module.d.ts +3 -0
- package/es/module.d.ts.map +1 -0
- package/es/module.js +71 -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 +399 -0
- package/es/output/output-contribution.d.ts +10 -0
- package/es/output/output-contribution.d.ts.map +1 -0
- package/es/output/output-contribution.js +36 -0
- package/es/output/output-model.d.ts +28 -0
- package/es/output/output-model.d.ts.map +1 -0
- package/es/output/output-model.js +105 -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 +134 -0
- package/es/output/output-protocol.d.ts.map +1 -0
- package/es/output/output-protocol.js +16 -0
- 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 +11 -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 +87 -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/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 +66 -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 +515 -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/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 +51 -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 +9 -0
- package/es/toolbar/libro-toolbar.d.ts.map +1 -0
- package/es/toolbar/libro-toolbar.js +275 -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 +5 -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 +5 -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/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 +23 -0
- package/es/virtualized-manager.d.ts.map +1 -0
- package/es/virtualized-manager.js +65 -0
- package/package.json +73 -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 +28 -0
- package/src/add-cell/libro-add-cell-view.tsx +99 -0
- package/src/cell/README.md +14 -0
- package/src/cell/index.ts +9 -0
- package/src/cell/libro-cell-contribution.ts +34 -0
- package/src/cell/libro-cell-model.ts +119 -0
- package/src/cell/libro-cell-module.ts +40 -0
- package/src/cell/libro-cell-protocol.ts +55 -0
- package/src/cell/libro-cell-service.ts +158 -0
- package/src/cell/libro-cell-view.tsx +156 -0
- package/src/cell/libro-edit-cell-view.tsx +205 -0
- package/src/cell/libro-executable-cell-model.ts +32 -0
- package/src/cell/libro-executable-cell-view.ts +86 -0
- package/src/cell/libro-markdown-cell-model.ts +20 -0
- package/src/collapse-service.ts +69 -0
- package/src/command/document-commands.ts +24 -0
- package/src/command/index.ts +6 -0
- package/src/command/kernel-command.ts +42 -0
- package/src/command/libro-command-contribution.ts +1346 -0
- package/src/command/libro-command-register.ts +168 -0
- package/src/command/module.ts +9 -0
- package/src/command/notebook-commands.ts +502 -0
- package/src/components/cell-protocol.ts +26 -0
- package/src/components/dnd-cell-item-render.tsx +465 -0
- package/src/components/dnd-component/custom-drag-layer.tsx +144 -0
- package/src/components/dnd-component/default-dnd-content.tsx +330 -0
- package/src/components/dnd-component/dnd-context.tsx +28 -0
- package/src/components/dnd-component/dnd-list.tsx +211 -0
- package/src/components/dnd-component/index.less +12 -0
- package/src/components/dnd-component/index.tsx +4 -0
- 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 +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/components/libro-virtualized-render.tsx +178 -0
- package/src/content/index.ts +5 -0
- package/src/content/libro-content-contribution.ts +16 -0
- package/src/content/libro-content-module.ts +17 -0
- package/src/content/libro-content-protocol.ts +14 -0
- package/src/content/libro-content-service.ts +48 -0
- 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 +789 -0
- package/src/index.spec.ts +12 -0
- package/src/index.tsx +25 -0
- package/src/libro-context-key.ts +84 -0
- package/src/libro-keybind-registry.ts +43 -0
- package/src/libro-model.ts +710 -0
- package/src/libro-protocol.ts +435 -0
- package/src/libro-service.ts +234 -0
- package/src/libro-setting-contribution.ts +28 -0
- package/src/libro-setting.ts +110 -0
- package/src/libro-view-tracker.ts +9 -0
- package/src/libro-view.tsx +1532 -0
- package/src/libro-workspace-service.ts +28 -0
- package/src/material-from-designer.tsx +579 -0
- package/src/module.ts +121 -0
- package/src/output/index.ts +5 -0
- package/src/output/output-area.tsx +286 -0
- package/src/output/output-contribution.ts +14 -0
- package/src/output/output-model.tsx +70 -0
- package/src/output/output-module.ts +10 -0
- package/src/output/output-protocol.ts +168 -0
- 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 +51 -0
- package/src/settings/settings-protocol.ts +7 -0
- package/src/slot/index.ts +4 -0
- package/src/slot/libro-slot-manager.ts +38 -0
- package/src/slot/libro-slot-protocol.ts +28 -0
- package/src/slot/libro-slot-view.tsx +48 -0
- package/src/slot/module.ts +9 -0
- package/src/theme/libro-color-registry.ts +386 -0
- package/src/toolbar/all-outputs-scroll-icon.tsx +19 -0
- package/src/toolbar/change-cell-to-selector.tsx +67 -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 +231 -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 +177 -0
- package/src/typings/index.d.ts +1 -0
- package/src/virtualized-manager-helper.ts +29 -0
- package/src/virtualized-manager.ts +47 -0
|
@@ -0,0 +1,330 @@
|
|
|
1
|
+
/* eslint-disable react-hooks/exhaustive-deps */
|
|
2
|
+
import { getOrigin, useInject, ViewInstance } from '@difizen/mana-app';
|
|
3
|
+
import { useConfigurationValue } from '@difizen/mana-app';
|
|
4
|
+
import type { Identifier } from 'dnd-core';
|
|
5
|
+
import React, {
|
|
6
|
+
useCallback,
|
|
7
|
+
useEffect,
|
|
8
|
+
useLayoutEffect,
|
|
9
|
+
useMemo,
|
|
10
|
+
useRef,
|
|
11
|
+
useState,
|
|
12
|
+
forwardRef,
|
|
13
|
+
} from 'react';
|
|
14
|
+
import { useDrag, useDragDropManager, useDrop } from 'react-dnd';
|
|
15
|
+
import { getEmptyImage } from 'react-dnd-html5-backend';
|
|
16
|
+
import 'resize-observer-polyfill';
|
|
17
|
+
|
|
18
|
+
import type { CellService } from '../../cell/index.js';
|
|
19
|
+
import { LibroCellService } from '../../cell/index.js';
|
|
20
|
+
import { CellCollapsible } from '../../collapse-service.js';
|
|
21
|
+
import { DragAreaKey, isCellView } from '../../libro-protocol.js';
|
|
22
|
+
import type { CellView, DndContentProps } from '../../libro-protocol.js';
|
|
23
|
+
import { MultiSelectionWhenShiftClick } from '../../libro-setting.js';
|
|
24
|
+
import type { LibroView } from '../../libro-view.js';
|
|
25
|
+
import { HolderOutlined, PlusOutlined } from '../../material-from-designer.js';
|
|
26
|
+
import { BetweenCellProvider } from '../cell-protocol.js';
|
|
27
|
+
|
|
28
|
+
export interface Dragparams {
|
|
29
|
+
cell: CellView;
|
|
30
|
+
index: number;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export const DndCellContainer: React.FC<DndContentProps> = ({ cell, index }) => {
|
|
34
|
+
const ref = useRef<HTMLDivElement>(null);
|
|
35
|
+
const instance = useInject<LibroView>(ViewInstance);
|
|
36
|
+
const [multiSelectionWhenShiftClick] = useConfigurationValue(
|
|
37
|
+
MultiSelectionWhenShiftClick,
|
|
38
|
+
);
|
|
39
|
+
const BetweenCellContent = useInject<BetweenCellProvider>(BetweenCellProvider);
|
|
40
|
+
const cellService = useInject<CellService>(LibroCellService);
|
|
41
|
+
const dragDropManager = useDragDropManager();
|
|
42
|
+
const dragDropMonitor = dragDropManager.getMonitor();
|
|
43
|
+
const ItemRender = getOrigin(instance.dndItemRender);
|
|
44
|
+
|
|
45
|
+
useLayoutEffect(() => {
|
|
46
|
+
if (typeof ref !== 'object') {
|
|
47
|
+
return () => {
|
|
48
|
+
//
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
const el = ref?.current;
|
|
52
|
+
if (!el) {
|
|
53
|
+
return () => {
|
|
54
|
+
//
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const resizeObserver = new ResizeObserver((entries) => {
|
|
59
|
+
entries.forEach((entry) => {
|
|
60
|
+
const isVisible =
|
|
61
|
+
entry.contentRect.width !== 0 && entry.contentRect.height !== 0;
|
|
62
|
+
|
|
63
|
+
if (isVisible) {
|
|
64
|
+
cell.noEditorAreaHeight = ref.current?.clientHeight || 0;
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
resizeObserver.observe(el as HTMLElement);
|
|
70
|
+
return () => {
|
|
71
|
+
cell.noEditorAreaHeight = 0;
|
|
72
|
+
resizeObserver.disconnect();
|
|
73
|
+
};
|
|
74
|
+
}, [ref, cell]);
|
|
75
|
+
|
|
76
|
+
const handleFocus = useCallback(
|
|
77
|
+
(e: React.FocusEvent<HTMLElement>) => {
|
|
78
|
+
const className = (e.target as HTMLDivElement).className;
|
|
79
|
+
if (
|
|
80
|
+
(e.target as HTMLDivElement).tagName === 'svg' ||
|
|
81
|
+
(className &&
|
|
82
|
+
className &&
|
|
83
|
+
typeof className === 'string' &&
|
|
84
|
+
(className.includes('mana-toolbar-item') ||
|
|
85
|
+
className.includes('mana-toolbar')))
|
|
86
|
+
) {
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
instance.model.selectCell(cell);
|
|
90
|
+
instance.model.selections = [];
|
|
91
|
+
if (cell.shouldEnterEditorMode(e)) {
|
|
92
|
+
instance.enterEditMode();
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
[instance, cell],
|
|
96
|
+
);
|
|
97
|
+
const handleMouseDown = useCallback(
|
|
98
|
+
(e: React.MouseEvent<HTMLDivElement>) => {
|
|
99
|
+
if (e.shiftKey && multiSelectionWhenShiftClick) {
|
|
100
|
+
//按shift键时为多选cell
|
|
101
|
+
instance.extendContiguousSelectionTo(index);
|
|
102
|
+
instance.model.mouseMode = 'multipleSelection';
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
instance.model.mouseMode = 'mouseDown';
|
|
106
|
+
},
|
|
107
|
+
[multiSelectionWhenShiftClick, instance, index],
|
|
108
|
+
);
|
|
109
|
+
const handleMouseUp = useCallback(() => {
|
|
110
|
+
if (
|
|
111
|
+
instance.model.mouseMode === 'multipleSelection' ||
|
|
112
|
+
instance.model.mouseMode === 'drag'
|
|
113
|
+
) {
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
instance.model.selectCell(cell);
|
|
117
|
+
instance.model.selections = [];
|
|
118
|
+
}, [instance, cell]);
|
|
119
|
+
|
|
120
|
+
const scrollTimer = useRef<null | NodeJS.Timeout>(null);
|
|
121
|
+
const unsubscribe = useRef<null | any>(null);
|
|
122
|
+
|
|
123
|
+
const [{ isDrag }, drag, preview] = useDrag(
|
|
124
|
+
{
|
|
125
|
+
type: DragAreaKey,
|
|
126
|
+
item: { cell, index },
|
|
127
|
+
collect: (monitor) => ({
|
|
128
|
+
isDrag: monitor.isDragging(),
|
|
129
|
+
}),
|
|
130
|
+
end() {
|
|
131
|
+
instance.isDragging = false;
|
|
132
|
+
if (scrollTimer.current) {
|
|
133
|
+
clearInterval(scrollTimer.current);
|
|
134
|
+
}
|
|
135
|
+
},
|
|
136
|
+
},
|
|
137
|
+
[cell, index],
|
|
138
|
+
);
|
|
139
|
+
|
|
140
|
+
const libroViewContent = instance.container?.current?.getElementsByClassName(
|
|
141
|
+
'libro-view-content',
|
|
142
|
+
)[0] as HTMLElement;
|
|
143
|
+
|
|
144
|
+
useEffect(() => {
|
|
145
|
+
unsubscribe.current = dragDropMonitor.subscribeToStateChange(() => {
|
|
146
|
+
instance.isDragging = dragDropMonitor.isDragging();
|
|
147
|
+
scrollTimer.current = setInterval(() => {
|
|
148
|
+
const currentOffset = dragDropMonitor.getClientOffset();
|
|
149
|
+
if (libroViewContent && instance.isDragging && currentOffset) {
|
|
150
|
+
const libroViewClientRect = libroViewContent.getBoundingClientRect();
|
|
151
|
+
const { top, bottom } = libroViewClientRect;
|
|
152
|
+
const { y } = currentOffset;
|
|
153
|
+
const topLimit = top + 30;
|
|
154
|
+
const bottomLimit = bottom - 50;
|
|
155
|
+
if (y < topLimit) {
|
|
156
|
+
libroViewContent.scrollTop -= 0.5;
|
|
157
|
+
} else if (y > bottomLimit) {
|
|
158
|
+
libroViewContent.scrollTop += 0.5;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
}, 10);
|
|
162
|
+
return () => {
|
|
163
|
+
if (scrollTimer.current) {
|
|
164
|
+
clearInterval(scrollTimer.current);
|
|
165
|
+
}
|
|
166
|
+
if (unsubscribe.current) {
|
|
167
|
+
unsubscribe.current();
|
|
168
|
+
}
|
|
169
|
+
};
|
|
170
|
+
});
|
|
171
|
+
}, [dragDropMonitor]);
|
|
172
|
+
|
|
173
|
+
useEffect(() => {
|
|
174
|
+
// This gets called after every render, by default
|
|
175
|
+
// (the first one, and every one after that)
|
|
176
|
+
|
|
177
|
+
// Use empty image as a drag preview so browsers don't draw it
|
|
178
|
+
// and we can draw whatever we want on the custom drag layer instead.
|
|
179
|
+
preview(getEmptyImage(), {
|
|
180
|
+
// IE fallback: specify that we'd rather screenshot the node
|
|
181
|
+
// when it already knows it's being dragged so we can hide it with CSS.
|
|
182
|
+
captureDraggingState: true,
|
|
183
|
+
});
|
|
184
|
+
}, [preview]);
|
|
185
|
+
|
|
186
|
+
const [{ handlerId, isDragOver }, drop] = useDrop<
|
|
187
|
+
Dragparams,
|
|
188
|
+
void,
|
|
189
|
+
{
|
|
190
|
+
handlerId: Identifier | null;
|
|
191
|
+
isDragOver: boolean;
|
|
192
|
+
}
|
|
193
|
+
>({
|
|
194
|
+
accept: DragAreaKey,
|
|
195
|
+
drop(item, monitor) {
|
|
196
|
+
cellService
|
|
197
|
+
.getOrCreateView(
|
|
198
|
+
{
|
|
199
|
+
...item.cell.model.options,
|
|
200
|
+
modelId: item.cell.model.id,
|
|
201
|
+
singleSelectionDragPreview: true,
|
|
202
|
+
},
|
|
203
|
+
item.cell.parent.id,
|
|
204
|
+
)
|
|
205
|
+
.then((view) => {
|
|
206
|
+
view.dispose();
|
|
207
|
+
return;
|
|
208
|
+
})
|
|
209
|
+
.catch((e) => {
|
|
210
|
+
//
|
|
211
|
+
});
|
|
212
|
+
if (isCellView(item.cell)) {
|
|
213
|
+
const didDrop = monitor.didDrop();
|
|
214
|
+
if (didDrop) {
|
|
215
|
+
return;
|
|
216
|
+
}
|
|
217
|
+
const dragIndex = instance.findCellIndex(item.cell);
|
|
218
|
+
const dropIndex = instance.findCellIndex(cell);
|
|
219
|
+
if (instance.model.selections.length > 0) {
|
|
220
|
+
const isDragInSelections =
|
|
221
|
+
instance.model.selections.findIndex(
|
|
222
|
+
(selection) => selection.id === item.cell.id,
|
|
223
|
+
) > -1
|
|
224
|
+
? true
|
|
225
|
+
: false;
|
|
226
|
+
const isDropInSelections =
|
|
227
|
+
instance.model.selections.findIndex(
|
|
228
|
+
(selection) => selection.id === cell.id,
|
|
229
|
+
) > -1
|
|
230
|
+
? true
|
|
231
|
+
: false;
|
|
232
|
+
if (isDragInSelections && isDropInSelections) {
|
|
233
|
+
return;
|
|
234
|
+
}
|
|
235
|
+
if (isDragInSelections) {
|
|
236
|
+
instance.model.exchangeCells(instance.model.selections, dropIndex);
|
|
237
|
+
instance.model.scrollToView(cell);
|
|
238
|
+
|
|
239
|
+
return;
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
if (dragIndex < dropIndex) {
|
|
243
|
+
instance.model.exchangeCell(dragIndex, dropIndex - 1);
|
|
244
|
+
instance.model.scrollToView(cell);
|
|
245
|
+
}
|
|
246
|
+
if (dragIndex > dropIndex) {
|
|
247
|
+
instance.model.exchangeCell(dragIndex, dropIndex);
|
|
248
|
+
instance.model.scrollToView(cell);
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
return;
|
|
252
|
+
},
|
|
253
|
+
collect(monitor) {
|
|
254
|
+
return {
|
|
255
|
+
isDragOver: monitor.isOver(),
|
|
256
|
+
canDrop: monitor.canDrop(),
|
|
257
|
+
handlerId: monitor.getHandlerId(),
|
|
258
|
+
};
|
|
259
|
+
},
|
|
260
|
+
});
|
|
261
|
+
const opacity = isDrag ? 0.4 : 1;
|
|
262
|
+
if (instance.model.cellsEditable) {
|
|
263
|
+
drop(ref);
|
|
264
|
+
}
|
|
265
|
+
if (isDrag) {
|
|
266
|
+
instance.model.mouseMode = 'drag';
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
const isMultiSelected =
|
|
270
|
+
instance.model.selections.length !== 0 && instance.isSelected(cell);
|
|
271
|
+
// let isMouseOver = false;
|
|
272
|
+
const [isMouseOverDragArea, setIsMouseOverDragArea] = useState(false);
|
|
273
|
+
const hasCellHidden = useMemo(() => {
|
|
274
|
+
return cell.hasCellHidden();
|
|
275
|
+
}, [cell]);
|
|
276
|
+
const isCollapsible = CellCollapsible.is(cell);
|
|
277
|
+
|
|
278
|
+
return (
|
|
279
|
+
<div
|
|
280
|
+
className={`libro-dnd-cell-container ${isMultiSelected ? 'multi-selected' : ''} ${
|
|
281
|
+
hasCellHidden ? 'hidden' : ''
|
|
282
|
+
}`}
|
|
283
|
+
data-handler-id={handlerId}
|
|
284
|
+
style={{ opacity }}
|
|
285
|
+
ref={ref}
|
|
286
|
+
id={cell.id}
|
|
287
|
+
>
|
|
288
|
+
<BetweenCellContent index={index} addCell={cell.parent.addCellAbove} />
|
|
289
|
+
{isDragOver && <div className="libro-drag-hoverline" />}
|
|
290
|
+
{isMouseOverDragArea && <HolderOutlined className="libro-handle-style" />}
|
|
291
|
+
<div
|
|
292
|
+
className="libro-drag-area"
|
|
293
|
+
ref={drag}
|
|
294
|
+
onMouseDown={handleMouseDown}
|
|
295
|
+
onMouseUp={handleMouseUp}
|
|
296
|
+
onMouseOver={() => setIsMouseOverDragArea(true)}
|
|
297
|
+
onMouseLeave={() => setIsMouseOverDragArea(false)}
|
|
298
|
+
/>
|
|
299
|
+
<div
|
|
300
|
+
tabIndex={-1}
|
|
301
|
+
onFocus={handleFocus}
|
|
302
|
+
// onClick={e => e.preventDefault()}
|
|
303
|
+
className="libro-dnd-cell-content"
|
|
304
|
+
>
|
|
305
|
+
<ItemRender
|
|
306
|
+
isDragOver={!!isDragOver}
|
|
307
|
+
isDrag={!!isDrag}
|
|
308
|
+
cell={cell}
|
|
309
|
+
isMouseOverDragArea={isMouseOverDragArea}
|
|
310
|
+
/>
|
|
311
|
+
</div>
|
|
312
|
+
{isCollapsible && cell.headingCollapsed && cell.collapsibleChildNumber > 0 && (
|
|
313
|
+
<div className="libro-cell-collapsed-expander">
|
|
314
|
+
<button
|
|
315
|
+
className="libro-cell-expand-button"
|
|
316
|
+
onClick={() => instance.collapseCell(cell, false)}
|
|
317
|
+
>
|
|
318
|
+
<PlusOutlined className="" /> {cell.collapsibleChildNumber} cell hidden
|
|
319
|
+
</button>
|
|
320
|
+
</div>
|
|
321
|
+
)}
|
|
322
|
+
</div>
|
|
323
|
+
);
|
|
324
|
+
};
|
|
325
|
+
|
|
326
|
+
export const LibroBetweenCellContent: BetweenCellProvider = forwardRef(
|
|
327
|
+
function LibroBetweenCellContent() {
|
|
328
|
+
return null;
|
|
329
|
+
},
|
|
330
|
+
);
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { getOrigin, useInject } from '@difizen/mana-app';
|
|
2
|
+
import { ViewInstance } from '@difizen/mana-app';
|
|
3
|
+
import type { FC } from 'react';
|
|
4
|
+
import { DndProvider } from 'react-dnd';
|
|
5
|
+
import { HTML5Backend } from 'react-dnd-html5-backend';
|
|
6
|
+
|
|
7
|
+
import type { LibroView } from '../../libro-view.js';
|
|
8
|
+
|
|
9
|
+
export const DndContext: FC<any> = ({ children }) => {
|
|
10
|
+
const instance = useInject<LibroView>(ViewInstance);
|
|
11
|
+
|
|
12
|
+
if (!instance.isVisible && !instance.model.dndAreaNullEnable) {
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
15
|
+
return (
|
|
16
|
+
<DndProvider
|
|
17
|
+
backend={HTML5Backend}
|
|
18
|
+
options={{
|
|
19
|
+
rootElement:
|
|
20
|
+
instance.isVisible || !instance.model.dndAreaNullEnable
|
|
21
|
+
? getOrigin(instance).container?.current
|
|
22
|
+
: null,
|
|
23
|
+
}}
|
|
24
|
+
>
|
|
25
|
+
{children}
|
|
26
|
+
</DndProvider>
|
|
27
|
+
);
|
|
28
|
+
};
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
import { getOrigin, useInject, useObserve, ViewInstance } from '@difizen/mana-app';
|
|
2
|
+
import classNames from 'classnames';
|
|
3
|
+
import type { FC, ReactNode } from 'react';
|
|
4
|
+
import { forwardRef, memo, useEffect, useState } from 'react';
|
|
5
|
+
import type { XYCoord } from 'react-dnd';
|
|
6
|
+
import { useDrop } from 'react-dnd';
|
|
7
|
+
|
|
8
|
+
import type { CellService } from '../../cell/index.js';
|
|
9
|
+
import { LibroCellService } from '../../cell/index.js';
|
|
10
|
+
import type { CellView, DndContentProps } from '../../libro-protocol.js';
|
|
11
|
+
import { DragAreaKey, isCellView } from '../../libro-protocol.js';
|
|
12
|
+
import type { LibroView } from '../../libro-view.js';
|
|
13
|
+
import { VirtualizedManagerHelper } from '../../virtualized-manager-helper.js';
|
|
14
|
+
import { LibroCellsOutputRender } from '../libro-virtualized-render.js';
|
|
15
|
+
|
|
16
|
+
import type { Dragparams } from './default-dnd-content.js';
|
|
17
|
+
import './index.less';
|
|
18
|
+
|
|
19
|
+
export const DndCellRender: FC<DndContentProps> = memo(function DndCellRender({
|
|
20
|
+
cell,
|
|
21
|
+
index,
|
|
22
|
+
...props
|
|
23
|
+
}: DndContentProps) {
|
|
24
|
+
const observableCell = useObserve(cell);
|
|
25
|
+
const instance = useInject<LibroView>(ViewInstance);
|
|
26
|
+
const DndCellContainer = instance.dndContentRender;
|
|
27
|
+
|
|
28
|
+
return (
|
|
29
|
+
<DndCellContainer cell={observableCell} key={cell.id} index={index} {...props} />
|
|
30
|
+
);
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
// 定义一个函数用于渲染非虚拟列表时的单元格
|
|
34
|
+
const renderNonVirtualListCells = (cells: CellView[]) => (
|
|
35
|
+
<div style={{ height: '100%', overflow: 'visible' }}>
|
|
36
|
+
{cells
|
|
37
|
+
.filter((cell) => !cell.collapsedHidden)
|
|
38
|
+
.map((cell, index) => (
|
|
39
|
+
<DndCellRender cell={cell} key={cell.id} index={index} />
|
|
40
|
+
))}
|
|
41
|
+
</div>
|
|
42
|
+
);
|
|
43
|
+
|
|
44
|
+
export const DndCellsRender = forwardRef<
|
|
45
|
+
HTMLDivElement,
|
|
46
|
+
{ libroView: LibroView; addCellButtons: ReactNode }
|
|
47
|
+
>(function DndCellsRender(
|
|
48
|
+
{ libroView, addCellButtons }: { libroView: LibroView; addCellButtons: ReactNode },
|
|
49
|
+
ref,
|
|
50
|
+
) {
|
|
51
|
+
const LoadingRender = getOrigin(libroView.loadingRender);
|
|
52
|
+
const virtualizedManagerHelper = useInject(VirtualizedManagerHelper);
|
|
53
|
+
const virtualizedManager = virtualizedManagerHelper.getOrCreate(libroView.model);
|
|
54
|
+
|
|
55
|
+
const cells = libroView.model.getCells().reduce<CellView[]>(function (a, b) {
|
|
56
|
+
if (a.indexOf(b) < 0) {
|
|
57
|
+
a.push(b);
|
|
58
|
+
}
|
|
59
|
+
return a;
|
|
60
|
+
}, []);
|
|
61
|
+
|
|
62
|
+
const [isVirtualList, setIsVirtualList] = useState<boolean>(false);
|
|
63
|
+
const [isJudging, setIsJudging] = useState<boolean>(true);
|
|
64
|
+
|
|
65
|
+
useEffect(() => {
|
|
66
|
+
if (!libroView.model.isInitialized) {
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
let size = undefined;
|
|
71
|
+
let path = undefined;
|
|
72
|
+
|
|
73
|
+
// TODO: 类型处理
|
|
74
|
+
const model = libroView.model as any;
|
|
75
|
+
if (model.currentFileContents && model.currentFileContents.size) {
|
|
76
|
+
size = parseFloat((model.currentFileContents.size / 1048576).toFixed(3)); // 单位MB
|
|
77
|
+
path = model.currentFileContents.path || '';
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
setIsJudging(true);
|
|
81
|
+
virtualizedManager
|
|
82
|
+
.openVirtualized(cells.length, size, path)
|
|
83
|
+
.then((willOpen) => {
|
|
84
|
+
setIsVirtualList(willOpen);
|
|
85
|
+
return;
|
|
86
|
+
})
|
|
87
|
+
.catch(() => {
|
|
88
|
+
setIsVirtualList(false);
|
|
89
|
+
})
|
|
90
|
+
.finally(() => {
|
|
91
|
+
setIsJudging(false);
|
|
92
|
+
})
|
|
93
|
+
.catch((e) => {
|
|
94
|
+
//
|
|
95
|
+
});
|
|
96
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
97
|
+
}, [virtualizedManager, libroView.model.isInitialized]);
|
|
98
|
+
|
|
99
|
+
const isInitialized = libroView.model.isInitialized;
|
|
100
|
+
const isLoading = !isInitialized || isJudging;
|
|
101
|
+
const shouldRenderCells = isInitialized && !isJudging;
|
|
102
|
+
|
|
103
|
+
return (
|
|
104
|
+
<>
|
|
105
|
+
<div
|
|
106
|
+
className={classNames(
|
|
107
|
+
'libro-dnd-cells-container',
|
|
108
|
+
isVirtualList && 'virtual_list_container',
|
|
109
|
+
)}
|
|
110
|
+
ref={ref}
|
|
111
|
+
>
|
|
112
|
+
{isLoading && <LoadingRender />}
|
|
113
|
+
<>
|
|
114
|
+
{shouldRenderCells && (
|
|
115
|
+
<>
|
|
116
|
+
{isVirtualList ? (
|
|
117
|
+
<LibroCellsOutputRender
|
|
118
|
+
cells={cells}
|
|
119
|
+
libroView={libroView}
|
|
120
|
+
addCellButtons={addCellButtons}
|
|
121
|
+
/>
|
|
122
|
+
) : (
|
|
123
|
+
renderNonVirtualListCells(cells)
|
|
124
|
+
)}
|
|
125
|
+
</>
|
|
126
|
+
)}
|
|
127
|
+
</>
|
|
128
|
+
</div>
|
|
129
|
+
{shouldRenderCells && !isVirtualList && addCellButtons}
|
|
130
|
+
</>
|
|
131
|
+
);
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
export const DndList = forwardRef<
|
|
135
|
+
HTMLDivElement,
|
|
136
|
+
{ libroView: LibroView; children: ReactNode }
|
|
137
|
+
>(function DndList(
|
|
138
|
+
{
|
|
139
|
+
libroView,
|
|
140
|
+
children,
|
|
141
|
+
}: {
|
|
142
|
+
libroView: LibroView;
|
|
143
|
+
children: ReactNode;
|
|
144
|
+
},
|
|
145
|
+
ref,
|
|
146
|
+
) {
|
|
147
|
+
const cellService = useInject<CellService>(LibroCellService);
|
|
148
|
+
|
|
149
|
+
const [, drop] = useDrop<Dragparams>(() => ({
|
|
150
|
+
accept: DragAreaKey,
|
|
151
|
+
drop(item, dropMonitor) {
|
|
152
|
+
cellService
|
|
153
|
+
.getOrCreateView(
|
|
154
|
+
{
|
|
155
|
+
...item.cell.model.options,
|
|
156
|
+
modelId: item.cell.model.id,
|
|
157
|
+
singleSelectionDragPreview: true,
|
|
158
|
+
},
|
|
159
|
+
item.cell.parent.id,
|
|
160
|
+
)
|
|
161
|
+
.then((view) => {
|
|
162
|
+
view.dispose();
|
|
163
|
+
return;
|
|
164
|
+
})
|
|
165
|
+
.catch((e) => {
|
|
166
|
+
//
|
|
167
|
+
});
|
|
168
|
+
if (isCellView(item.cell)) {
|
|
169
|
+
const didDrop = dropMonitor.didDrop();
|
|
170
|
+
if (didDrop) {
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
// Determine mouse position
|
|
174
|
+
const clientOffset = dropMonitor.getClientOffset();
|
|
175
|
+
const clientOffsetY = (clientOffset as XYCoord).y;
|
|
176
|
+
const dragIndex = libroView.findCellIndex(item.cell);
|
|
177
|
+
// Determine rectangle on screen
|
|
178
|
+
const lastCell =
|
|
179
|
+
libroView.model.getCells()[libroView.model.getCells().length - 1];
|
|
180
|
+
const lastCellOffsetY = lastCell.container?.current?.getBoundingClientRect().y;
|
|
181
|
+
if (lastCellOffsetY && clientOffsetY >= lastCellOffsetY) {
|
|
182
|
+
if (libroView.model.selections.length > 0) {
|
|
183
|
+
const isDragInSelections =
|
|
184
|
+
libroView.model.selections.findIndex(
|
|
185
|
+
(selection) => selection.id === item.cell.id,
|
|
186
|
+
) > -1
|
|
187
|
+
? true
|
|
188
|
+
: false;
|
|
189
|
+
if (isDragInSelections) {
|
|
190
|
+
libroView.model.exchangeCells(
|
|
191
|
+
libroView.model.selections,
|
|
192
|
+
libroView.model.cells.length,
|
|
193
|
+
);
|
|
194
|
+
return;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
libroView.model.exchangeCell(dragIndex, libroView.model.cells.length - 1);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
// Determine mouse position
|
|
201
|
+
|
|
202
|
+
return;
|
|
203
|
+
},
|
|
204
|
+
}));
|
|
205
|
+
|
|
206
|
+
return (
|
|
207
|
+
<div className="libro-dnd-list-container" ref={drop}>
|
|
208
|
+
<DndCellsRender libroView={libroView} addCellButtons={children} />
|
|
209
|
+
</div>
|
|
210
|
+
);
|
|
211
|
+
});
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
export type OverscanIndicesGetterParams = {
|
|
2
|
+
// One of SCROLL_DIRECTION_HORIZONTAL or SCROLL_DIRECTION_VERTICAL
|
|
3
|
+
direction: 'horizontal' | 'vertical';
|
|
4
|
+
|
|
5
|
+
// One of SCROLL_DIRECTION_BACKWARD or SCROLL_DIRECTION_FORWARD
|
|
6
|
+
scrollDirection: -1 | 1;
|
|
7
|
+
|
|
8
|
+
// Number of rows or columns in the current axis
|
|
9
|
+
cellCount: number;
|
|
10
|
+
|
|
11
|
+
// Maximum number of cells to over-render in either direction
|
|
12
|
+
overscanCellsCount: number;
|
|
13
|
+
|
|
14
|
+
// Begin of range of visible cells
|
|
15
|
+
startIndex: number;
|
|
16
|
+
|
|
17
|
+
// End of range of visible cells
|
|
18
|
+
stopIndex: number;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export type OverscanIndices = {
|
|
22
|
+
overscanStartIndex: number;
|
|
23
|
+
overscanStopIndex: number;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export const SCROLL_DIRECTION_BACKWARD = -1;
|
|
27
|
+
export const SCROLL_DIRECTION_FORWARD = 1;
|
|
28
|
+
|
|
29
|
+
export const SCROLL_DIRECTION_HORIZONTAL = 'horizontal';
|
|
30
|
+
export const SCROLL_DIRECTION_VERTICAL = 'vertical';
|
|
31
|
+
|
|
32
|
+
let overscanIndicesCache: { value: any; timestamp: number } | null = null;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Calculates the number of cells to overscan before and after a specified range.
|
|
36
|
+
* This function ensures that overscanning doesn't exceed the available cells.
|
|
37
|
+
*/
|
|
38
|
+
export default function libroOverscanIndicesGetter({
|
|
39
|
+
cellCount,
|
|
40
|
+
overscanCellsCount,
|
|
41
|
+
scrollDirection,
|
|
42
|
+
startIndex,
|
|
43
|
+
stopIndex,
|
|
44
|
+
}: OverscanIndicesGetterParams): OverscanIndices {
|
|
45
|
+
// Make sure we render at least 1 cell extra before and after (except near boundaries)
|
|
46
|
+
// This is necessary in order to support keyboard navigation (TAB/SHIFT+TAB) in some cases
|
|
47
|
+
// For more info see issues #625
|
|
48
|
+
|
|
49
|
+
// 计算 overscanIndices 的函数
|
|
50
|
+
const calculateOverscanIndices = () => {
|
|
51
|
+
const _overscanCellsCount = Math.max(1, overscanCellsCount);
|
|
52
|
+
|
|
53
|
+
let overscanIndices = null;
|
|
54
|
+
|
|
55
|
+
if (scrollDirection === SCROLL_DIRECTION_FORWARD) {
|
|
56
|
+
overscanIndices = {
|
|
57
|
+
overscanStartIndex: Math.max(0, startIndex - 1),
|
|
58
|
+
overscanStopIndex: Math.min(cellCount - 1, stopIndex + _overscanCellsCount),
|
|
59
|
+
};
|
|
60
|
+
} else {
|
|
61
|
+
overscanIndices = {
|
|
62
|
+
overscanStartIndex: Math.max(0, startIndex - _overscanCellsCount),
|
|
63
|
+
overscanStopIndex: Math.min(cellCount - 1, stopIndex + 1),
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
return overscanIndices;
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
// 检查缓存和时间戳函数
|
|
71
|
+
const checkCacheAndTimestamp = () => {
|
|
72
|
+
if (cellCount === 1) {
|
|
73
|
+
// 'horizontal' 方向 不用缓存
|
|
74
|
+
const overscanIndices = calculateOverscanIndices();
|
|
75
|
+
return overscanIndices;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
if (overscanIndicesCache && Date.now() - overscanIndicesCache.timestamp < 500) {
|
|
79
|
+
return overscanIndicesCache.value;
|
|
80
|
+
} else {
|
|
81
|
+
const overscanIndices = calculateOverscanIndices();
|
|
82
|
+
overscanIndicesCache = {
|
|
83
|
+
value: overscanIndices,
|
|
84
|
+
timestamp: Date.now(),
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
return overscanIndices;
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
return checkCacheAndTimestamp();
|
|
92
|
+
}
|