@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,465 @@
|
|
|
1
|
+
/* eslint-disable react-hooks/exhaustive-deps */
|
|
2
|
+
import {
|
|
3
|
+
useConfigurationValue,
|
|
4
|
+
CommandRegistry,
|
|
5
|
+
equals,
|
|
6
|
+
ToolbarRender,
|
|
7
|
+
useInject,
|
|
8
|
+
useObserve,
|
|
9
|
+
ViewInstance,
|
|
10
|
+
ViewRender,
|
|
11
|
+
} from '@difizen/mana-app';
|
|
12
|
+
import { l10n } from '@difizen/mana-l10n';
|
|
13
|
+
import { Tooltip } from 'antd';
|
|
14
|
+
import classnames from 'classnames';
|
|
15
|
+
import type { FC } from 'react';
|
|
16
|
+
import React, { forwardRef, memo, useLayoutEffect, useMemo, useRef } from 'react';
|
|
17
|
+
|
|
18
|
+
import {
|
|
19
|
+
EditorCellView,
|
|
20
|
+
ExecutableCellModel,
|
|
21
|
+
ExecutableCellView,
|
|
22
|
+
isLibroCellModel,
|
|
23
|
+
} from '../cell/index.js';
|
|
24
|
+
import { CellCollapsible } from '../collapse-service.js';
|
|
25
|
+
import { NotebookCommands } from '../command/index.js';
|
|
26
|
+
import '../index.less';
|
|
27
|
+
import type { CellView, DndItemProps } from '../libro-protocol.js';
|
|
28
|
+
import { isCellView, LibroToolbarArea } from '../libro-protocol.js';
|
|
29
|
+
import {
|
|
30
|
+
CellSideToolbarVisible,
|
|
31
|
+
CellTopToolbarSetting,
|
|
32
|
+
CollapserClickActive,
|
|
33
|
+
OutputScrollBtnVisiable,
|
|
34
|
+
} from '../libro-setting.js';
|
|
35
|
+
import type { LibroView } from '../libro-view.js';
|
|
36
|
+
import {
|
|
37
|
+
ArrowDown,
|
|
38
|
+
ArrowRight,
|
|
39
|
+
ContentMore,
|
|
40
|
+
DisableOutputScroll,
|
|
41
|
+
EnableOutputScroll,
|
|
42
|
+
} from '../material-from-designer.js';
|
|
43
|
+
import { hasErrorOutput } from '../output/index.js';
|
|
44
|
+
|
|
45
|
+
import { CellOutputBottomBlankProvider } from './cell-protocol.js';
|
|
46
|
+
import {
|
|
47
|
+
CellExecutionTimeProvider,
|
|
48
|
+
CellInputBottonBlankProvider,
|
|
49
|
+
CellOutputVisulizationProvider,
|
|
50
|
+
} from './cell-protocol.js';
|
|
51
|
+
|
|
52
|
+
const CellInputContent = memo(function CellInputContent(props: { cell: CellView }) {
|
|
53
|
+
const { cell } = props;
|
|
54
|
+
const observableCell = useObserve(cell);
|
|
55
|
+
const CellInputBottonBlank = useInject<CellInputBottonBlankProvider>(
|
|
56
|
+
CellInputBottonBlankProvider,
|
|
57
|
+
);
|
|
58
|
+
|
|
59
|
+
if (!observableCell?.view || !isCellView(observableCell)) {
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
const isHidden = observableCell.hasInputHidden;
|
|
63
|
+
if (isHidden) {
|
|
64
|
+
return (
|
|
65
|
+
<div className="libro-input-hidden">
|
|
66
|
+
<ContentMore />
|
|
67
|
+
</div>
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
return (
|
|
71
|
+
<div className="libro-cell-input-content">
|
|
72
|
+
<ViewRender view={observableCell} />
|
|
73
|
+
<CellInputBottonBlank cell={cell} />
|
|
74
|
+
</div>
|
|
75
|
+
);
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
interface CellInputProps {
|
|
79
|
+
cell: CellView;
|
|
80
|
+
}
|
|
81
|
+
const CellInputInnner = forwardRef(function CellInput(
|
|
82
|
+
props: CellInputProps,
|
|
83
|
+
ref: React.ForwardedRef<HTMLDivElement>,
|
|
84
|
+
) {
|
|
85
|
+
const { cell } = props;
|
|
86
|
+
const observableCell = useObserve(cell);
|
|
87
|
+
const inputCollapserRef = useRef<HTMLDivElement>(null);
|
|
88
|
+
const [collapserClickActive] = useConfigurationValue(CollapserClickActive);
|
|
89
|
+
const handleCellInputCollapser = () => {
|
|
90
|
+
if (collapserClickActive) {
|
|
91
|
+
observableCell.hasInputHidden = !observableCell.hasInputHidden;
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
const hasErrorOutputs = EditorCellView.is(observableCell)
|
|
95
|
+
? hasErrorOutput(observableCell)
|
|
96
|
+
: false;
|
|
97
|
+
// TODO: 性能!
|
|
98
|
+
// const isFirstCell = cell.parent.model.cells.indexOf(cell) === 0 ? true : false;
|
|
99
|
+
const isFirstCell = useMemo(() => {
|
|
100
|
+
return observableCell.parent.model.cells[0] &&
|
|
101
|
+
equals(observableCell.parent.model.cells[0], observableCell)
|
|
102
|
+
? true
|
|
103
|
+
: false;
|
|
104
|
+
}, [observableCell]);
|
|
105
|
+
|
|
106
|
+
return (
|
|
107
|
+
<div className="libro-cell-container" tabIndex={10} ref={ref}>
|
|
108
|
+
<div
|
|
109
|
+
className={`libro-cell-input-collapser ${isFirstCell ? 'firstCell' : ''} ${
|
|
110
|
+
hasErrorOutputs ? 'error' : ''
|
|
111
|
+
} `}
|
|
112
|
+
ref={inputCollapserRef}
|
|
113
|
+
onClick={handleCellInputCollapser}
|
|
114
|
+
/>
|
|
115
|
+
<CellInputContent cell={observableCell} />
|
|
116
|
+
</div>
|
|
117
|
+
);
|
|
118
|
+
});
|
|
119
|
+
const CellInput: FC<CellInputProps> = memo<CellInputProps>(CellInputInnner);
|
|
120
|
+
|
|
121
|
+
export const CellOutputContent: React.FC<{ cell: CellView }> = memo(
|
|
122
|
+
function CellOutputContent(props: { cell: CellView }) {
|
|
123
|
+
const { cell } = props;
|
|
124
|
+
|
|
125
|
+
const observableCell = useObserve(cell);
|
|
126
|
+
const CellOutputVisulization = useInject<CellOutputVisulizationProvider>(
|
|
127
|
+
CellOutputVisulizationProvider,
|
|
128
|
+
);
|
|
129
|
+
const CellOutputBottomBlank = useInject<CellOutputBottomBlankProvider>(
|
|
130
|
+
CellOutputBottomBlankProvider,
|
|
131
|
+
);
|
|
132
|
+
const CellExecutionTime = useInject<CellExecutionTimeProvider>(
|
|
133
|
+
CellExecutionTimeProvider,
|
|
134
|
+
);
|
|
135
|
+
|
|
136
|
+
if (!ExecutableCellView.is(cell) || !ExecutableCellView.is(observableCell)) {
|
|
137
|
+
return null;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
if (!ExecutableCellModel.is(observableCell.model)) {
|
|
141
|
+
return null;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
const hasOutputsScrolled = observableCell.model.hasOutputsScrolled;
|
|
145
|
+
|
|
146
|
+
const isHidden = observableCell.model.hasOutputHidden;
|
|
147
|
+
if (isHidden) {
|
|
148
|
+
return (
|
|
149
|
+
<div className="libro-cell-output-hidden">
|
|
150
|
+
<ContentMore />
|
|
151
|
+
</div>
|
|
152
|
+
);
|
|
153
|
+
}
|
|
154
|
+
return (
|
|
155
|
+
<div
|
|
156
|
+
className={`libro-cell-output-content ${hasOutputsScrolled ? 'scrolled' : ''} `}
|
|
157
|
+
>
|
|
158
|
+
<CellExecutionTime cell={cell} />
|
|
159
|
+
<CellOutputVisulization cell={cell} />
|
|
160
|
+
{observableCell.outputArea.length > 0 && <ViewRender view={cell.outputArea} />}
|
|
161
|
+
<CellOutputBottomBlank cell={cell} />
|
|
162
|
+
</div>
|
|
163
|
+
);
|
|
164
|
+
},
|
|
165
|
+
);
|
|
166
|
+
|
|
167
|
+
export const LibroCellExecutionTime: CellExecutionTimeProvider = forwardRef(
|
|
168
|
+
function LibroCellExecutionTime() {
|
|
169
|
+
return null;
|
|
170
|
+
},
|
|
171
|
+
);
|
|
172
|
+
|
|
173
|
+
export const LibroCellInputBottonBlank: CellInputBottonBlankProvider = forwardRef(
|
|
174
|
+
function LibroCellInputBottonBlank() {
|
|
175
|
+
return null;
|
|
176
|
+
},
|
|
177
|
+
);
|
|
178
|
+
|
|
179
|
+
export const LibroCellOutputBottomBlank: CellOutputBottomBlankProvider = forwardRef(
|
|
180
|
+
function LibroCellOutputBottomBlank() {
|
|
181
|
+
return null;
|
|
182
|
+
},
|
|
183
|
+
);
|
|
184
|
+
|
|
185
|
+
export const LibroCellVisualization: CellOutputVisulizationProvider = forwardRef(
|
|
186
|
+
function LibroCellVisualization() {
|
|
187
|
+
return null;
|
|
188
|
+
},
|
|
189
|
+
);
|
|
190
|
+
|
|
191
|
+
const CellOutput: React.FC<{ cell: CellView }> = forwardRef(function CellOutput(
|
|
192
|
+
props: {
|
|
193
|
+
cell: CellView;
|
|
194
|
+
},
|
|
195
|
+
ref: React.ForwardedRef<HTMLDivElement>,
|
|
196
|
+
) {
|
|
197
|
+
const { cell } = props;
|
|
198
|
+
const outputRef = useRef<HTMLDivElement>(null);
|
|
199
|
+
const outputCollapserRef = useRef<HTMLDivElement>(null);
|
|
200
|
+
const [collapserClickActive] = useConfigurationValue(CollapserClickActive);
|
|
201
|
+
const [outputScrollBtnVisiable] = useConfigurationValue(OutputScrollBtnVisiable);
|
|
202
|
+
const command = useInject(CommandRegistry);
|
|
203
|
+
|
|
204
|
+
const isExecutingRef = useRef<boolean | null>(null);
|
|
205
|
+
|
|
206
|
+
let executing = false;
|
|
207
|
+
if (ExecutableCellModel.is(cell.model)) {
|
|
208
|
+
executing = cell.model.executing;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
useLayoutEffect(() => {
|
|
212
|
+
isExecutingRef.current = !!executing;
|
|
213
|
+
}, [executing]);
|
|
214
|
+
|
|
215
|
+
// useLayoutEffect(() => {
|
|
216
|
+
// if (!outputRef || !isExecutingRef || !outputRef?.current) {
|
|
217
|
+
// return () => {
|
|
218
|
+
// //
|
|
219
|
+
// };
|
|
220
|
+
// }
|
|
221
|
+
// const el = outputRef?.current;
|
|
222
|
+
|
|
223
|
+
// const resizeObserver = new ResizeObserver((entries) => {
|
|
224
|
+
// entries.forEach(() => {
|
|
225
|
+
// const outputAreaHeight = outputRef?.current?.clientHeight || 0;
|
|
226
|
+
// if (isExecutingRef.current && outputAreaHeight > 495) {
|
|
227
|
+
// command.executeCommand(NotebookCommands['EnableOutputScrolling'].id);
|
|
228
|
+
// }
|
|
229
|
+
// });
|
|
230
|
+
// });
|
|
231
|
+
|
|
232
|
+
// resizeObserver.observe(el as HTMLElement);
|
|
233
|
+
// return () => {
|
|
234
|
+
// resizeObserver.unobserve(el as HTMLElement);
|
|
235
|
+
// resizeObserver.disconnect();
|
|
236
|
+
// };
|
|
237
|
+
// }, [outputRef.current, cell, isExecutingRef]);
|
|
238
|
+
|
|
239
|
+
if (!ExecutableCellView.is(cell) || !ExecutableCellModel.is(cell.model)) {
|
|
240
|
+
return null;
|
|
241
|
+
}
|
|
242
|
+
const handleCellOutputCollapser = () => {
|
|
243
|
+
if (ExecutableCellModel.is(cell.model) && collapserClickActive) {
|
|
244
|
+
cell.model.hasOutputHidden = !cell.model.hasOutputHidden;
|
|
245
|
+
}
|
|
246
|
+
};
|
|
247
|
+
|
|
248
|
+
const handleOutputScroll = () => {
|
|
249
|
+
if (!ExecutableCellModel.is(cell.model)) {
|
|
250
|
+
return;
|
|
251
|
+
}
|
|
252
|
+
if (cell.model.hasOutputsScrolled) {
|
|
253
|
+
command.executeCommand(NotebookCommands['DisableOutputScrolling'].id);
|
|
254
|
+
} else {
|
|
255
|
+
command.executeCommand(NotebookCommands['EnableOutputScrolling'].id);
|
|
256
|
+
}
|
|
257
|
+
};
|
|
258
|
+
return (
|
|
259
|
+
<div className="libro-cell-output-container" ref={ref}>
|
|
260
|
+
<div ref={outputRef}>
|
|
261
|
+
<div
|
|
262
|
+
className={'libro-cell-output-collapser'}
|
|
263
|
+
ref={outputCollapserRef}
|
|
264
|
+
onClick={handleCellOutputCollapser}
|
|
265
|
+
/>
|
|
266
|
+
{outputScrollBtnVisiable && cell.outputArea.length > 0 && (
|
|
267
|
+
<div className="libro-cell-output-scroll">
|
|
268
|
+
<Tooltip
|
|
269
|
+
title={`${
|
|
270
|
+
cell.model.hasOutputsScrolled
|
|
271
|
+
? l10n.t('取消固定 Output 高度')
|
|
272
|
+
: l10n.t('固定 Output 高度')
|
|
273
|
+
}`}
|
|
274
|
+
>
|
|
275
|
+
<div
|
|
276
|
+
className="libro-cell-output-scroll-button "
|
|
277
|
+
onClick={handleOutputScroll}
|
|
278
|
+
>
|
|
279
|
+
{cell.model.hasOutputsScrolled ? (
|
|
280
|
+
<DisableOutputScroll />
|
|
281
|
+
) : (
|
|
282
|
+
<EnableOutputScroll />
|
|
283
|
+
)}
|
|
284
|
+
</div>
|
|
285
|
+
</Tooltip>
|
|
286
|
+
</div>
|
|
287
|
+
)}
|
|
288
|
+
<CellOutputContent cell={cell} />
|
|
289
|
+
</div>
|
|
290
|
+
</div>
|
|
291
|
+
);
|
|
292
|
+
});
|
|
293
|
+
|
|
294
|
+
const HideCellContent: React.FC<{ cell: CellView }> = (props: { cell: CellView }) => {
|
|
295
|
+
const { cell } = props;
|
|
296
|
+
const cellCollapserRef = useRef<HTMLDivElement>(null);
|
|
297
|
+
const [collapserClickActive] = useConfigurationValue(CollapserClickActive);
|
|
298
|
+
|
|
299
|
+
const handleCellCollapser = () => {
|
|
300
|
+
if (collapserClickActive) {
|
|
301
|
+
cell.hasInputHidden = !cell.hasInputHidden;
|
|
302
|
+
}
|
|
303
|
+
};
|
|
304
|
+
const hasErrorOutputs = hasErrorOutput(cell);
|
|
305
|
+
return (
|
|
306
|
+
<>
|
|
307
|
+
<div
|
|
308
|
+
className={`libro-cell-collapser ${hasErrorOutputs ? 'error' : ''}`}
|
|
309
|
+
ref={cellCollapserRef}
|
|
310
|
+
onClick={handleCellCollapser}
|
|
311
|
+
/>
|
|
312
|
+
<div className="libro-cell-hidden">
|
|
313
|
+
<ContentMore />
|
|
314
|
+
</div>
|
|
315
|
+
</>
|
|
316
|
+
);
|
|
317
|
+
};
|
|
318
|
+
|
|
319
|
+
const ExecuteTooltipArea = memo(function ExecuteTooltipArea(props: {
|
|
320
|
+
isMouseOverDragArea: boolean | undefined;
|
|
321
|
+
cell: CellView;
|
|
322
|
+
}) {
|
|
323
|
+
const { isMouseOverDragArea, cell } = props;
|
|
324
|
+
const observableCell = useObserve(cell);
|
|
325
|
+
|
|
326
|
+
const executable = ExecutableCellModel.is(observableCell.model);
|
|
327
|
+
const executeState =
|
|
328
|
+
ExecutableCellModel.is(observableCell.model) && !observableCell.model.executing
|
|
329
|
+
? observableCell.model.executeCount || ' '
|
|
330
|
+
: '*';
|
|
331
|
+
return (
|
|
332
|
+
<>
|
|
333
|
+
{executable && !isMouseOverDragArea && (
|
|
334
|
+
<div className="libro-execute-tooltip-area">
|
|
335
|
+
<pre className="libro-execute-state-tip">{`[${executeState}]:`}</pre>
|
|
336
|
+
</div>
|
|
337
|
+
)}
|
|
338
|
+
</>
|
|
339
|
+
);
|
|
340
|
+
});
|
|
341
|
+
|
|
342
|
+
export const DndCellItemContent = memo(function DndCellItemContent(props: {
|
|
343
|
+
cell: CellView;
|
|
344
|
+
}) {
|
|
345
|
+
const instance = useInject<LibroView>(ViewInstance);
|
|
346
|
+
const { cell } = props;
|
|
347
|
+
const observableCell = useObserve(cell);
|
|
348
|
+
const isCollapsible = CellCollapsible.is(observableCell);
|
|
349
|
+
const hasCellHidden = useMemo(() => {
|
|
350
|
+
return observableCell.hasCellHidden();
|
|
351
|
+
}, [observableCell]);
|
|
352
|
+
|
|
353
|
+
return (
|
|
354
|
+
<>
|
|
355
|
+
{hasCellHidden && <HideCellContent cell={observableCell} />}
|
|
356
|
+
{!hasCellHidden && (
|
|
357
|
+
<>
|
|
358
|
+
{instance.collapserVisible && isCollapsible && (
|
|
359
|
+
<div
|
|
360
|
+
className="libro-markdown-collapser"
|
|
361
|
+
onClick={() => {
|
|
362
|
+
instance.collapseCell(observableCell, !observableCell.headingCollapsed);
|
|
363
|
+
}}
|
|
364
|
+
>
|
|
365
|
+
{observableCell.headingCollapsed ? <ArrowRight /> : <ArrowDown />}
|
|
366
|
+
</div>
|
|
367
|
+
)}
|
|
368
|
+
<CellInput cell={observableCell} />
|
|
369
|
+
<CellOutput cell={observableCell} />
|
|
370
|
+
</>
|
|
371
|
+
)}
|
|
372
|
+
</>
|
|
373
|
+
);
|
|
374
|
+
});
|
|
375
|
+
|
|
376
|
+
export const DndCellItemContainer = memo(function DndCellItemContainer(
|
|
377
|
+
props: DndItemProps,
|
|
378
|
+
) {
|
|
379
|
+
const { isDrag, isMouseOverDragArea, cell } = props;
|
|
380
|
+
|
|
381
|
+
const [topToolbarVisible] = useConfigurationValue(CellTopToolbarSetting);
|
|
382
|
+
const [sideToolbarVisible] = useConfigurationValue(CellSideToolbarVisible);
|
|
383
|
+
|
|
384
|
+
const instance = useInject<LibroView>(ViewInstance);
|
|
385
|
+
const isActive = instance.activeCell?.id === cell.id;
|
|
386
|
+
const topToolbarArgs = useMemo(() => {
|
|
387
|
+
return [cell, instance, LibroToolbarArea.CellTop];
|
|
388
|
+
}, [cell, instance]);
|
|
389
|
+
|
|
390
|
+
const rightToolbarArgs = useMemo(() => {
|
|
391
|
+
return [cell, instance, LibroToolbarArea.CellRight];
|
|
392
|
+
}, [cell, instance]);
|
|
393
|
+
if (!isLibroCellModel(cell.model)) {
|
|
394
|
+
return null;
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
return (
|
|
398
|
+
<>
|
|
399
|
+
{topToolbarVisible && isActive && (
|
|
400
|
+
<div className="libro-cell-top-toolbar">
|
|
401
|
+
<ToolbarRender data={topToolbarArgs} />
|
|
402
|
+
</div>
|
|
403
|
+
)}
|
|
404
|
+
<ExecuteTooltipArea cell={cell} isMouseOverDragArea={isMouseOverDragArea} />
|
|
405
|
+
<DndCellItemContent cell={cell} />
|
|
406
|
+
{sideToolbarVisible && (
|
|
407
|
+
<div
|
|
408
|
+
className="libro-cell-right-toolbar"
|
|
409
|
+
tabIndex={0}
|
|
410
|
+
onFocus={(e) => {
|
|
411
|
+
e.stopPropagation();
|
|
412
|
+
}}
|
|
413
|
+
>
|
|
414
|
+
{isActive && !isDrag && instance.model.cellsEditable && (
|
|
415
|
+
<ToolbarRender
|
|
416
|
+
data={rightToolbarArgs}
|
|
417
|
+
tooltip={{ placement: LibroToolbarArea.CellRight }}
|
|
418
|
+
/>
|
|
419
|
+
)}
|
|
420
|
+
</div>
|
|
421
|
+
)}
|
|
422
|
+
</>
|
|
423
|
+
);
|
|
424
|
+
});
|
|
425
|
+
const DndCellItemRenderInner = forwardRef(function DndCellItemRender(
|
|
426
|
+
props: DndItemProps,
|
|
427
|
+
ref: React.ForwardedRef<HTMLDivElement>,
|
|
428
|
+
) {
|
|
429
|
+
const { isDrag, isMouseOverDragArea, cell, isDragOver } = props;
|
|
430
|
+
const observableCell = useObserve(cell);
|
|
431
|
+
const instance = useInject<LibroView>(ViewInstance);
|
|
432
|
+
const isActive = instance.activeCell?.id === observableCell.id;
|
|
433
|
+
const hasErrorOutputs = hasErrorOutput(observableCell);
|
|
434
|
+
const hasCellHidden = useMemo(() => {
|
|
435
|
+
return observableCell.hasCellHidden();
|
|
436
|
+
}, [observableCell]);
|
|
437
|
+
|
|
438
|
+
const classNames = [
|
|
439
|
+
'libro-dnd-cell',
|
|
440
|
+
{ active: isActive },
|
|
441
|
+
{ 'command-mode': instance.model.commandMode },
|
|
442
|
+
{ 'edit-mode': !instance.model.commandMode },
|
|
443
|
+
{ error: hasErrorOutputs },
|
|
444
|
+
{
|
|
445
|
+
hidden: hasCellHidden,
|
|
446
|
+
},
|
|
447
|
+
];
|
|
448
|
+
if (observableCell.wrapperCls) {
|
|
449
|
+
classNames.push(observableCell.wrapperCls);
|
|
450
|
+
}
|
|
451
|
+
return (
|
|
452
|
+
<div className="libro-dnd-cell-border">
|
|
453
|
+
<div className={classnames(classNames)} ref={ref}>
|
|
454
|
+
<DndCellItemContainer
|
|
455
|
+
cell={observableCell}
|
|
456
|
+
isDrag={isDrag}
|
|
457
|
+
isDragOver={isDragOver}
|
|
458
|
+
isMouseOverDragArea={isMouseOverDragArea}
|
|
459
|
+
// ref={ref}
|
|
460
|
+
/>
|
|
461
|
+
</div>
|
|
462
|
+
</div>
|
|
463
|
+
);
|
|
464
|
+
});
|
|
465
|
+
export const DndCellItemRender = memo(DndCellItemRenderInner);
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
/* eslint-disable react-hooks/exhaustive-deps */
|
|
2
|
+
import { useInject, ViewInstance } from '@difizen/mana-app';
|
|
3
|
+
import { ViewRender } from '@difizen/mana-app';
|
|
4
|
+
import type { FC, CSSProperties } from 'react';
|
|
5
|
+
import { useState, useEffect, memo } from 'react';
|
|
6
|
+
import type { XYCoord } from 'react-dnd';
|
|
7
|
+
import { useDragLayer } from 'react-dnd';
|
|
8
|
+
|
|
9
|
+
import type { CellService } from '../../cell/index.js';
|
|
10
|
+
import { LibroCellService } from '../../cell/index.js';
|
|
11
|
+
import type { CellView } from '../../libro-protocol.js';
|
|
12
|
+
import type { LibroView } from '../../libro-view.js';
|
|
13
|
+
|
|
14
|
+
export interface SelectionPreviewProps {
|
|
15
|
+
activeCell: CellView;
|
|
16
|
+
}
|
|
17
|
+
const layerStyles: CSSProperties = {
|
|
18
|
+
position: 'fixed',
|
|
19
|
+
pointerEvents: 'none',
|
|
20
|
+
zIndex: 1000,
|
|
21
|
+
left: 0,
|
|
22
|
+
top: 0,
|
|
23
|
+
width: '300px',
|
|
24
|
+
height: '50px',
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
const getItemStyles = (currentOffset: XYCoord | null) => {
|
|
28
|
+
if (!currentOffset) {
|
|
29
|
+
return {
|
|
30
|
+
display: 'none',
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const { x, y } = currentOffset;
|
|
35
|
+
|
|
36
|
+
const transform = `translate(${x}px, ${y}px)`;
|
|
37
|
+
return {
|
|
38
|
+
transform,
|
|
39
|
+
WebkitTransform: transform,
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
const MultipleSelectionPreview: FC<{ activeCell: CellView }> = ({ activeCell }) => {
|
|
44
|
+
const cellService = useInject<CellService>(LibroCellService);
|
|
45
|
+
const [multipleSelectionPreview, setMultipleSelectionPreview] = useState<CellView>();
|
|
46
|
+
useEffect(() => {
|
|
47
|
+
cellService
|
|
48
|
+
.getOrCreateView(activeCell.model.options, activeCell.parent.id)
|
|
49
|
+
.then((view) => {
|
|
50
|
+
setMultipleSelectionPreview(view);
|
|
51
|
+
return;
|
|
52
|
+
})
|
|
53
|
+
.catch((e) => {
|
|
54
|
+
//
|
|
55
|
+
});
|
|
56
|
+
}, []);
|
|
57
|
+
|
|
58
|
+
return (
|
|
59
|
+
<div className="libro-dnd-multiple-selection-preview">
|
|
60
|
+
<div className="libro-dnd-active-selection">
|
|
61
|
+
{multipleSelectionPreview && <ViewRender view={multipleSelectionPreview} />}
|
|
62
|
+
</div>
|
|
63
|
+
<div className="libro-dnd-cascading-multiple-selection" />
|
|
64
|
+
</div>
|
|
65
|
+
);
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
export const MultipleSelectionPreviewMemo: FC<SelectionPreviewProps> = memo(
|
|
69
|
+
MultipleSelectionPreview,
|
|
70
|
+
);
|
|
71
|
+
|
|
72
|
+
const SingleSelectionDragPreview: FC<{ activeCell: CellView }> = ({ activeCell }) => {
|
|
73
|
+
const cellService = useInject<CellService>(LibroCellService);
|
|
74
|
+
const [singleSelectionPreview, setSingleSelectionPreview] = useState<CellView>();
|
|
75
|
+
useEffect(() => {
|
|
76
|
+
cellService
|
|
77
|
+
.getOrCreateView(
|
|
78
|
+
{
|
|
79
|
+
...activeCell.model.options,
|
|
80
|
+
modelId: activeCell.model.id,
|
|
81
|
+
singleSelectionDragPreview: true,
|
|
82
|
+
},
|
|
83
|
+
activeCell.parent.id,
|
|
84
|
+
)
|
|
85
|
+
.then((view) => {
|
|
86
|
+
setSingleSelectionPreview(view);
|
|
87
|
+
return;
|
|
88
|
+
})
|
|
89
|
+
.catch((e) => {
|
|
90
|
+
//
|
|
91
|
+
});
|
|
92
|
+
}, []);
|
|
93
|
+
|
|
94
|
+
return (
|
|
95
|
+
<div className="libro-dnd-active-selection">
|
|
96
|
+
{singleSelectionPreview && <ViewRender view={singleSelectionPreview} />}
|
|
97
|
+
</div>
|
|
98
|
+
);
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
export const SingleSelectionPreviewMemo: FC<SelectionPreviewProps> = memo(
|
|
102
|
+
SingleSelectionDragPreview,
|
|
103
|
+
);
|
|
104
|
+
|
|
105
|
+
export const CustomDragLayer = () => {
|
|
106
|
+
const { isDragging, item, currentOffset } = useDragLayer((monitor) => ({
|
|
107
|
+
item: monitor.getItem(),
|
|
108
|
+
itemType: monitor.getItemType(),
|
|
109
|
+
currentOffset: monitor.getClientOffset(),
|
|
110
|
+
isDragging: monitor.isDragging(),
|
|
111
|
+
}));
|
|
112
|
+
|
|
113
|
+
const instance = useInject<LibroView>(ViewInstance);
|
|
114
|
+
|
|
115
|
+
function renderItem() {
|
|
116
|
+
const isItemSelected =
|
|
117
|
+
instance.model.selections.findIndex((select) => select.id === item.cell.id) >= 0;
|
|
118
|
+
if (instance.model.selections.length !== 0 && isItemSelected) {
|
|
119
|
+
return (
|
|
120
|
+
<>
|
|
121
|
+
{instance.model.active && (
|
|
122
|
+
<MultipleSelectionPreviewMemo activeCell={instance.model.active} />
|
|
123
|
+
)}
|
|
124
|
+
</>
|
|
125
|
+
);
|
|
126
|
+
}
|
|
127
|
+
return (
|
|
128
|
+
<>
|
|
129
|
+
{instance.model.active && (
|
|
130
|
+
<SingleSelectionPreviewMemo activeCell={instance.model.active} />
|
|
131
|
+
)}
|
|
132
|
+
</>
|
|
133
|
+
);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
if (!isDragging) {
|
|
137
|
+
return null;
|
|
138
|
+
}
|
|
139
|
+
return (
|
|
140
|
+
<div className="libro-custom-drag-layer" style={layerStyles}>
|
|
141
|
+
<div style={getItemStyles(currentOffset)}>{renderItem()}</div>
|
|
142
|
+
</div>
|
|
143
|
+
);
|
|
144
|
+
};
|