@difizen/libro-core 0.3.3 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/add-cell/libro-add-cell-module.d.ts +1 -1
- package/es/add-cell/libro-add-cell-module.d.ts.map +1 -1
- package/es/add-cell/libro-add-cell-module.js +1 -1
- package/es/add-cell/libro-add-cell-slot-contribution.d.ts +1 -1
- package/es/add-cell/libro-add-cell-slot-contribution.d.ts.map +1 -1
- package/es/add-cell/libro-add-cell-slot-contribution.js +2 -2
- package/es/add-cell/libro-add-cell-view.d.ts +1 -1
- package/es/add-cell/libro-add-cell-view.d.ts.map +1 -1
- package/es/add-cell/libro-add-cell-view.js +1 -1
- package/es/cell/libro-cell-contribution.js +1 -1
- package/es/cell/libro-cell-model.d.ts +1 -1
- package/es/cell/libro-cell-model.d.ts.map +1 -1
- package/es/cell/libro-cell-model.js +2 -2
- package/es/cell/libro-cell-module.d.ts +1 -1
- package/es/cell/libro-cell-module.d.ts.map +1 -1
- package/es/cell/libro-cell-module.js +1 -1
- package/es/cell/libro-cell-protocol.d.ts +2 -2
- package/es/cell/libro-cell-protocol.d.ts.map +1 -1
- package/es/cell/libro-cell-protocol.js +1 -1
- package/es/cell/libro-cell-service.d.ts +2 -2
- package/es/cell/libro-cell-service.d.ts.map +1 -1
- package/es/cell/libro-cell-service.js +3 -3
- package/es/cell/libro-cell-view.d.ts +4 -4
- package/es/cell/libro-cell-view.d.ts.map +1 -1
- package/es/cell/libro-cell-view.js +6 -6
- package/es/cell/libro-edit-cell-view.d.ts +1 -1
- package/es/cell/libro-edit-cell-view.d.ts.map +1 -1
- package/es/cell/libro-edit-cell-view.js +1 -1
- package/es/cell/libro-executable-cell-model.d.ts +1 -1
- package/es/cell/libro-executable-cell-model.d.ts.map +1 -1
- package/es/cell/libro-executable-cell-view.js +3 -3
- package/es/collapse-service.js +1 -1
- package/es/command/document-commands.d.ts +1 -1
- package/es/command/document-commands.d.ts.map +1 -1
- package/es/command/kernel-command.d.ts +1 -1
- package/es/command/kernel-command.d.ts.map +1 -1
- package/es/command/kernel-command.js +1 -1
- package/es/command/libro-command-contribution.d.ts +2 -2
- package/es/command/libro-command-contribution.d.ts.map +1 -1
- package/es/command/libro-command-contribution.js +2 -2
- package/es/command/libro-command-register.d.ts +1 -1
- package/es/command/libro-command-register.d.ts.map +1 -1
- package/es/command/libro-command-register.js +1 -1
- package/es/command/module.d.ts +1 -1
- package/es/command/module.d.ts.map +1 -1
- package/es/command/module.js +1 -1
- package/es/command/notebook-commands.d.ts +1 -1
- package/es/command/notebook-commands.d.ts.map +1 -1
- package/es/command/notebook-commands.js +1 -1
- package/es/components/dnd-cell-item-render.js +2 -2
- package/es/components/dnd-component/default-dnd-content.d.ts.map +1 -1
- package/es/components/dnd-component/default-dnd-content.js +90 -167
- package/es/components/dnd-component/dnd-list.d.ts +12 -0
- package/es/components/dnd-component/dnd-list.d.ts.map +1 -1
- package/es/components/dnd-component/dnd-list.js +307 -63
- package/es/components/dnd-component/index.d.ts +0 -2
- package/es/components/dnd-component/index.d.ts.map +1 -1
- package/es/components/dnd-component/index.js +0 -2
- package/es/components/dnd-component/index.less +84 -0
- package/es/components/dnd-component/virtualized-manager.d.ts.map +1 -1
- package/es/components/dnd-component/virtualized-manager.js +3 -9
- package/es/components/libro-component.js +2 -2
- package/es/components/libro-side-toolbar-menu.js +2 -2
- package/es/components/libro-view-header.js +1 -1
- package/es/content/libro-content-contribution.js +1 -1
- package/es/content/libro-content-module.d.ts +1 -1
- package/es/content/libro-content-module.d.ts.map +1 -1
- package/es/content/libro-content-module.js +1 -1
- package/es/content/libro-content-protocol.d.ts +1 -1
- package/es/content/libro-content-protocol.d.ts.map +1 -1
- package/es/content/libro-content-protocol.js +1 -1
- package/es/content/libro-content-service.d.ts +1 -1
- package/es/content/libro-content-service.d.ts.map +1 -1
- package/es/content/libro-content-service.js +1 -1
- package/es/content/libro-save-content-contribution.js +1 -1
- package/es/formatter/libro-formatter-json-contribution.d.ts +1 -1
- package/es/formatter/libro-formatter-json-contribution.js +1 -1
- package/es/formatter/libro-formatter-manager.d.ts +1 -1
- package/es/formatter/libro-formatter-manager.d.ts.map +1 -1
- package/es/formatter/libro-formatter-manager.js +1 -1
- package/es/formatter/libro-formatter-module.d.ts +1 -1
- package/es/formatter/libro-formatter-module.d.ts.map +1 -1
- package/es/formatter/libro-formatter-module.js +1 -1
- package/es/formatter/libro-formatter-protocol.d.ts +1 -1
- package/es/formatter/libro-formatter-protocol.d.ts.map +1 -1
- package/es/formatter/libro-formatter-protocol.js +1 -1
- package/es/formatter/libro-formatter-string-contribution.d.ts +1 -1
- package/es/formatter/libro-formatter-string-contribution.js +1 -1
- package/es/formatter/libro-formatter-trans-default-contribution.js +1 -1
- package/es/index.d.ts +2 -0
- package/es/index.d.ts.map +1 -1
- package/es/index.js +2 -0
- package/es/index.less +0 -22
- package/es/libro-context-key.d.ts +3 -3
- package/es/libro-context-key.d.ts.map +1 -1
- package/es/libro-context-key.js +2 -2
- package/es/libro-keybind-registry.d.ts +1 -1
- package/es/libro-keybind-registry.d.ts.map +1 -1
- package/es/libro-keybind-registry.js +2 -2
- package/es/libro-model.d.ts +9 -9
- package/es/libro-model.d.ts.map +1 -1
- package/es/libro-model.js +4 -4
- package/es/libro-protocol.d.ts +2 -2
- package/es/libro-protocol.d.ts.map +1 -1
- package/es/libro-service.d.ts +13 -13
- package/es/libro-service.d.ts.map +1 -1
- package/es/libro-service.js +4 -4
- package/es/libro-setting-contribution.d.ts +2 -2
- package/es/libro-setting-contribution.d.ts.map +1 -1
- package/es/libro-setting-contribution.js +1 -1
- package/es/libro-setting.d.ts +1 -1
- package/es/libro-setting.d.ts.map +1 -1
- package/es/libro-setting.js +1 -1
- package/es/libro-view-tracker.js +1 -1
- package/es/libro-view.d.ts +9 -9
- package/es/libro-view.d.ts.map +1 -1
- package/es/libro-view.js +8 -12
- package/es/libro-workspace-service.d.ts +1 -1
- package/es/libro-workspace-service.d.ts.map +1 -1
- package/es/libro-workspace-service.js +2 -2
- package/es/module.d.ts +1 -1
- package/es/module.d.ts.map +1 -1
- package/es/module.js +2 -2
- package/es/output/output-area.d.ts +4 -4
- package/es/output/output-area.d.ts.map +1 -1
- package/es/output/output-area.js +2 -2
- package/es/output/output-contribution.d.ts +1 -1
- package/es/output/output-contribution.d.ts.map +1 -1
- package/es/output/output-contribution.js +1 -1
- package/es/output/output-model.d.ts +1 -1
- package/es/output/output-model.d.ts.map +1 -1
- package/es/output/output-model.js +2 -2
- package/es/output/output-module.d.ts +1 -1
- package/es/output/output-module.d.ts.map +1 -1
- package/es/output/output-module.js +1 -1
- package/es/output/output-protocol.d.ts +3 -3
- package/es/output/output-protocol.d.ts.map +1 -1
- package/es/output/output-protocol.js +1 -1
- package/es/settings/module.d.ts +1 -1
- package/es/settings/module.d.ts.map +1 -1
- package/es/settings/module.js +1 -1
- package/es/settings/setting-editor/configuration-panel-view.d.ts +2 -2
- package/es/settings/setting-editor/configuration-panel-view.d.ts.map +1 -1
- package/es/settings/setting-editor/configuration-panel-view.js +1 -1
- package/es/settings/setting-editor/configuration-render-contribution.d.ts +2 -2
- package/es/settings/setting-editor/configuration-render-contribution.d.ts.map +1 -1
- package/es/settings/setting-editor/configuration-render-contribution.js +1 -1
- package/es/settings/setting-editor/default-node-render.d.ts +1 -1
- package/es/settings/setting-editor/default-node-render.d.ts.map +1 -1
- package/es/settings/setting-editor/default-node-render.js +1 -1
- package/es/settings/setting-editor/module.d.ts +1 -1
- package/es/settings/setting-editor/module.d.ts.map +1 -1
- package/es/settings/setting-editor/module.js +1 -1
- package/es/settings/setting-editor/setting-editor-view.d.ts +1 -1
- package/es/settings/setting-editor/setting-editor-view.d.ts.map +1 -1
- package/es/settings/setting-editor/setting-editor-view.js +2 -2
- package/es/settings/setting-editor/setting-tree-service.d.ts +3 -3
- package/es/settings/setting-editor/setting-tree-service.d.ts.map +1 -1
- package/es/settings/setting-editor/setting-tree-service.js +2 -2
- package/es/settings/setting-editor/setting-tree-view.d.ts +2 -2
- package/es/settings/setting-editor/setting-tree-view.d.ts.map +1 -1
- package/es/settings/setting-editor/setting-tree-view.js +2 -2
- package/es/settings/settings-contribution.d.ts +3 -3
- package/es/settings/settings-contribution.d.ts.map +1 -1
- package/es/settings/settings-contribution.js +2 -2
- package/es/settings/settings-modal.d.ts +1 -1
- package/es/settings/settings-modal.d.ts.map +1 -1
- package/es/settings/settings-modal.js +3 -3
- package/es/settings/settings-protocol.d.ts +1 -1
- package/es/settings/settings-protocol.d.ts.map +1 -1
- package/es/slot/libro-slot-manager.d.ts +2 -2
- package/es/slot/libro-slot-manager.d.ts.map +1 -1
- package/es/slot/libro-slot-manager.js +2 -2
- package/es/slot/libro-slot-protocol.d.ts +2 -2
- package/es/slot/libro-slot-protocol.d.ts.map +1 -1
- package/es/slot/libro-slot-protocol.js +1 -1
- package/es/slot/libro-slot-view.d.ts +2 -2
- package/es/slot/libro-slot-view.d.ts.map +1 -1
- package/es/slot/libro-slot-view.js +3 -3
- package/es/slot/module.d.ts +1 -1
- package/es/slot/module.d.ts.map +1 -1
- package/es/slot/module.js +1 -1
- package/es/theme/libro-color-registry.d.ts +2 -2
- package/es/theme/libro-color-registry.d.ts.map +1 -1
- package/es/theme/libro-color-registry.js +2 -2
- package/es/toolbar/all-outputs-scroll-icon.js +1 -1
- package/es/toolbar/change-cell-to-selector.js +1 -1
- package/es/toolbar/hide-all-selector.js +2 -2
- package/es/toolbar/libro-toolbar.d.ts +2 -2
- package/es/toolbar/libro-toolbar.d.ts.map +1 -1
- package/es/toolbar/libro-toolbar.js +3 -3
- package/es/toolbar/module.d.ts +1 -1
- package/es/toolbar/module.d.ts.map +1 -1
- package/es/toolbar/module.js +1 -1
- package/es/toolbar/restart-clear-outputs-contribution.d.ts +2 -2
- package/es/toolbar/restart-clear-outputs-contribution.d.ts.map +1 -1
- package/es/toolbar/restart-clear-outputs-contribution.js +1 -1
- package/es/toolbar/restart-clear-outputs-modal.d.ts +1 -1
- package/es/toolbar/restart-clear-outputs-modal.d.ts.map +1 -1
- package/es/toolbar/restart-clear-outputs-modal.js +1 -1
- package/es/toolbar/save-icon.js +1 -1
- package/es/toolbar/shutdown-contribution.d.ts +2 -2
- package/es/toolbar/shutdown-contribution.d.ts.map +1 -1
- package/es/toolbar/shutdown-contribution.js +1 -1
- package/es/toolbar/shutdown-modal.d.ts +1 -1
- package/es/toolbar/shutdown-modal.d.ts.map +1 -1
- package/es/toolbar/side-toolar-more-select.js +4 -4
- package/es/utils/index.js +1 -1
- package/es/virtualized-manager-helper.js +1 -1
- package/es/virtualized-manager.d.ts.map +1 -1
- package/es/virtualized-manager.js +2 -9
- package/package.json +10 -9
- package/src/add-cell/libro-add-cell-module.ts +1 -1
- package/src/add-cell/libro-add-cell-slot-contribution.ts +2 -2
- package/src/add-cell/libro-add-cell-view.tsx +1 -1
- package/src/cell/libro-cell-contribution.ts +1 -1
- package/src/cell/libro-cell-model.ts +2 -2
- package/src/cell/libro-cell-module.ts +1 -1
- package/src/cell/libro-cell-protocol.ts +2 -2
- package/src/cell/libro-cell-service.ts +4 -4
- package/src/cell/libro-cell-view.tsx +7 -7
- package/src/cell/libro-edit-cell-view.tsx +1 -1
- package/src/cell/libro-executable-cell-model.ts +1 -1
- package/src/cell/libro-executable-cell-view.ts +3 -3
- package/src/collapse-service.ts +1 -1
- package/src/command/document-commands.ts +1 -1
- package/src/command/kernel-command.ts +2 -2
- package/src/command/libro-command-contribution.ts +3 -3
- package/src/command/libro-command-register.ts +2 -2
- package/src/command/module.ts +1 -1
- package/src/command/notebook-commands.ts +2 -2
- package/src/components/dnd-cell-item-render.tsx +2 -2
- package/src/components/dnd-component/default-dnd-content.tsx +101 -165
- package/src/components/dnd-component/dnd-list.tsx +309 -35
- package/src/components/dnd-component/index.less +84 -0
- package/src/components/dnd-component/index.tsx +0 -2
- package/src/components/dnd-component/virtualized-manager.ts +11 -8
- package/src/components/libro-component.tsx +2 -2
- package/src/components/libro-side-toolbar-menu.tsx +3 -3
- package/src/components/libro-view-header.tsx +1 -1
- package/src/content/libro-content-contribution.ts +1 -1
- package/src/content/libro-content-module.ts +1 -1
- package/src/content/libro-content-protocol.ts +1 -1
- package/src/content/libro-content-service.ts +2 -2
- package/src/content/libro-save-content-contribution.ts +1 -1
- package/src/formatter/libro-formatter-json-contribution.ts +1 -1
- package/src/formatter/libro-formatter-manager.ts +2 -2
- package/src/formatter/libro-formatter-module.ts +1 -1
- package/src/formatter/libro-formatter-protocol.ts +1 -1
- package/src/formatter/libro-formatter-string-contribution.ts +1 -1
- package/src/formatter/libro-formatter-trans-default-contribution.ts +1 -1
- package/src/index.less +0 -22
- package/src/index.tsx +3 -0
- package/src/libro-context-key.ts +4 -4
- package/src/libro-keybind-registry.ts +2 -2
- package/src/libro-model.ts +4 -4
- package/src/libro-protocol.ts +2 -2
- package/src/libro-service.ts +5 -5
- package/src/libro-setting-contribution.ts +1 -1
- package/src/libro-setting.ts +2 -2
- package/src/libro-view-tracker.ts +1 -1
- package/src/libro-view.tsx +8 -18
- package/src/libro-workspace-service.ts +2 -2
- package/src/module.ts +2 -2
- package/src/output/output-area.tsx +3 -3
- package/src/output/output-contribution.ts +1 -1
- package/src/output/output-model.tsx +2 -2
- package/src/output/output-module.ts +1 -1
- package/src/output/output-protocol.ts +3 -3
- package/src/settings/module.ts +1 -1
- package/src/settings/setting-editor/configuration-panel-view.tsx +2 -2
- package/src/settings/setting-editor/configuration-render-contribution.ts +2 -2
- package/src/settings/setting-editor/default-node-render.tsx +2 -2
- package/src/settings/setting-editor/module.ts +1 -1
- package/src/settings/setting-editor/setting-editor-view.tsx +2 -2
- package/src/settings/setting-editor/setting-tree-service.ts +3 -3
- package/src/settings/setting-editor/setting-tree-view.tsx +3 -3
- package/src/settings/settings-contribution.tsx +7 -3
- package/src/settings/settings-modal.tsx +4 -4
- package/src/settings/settings-protocol.ts +1 -1
- package/src/slot/libro-slot-manager.ts +3 -3
- package/src/slot/libro-slot-protocol.ts +2 -2
- package/src/slot/libro-slot-view.tsx +9 -4
- package/src/slot/module.ts +1 -1
- package/src/theme/libro-color-registry.ts +3 -3
- package/src/toolbar/all-outputs-scroll-icon.tsx +1 -1
- package/src/toolbar/change-cell-to-selector.tsx +2 -2
- package/src/toolbar/hide-all-selector.tsx +3 -3
- package/src/toolbar/libro-toolbar.tsx +4 -4
- package/src/toolbar/module.ts +1 -1
- package/src/toolbar/restart-clear-outputs-contribution.tsx +1 -1
- package/src/toolbar/restart-clear-outputs-modal.tsx +2 -2
- package/src/toolbar/save-icon.tsx +2 -2
- package/src/toolbar/shutdown-contribution.tsx +1 -1
- package/src/toolbar/shutdown-modal.tsx +1 -1
- package/src/toolbar/side-toolar-more-select.tsx +5 -5
- package/src/utils/index.ts +1 -1
- package/src/virtualized-manager-helper.ts +1 -1
- package/src/virtualized-manager.ts +10 -8
- package/es/components/dnd-component/custom-drag-layer.d.ts +0 -9
- package/es/components/dnd-component/custom-drag-layer.d.ts.map +0 -1
- package/es/components/dnd-component/custom-drag-layer.js +0 -140
- package/es/components/dnd-component/dnd-context.d.ts +0 -3
- package/es/components/dnd-component/dnd-context.d.ts.map +0 -1
- package/es/components/dnd-component/dnd-context.js +0 -20
- package/src/components/dnd-component/custom-drag-layer.tsx +0 -144
- package/src/components/dnd-component/dnd-context.tsx +0 -28
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { ICodeCell } from '@difizen/libro-common';
|
|
2
|
-
import { watch } from '@difizen/
|
|
3
|
-
import { ViewOption } from '@difizen/
|
|
4
|
-
import { inject } from '@difizen/
|
|
2
|
+
import { watch } from '@difizen/libro-common/app';
|
|
3
|
+
import { ViewOption } from '@difizen/libro-common/app';
|
|
4
|
+
import { inject } from '@difizen/libro-common/app';
|
|
5
5
|
|
|
6
6
|
import type { CellModel } from '../libro-protocol.js';
|
|
7
7
|
import type { CellViewOptions } from '../libro-protocol.js';
|
package/src/collapse-service.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { Command } from '@difizen/
|
|
2
|
-
import { l10n } from '@difizen/
|
|
1
|
+
import type { Command } from '@difizen/libro-common/app';
|
|
2
|
+
import { l10n } from '@difizen/libro-common/l10n';
|
|
3
3
|
|
|
4
4
|
export const KernelCommands: Record<string, Command & { keybind?: string }> = {
|
|
5
5
|
//#region libro command
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { MIME } from '@difizen/libro-common';
|
|
2
|
-
import type { CommandRegistry } from '@difizen/
|
|
2
|
+
import type { CommandRegistry } from '@difizen/libro-common/app';
|
|
3
3
|
import {
|
|
4
4
|
inject,
|
|
5
5
|
ModalService,
|
|
6
6
|
singleton,
|
|
7
7
|
CommandContribution,
|
|
8
|
-
} from '@difizen/
|
|
9
|
-
import { equals } from '@difizen/
|
|
8
|
+
} from '@difizen/libro-common/app';
|
|
9
|
+
import { equals } from '@difizen/libro-common/app';
|
|
10
10
|
import { v4 } from 'uuid';
|
|
11
11
|
|
|
12
12
|
import { LibroCellView, ExecutableCellModel, EditorCellView } from '../cell/index.js';
|
|
@@ -4,8 +4,8 @@ import type {
|
|
|
4
4
|
CommandHandlerWithContext,
|
|
5
5
|
CommandRegistry,
|
|
6
6
|
KeybindingRegistry,
|
|
7
|
-
} from '@difizen/
|
|
8
|
-
import { inject, singleton } from '@difizen/
|
|
7
|
+
} from '@difizen/libro-common/app';
|
|
8
|
+
import { inject, singleton } from '@difizen/libro-common/app';
|
|
9
9
|
|
|
10
10
|
import type { CellView, NotebookView } from '../libro-protocol.js';
|
|
11
11
|
import { LibroContextKeys } from '../libro-protocol.js';
|
package/src/command/module.ts
CHANGED
|
@@ -9,8 +9,8 @@ import {
|
|
|
9
9
|
// ReloadOutlined,
|
|
10
10
|
PoweroffOutlined,
|
|
11
11
|
} from '@ant-design/icons';
|
|
12
|
-
import type { Command } from '@difizen/
|
|
13
|
-
import { l10n } from '@difizen/
|
|
12
|
+
import type { Command } from '@difizen/libro-common/app';
|
|
13
|
+
import { l10n } from '@difizen/libro-common/l10n';
|
|
14
14
|
|
|
15
15
|
import {
|
|
16
16
|
Undo,
|
|
@@ -8,8 +8,8 @@ import {
|
|
|
8
8
|
useObserve,
|
|
9
9
|
ViewInstance,
|
|
10
10
|
ViewRender,
|
|
11
|
-
} from '@difizen/
|
|
12
|
-
import { l10n } from '@difizen/
|
|
11
|
+
} from '@difizen/libro-common/app';
|
|
12
|
+
import { l10n } from '@difizen/libro-common/l10n';
|
|
13
13
|
import { Tooltip } from 'antd';
|
|
14
14
|
import classnames from 'classnames';
|
|
15
15
|
import type { FC } from 'react';
|
|
@@ -1,31 +1,27 @@
|
|
|
1
1
|
/* eslint-disable react-hooks/exhaustive-deps */
|
|
2
|
-
import { getOrigin, useInject, ViewInstance } from '@difizen/
|
|
3
|
-
import { useConfigurationValue } from '@difizen/
|
|
2
|
+
import { getOrigin, useInject, ViewInstance } from '@difizen/libro-common/app';
|
|
3
|
+
import { useConfigurationValue } from '@difizen/libro-common/app';
|
|
4
4
|
import { Button } from 'antd';
|
|
5
|
-
import type { Identifier } from 'dnd-core';
|
|
6
5
|
import React, {
|
|
7
6
|
useCallback,
|
|
8
|
-
useEffect,
|
|
9
7
|
useLayoutEffect,
|
|
10
8
|
useMemo,
|
|
11
9
|
useRef,
|
|
12
10
|
useState,
|
|
13
11
|
forwardRef,
|
|
12
|
+
useContext,
|
|
14
13
|
} from 'react';
|
|
15
|
-
import { useDrag, useDragDropManager, useDrop } from 'react-dnd';
|
|
16
|
-
import { getEmptyImage } from 'react-dnd-html5-backend';
|
|
17
14
|
import 'resize-observer-polyfill';
|
|
18
15
|
|
|
19
|
-
import type { CellService } from '../../cell/index.js';
|
|
20
|
-
import { LibroCellService } from '../../cell/index.js';
|
|
21
16
|
import { CellCollapsible } from '../../collapse-service.js';
|
|
22
|
-
import { DragAreaKey, isCellView } from '../../libro-protocol.js';
|
|
23
17
|
import type { CellView, DndContentProps } from '../../libro-protocol.js';
|
|
24
18
|
import { MultiSelectionWhenShiftClick } from '../../libro-setting.js';
|
|
25
19
|
import type { LibroView } from '../../libro-view.js';
|
|
26
20
|
import { HolderOutlined, PlusOutlined } from '../../material-from-designer.js';
|
|
27
21
|
import { BetweenCellProvider } from '../cell-protocol.js';
|
|
28
22
|
|
|
23
|
+
import { DragContext } from './dnd-list.js';
|
|
24
|
+
|
|
29
25
|
export interface Dragparams {
|
|
30
26
|
cell: CellView;
|
|
31
27
|
index: number;
|
|
@@ -42,11 +38,21 @@ export const DndCellContainer: React.FC<DndContentProps> = ({
|
|
|
42
38
|
MultiSelectionWhenShiftClick,
|
|
43
39
|
);
|
|
44
40
|
const BetweenCellContent = useInject<BetweenCellProvider>(BetweenCellProvider);
|
|
45
|
-
const
|
|
46
|
-
const
|
|
47
|
-
const dragDropMonitor = dragDropManager.getMonitor();
|
|
41
|
+
const [isMouseOverDragArea, setIsMouseOverDragArea] = useState(false);
|
|
42
|
+
const [isDragDown, setIsDragDown] = useState(false);
|
|
48
43
|
const ItemRender = getOrigin(instance.dndItemRender);
|
|
49
44
|
|
|
45
|
+
const {
|
|
46
|
+
dragOverIndex,
|
|
47
|
+
isDraging,
|
|
48
|
+
sourceIndex,
|
|
49
|
+
onDragStart,
|
|
50
|
+
onDragOver,
|
|
51
|
+
onDrop,
|
|
52
|
+
onDragEnd,
|
|
53
|
+
fragFromRef,
|
|
54
|
+
} = useContext(DragContext);
|
|
55
|
+
|
|
50
56
|
useLayoutEffect(() => {
|
|
51
57
|
if (typeof ref !== 'object') {
|
|
52
58
|
return () => {
|
|
@@ -119,174 +125,102 @@ export const DndCellContainer: React.FC<DndContentProps> = ({
|
|
|
119
125
|
return;
|
|
120
126
|
}
|
|
121
127
|
instance.model.selectCell(cell);
|
|
122
|
-
instance.model.selections
|
|
128
|
+
if (instance.model.selections.length !== 0) {
|
|
129
|
+
instance.model.selections = [];
|
|
130
|
+
}
|
|
123
131
|
}, [instance, cell]);
|
|
124
132
|
|
|
125
|
-
const
|
|
126
|
-
|
|
133
|
+
const isMultiSelected =
|
|
134
|
+
instance.model.selections.length !== 0 && instance.isSelected(cell);
|
|
135
|
+
|
|
136
|
+
const isDragOver = useMemo(() => {
|
|
137
|
+
return index === dragOverIndex;
|
|
138
|
+
}, [index, dragOverIndex]);
|
|
127
139
|
|
|
128
|
-
const
|
|
129
|
-
{
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
end() {
|
|
136
|
-
instance.isDragging = false;
|
|
137
|
-
if (scrollTimer.current) {
|
|
138
|
-
clearInterval(scrollTimer.current);
|
|
139
|
-
}
|
|
140
|
-
},
|
|
140
|
+
const handleDragStart = useCallback(
|
|
141
|
+
(e: React.DragEvent) => {
|
|
142
|
+
if (!instance.model.cellsEditable) {
|
|
143
|
+
e.preventDefault();
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
onDragStart?.(e, index);
|
|
141
147
|
},
|
|
142
|
-
[
|
|
148
|
+
[index, instance.model.cellsEditable, onDragStart],
|
|
143
149
|
);
|
|
144
150
|
|
|
145
|
-
const
|
|
146
|
-
|
|
147
|
-
|
|
151
|
+
const handleDragOver = useCallback(
|
|
152
|
+
(e: React.DragEvent) => {
|
|
153
|
+
//判断拖拽来源是否cell
|
|
154
|
+
if (fragFromRef.current !== 'cell') {
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
e.preventDefault();
|
|
158
|
+
instance.model.mouseMode = 'drag';
|
|
159
|
+
//判断是向下拖拽还是向上拖拽
|
|
160
|
+
if (sourceIndex! < index) {
|
|
161
|
+
setIsDragDown(true);
|
|
162
|
+
} else {
|
|
163
|
+
setIsDragDown(false);
|
|
164
|
+
}
|
|
165
|
+
onDragOver(e, index);
|
|
166
|
+
},
|
|
167
|
+
[fragFromRef, index, instance.model, onDragOver, sourceIndex],
|
|
168
|
+
);
|
|
148
169
|
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
const bottomLimit = bottom - 50;
|
|
160
|
-
if (y < topLimit) {
|
|
161
|
-
libroViewContent.scrollTop -= 0.5;
|
|
162
|
-
} else if (y > bottomLimit) {
|
|
163
|
-
libroViewContent.scrollTop += 0.5;
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
}, 10);
|
|
167
|
-
return () => {
|
|
168
|
-
if (scrollTimer.current) {
|
|
169
|
-
clearInterval(scrollTimer.current);
|
|
170
|
-
}
|
|
171
|
-
if (unsubscribe.current) {
|
|
172
|
-
unsubscribe.current();
|
|
173
|
-
}
|
|
174
|
-
};
|
|
175
|
-
});
|
|
176
|
-
}, [dragDropMonitor]);
|
|
170
|
+
const handleDrop = useCallback(
|
|
171
|
+
(e: React.DragEvent) => {
|
|
172
|
+
e.preventDefault();
|
|
173
|
+
if (fragFromRef.current !== 'cell') {
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
onDrop(e, index);
|
|
177
|
+
},
|
|
178
|
+
[fragFromRef, index, onDrop],
|
|
179
|
+
);
|
|
177
180
|
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
+
const handleDragEnd = useCallback(
|
|
182
|
+
(e: React.DragEvent) => {
|
|
183
|
+
if (fragFromRef.current !== 'cell') {
|
|
184
|
+
return;
|
|
185
|
+
}
|
|
186
|
+
onDragEnd(e, index);
|
|
187
|
+
},
|
|
188
|
+
[fragFromRef, index, onDragEnd],
|
|
189
|
+
);
|
|
181
190
|
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
captureDraggingState: true,
|
|
188
|
-
});
|
|
189
|
-
}, [preview]);
|
|
191
|
+
const opacity = useMemo(() => {
|
|
192
|
+
return {
|
|
193
|
+
opacity: isDraging && sourceIndex === index ? 0.4 : 1,
|
|
194
|
+
};
|
|
195
|
+
}, [index, isDraging, sourceIndex]);
|
|
190
196
|
|
|
191
|
-
const
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
{
|
|
195
|
-
handlerId: Identifier | null;
|
|
196
|
-
isDragOver: boolean;
|
|
197
|
-
}
|
|
198
|
-
>({
|
|
199
|
-
accept: DragAreaKey,
|
|
200
|
-
drop(item, monitor) {
|
|
201
|
-
cellService
|
|
202
|
-
.getOrCreateView(
|
|
203
|
-
{
|
|
204
|
-
...item.cell.model.options,
|
|
205
|
-
modelId: item.cell.model.id,
|
|
206
|
-
singleSelectionDragPreview: true,
|
|
207
|
-
},
|
|
208
|
-
item.cell.parent.id,
|
|
209
|
-
)
|
|
210
|
-
.then((view) => {
|
|
211
|
-
view.dispose();
|
|
212
|
-
return;
|
|
213
|
-
})
|
|
214
|
-
.catch((e) => {
|
|
215
|
-
//
|
|
216
|
-
});
|
|
217
|
-
if (isCellView(item.cell)) {
|
|
218
|
-
const didDrop = monitor.didDrop();
|
|
219
|
-
if (didDrop) {
|
|
220
|
-
return;
|
|
221
|
-
}
|
|
222
|
-
const dragIndex = instance.findCellIndex(item.cell);
|
|
223
|
-
const dropIndex = instance.findCellIndex(cell);
|
|
224
|
-
if (instance.model.selections.length > 0) {
|
|
225
|
-
const isDragInSelections =
|
|
226
|
-
instance.model.selections.findIndex(
|
|
227
|
-
(selection) => selection.id === item.cell.id,
|
|
228
|
-
) > -1
|
|
229
|
-
? true
|
|
230
|
-
: false;
|
|
231
|
-
const isDropInSelections =
|
|
232
|
-
instance.model.selections.findIndex(
|
|
233
|
-
(selection) => selection.id === cell.id,
|
|
234
|
-
) > -1
|
|
235
|
-
? true
|
|
236
|
-
: false;
|
|
237
|
-
if (isDragInSelections && isDropInSelections) {
|
|
238
|
-
return;
|
|
239
|
-
}
|
|
240
|
-
if (isDragInSelections) {
|
|
241
|
-
instance.model.exchangeCells(instance.model.selections, dropIndex);
|
|
242
|
-
instance.model.scrollToView(cell);
|
|
197
|
+
const onMouseOver = useCallback(() => {
|
|
198
|
+
setIsMouseOverDragArea(true);
|
|
199
|
+
}, []);
|
|
243
200
|
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
if (dragIndex < dropIndex) {
|
|
248
|
-
instance.model.exchangeCell(dragIndex, dropIndex - 1);
|
|
249
|
-
instance.model.scrollToView(cell);
|
|
250
|
-
}
|
|
251
|
-
if (dragIndex > dropIndex) {
|
|
252
|
-
instance.model.exchangeCell(dragIndex, dropIndex);
|
|
253
|
-
instance.model.scrollToView(cell);
|
|
254
|
-
}
|
|
255
|
-
}
|
|
256
|
-
return;
|
|
257
|
-
},
|
|
258
|
-
collect(monitor) {
|
|
259
|
-
return {
|
|
260
|
-
isDragOver: monitor.isOver(),
|
|
261
|
-
canDrop: monitor.canDrop(),
|
|
262
|
-
handlerId: monitor.getHandlerId(),
|
|
263
|
-
};
|
|
264
|
-
},
|
|
265
|
-
});
|
|
266
|
-
const opacity = isDrag ? 0.4 : 1;
|
|
267
|
-
if (instance.model.cellsEditable) {
|
|
268
|
-
drop(ref);
|
|
269
|
-
}
|
|
270
|
-
if (isDrag) {
|
|
271
|
-
instance.model.mouseMode = 'drag';
|
|
272
|
-
}
|
|
201
|
+
const onMouseLeave = useCallback(() => {
|
|
202
|
+
setIsMouseOverDragArea(false);
|
|
203
|
+
}, []);
|
|
273
204
|
|
|
274
|
-
const isMultiSelected =
|
|
275
|
-
instance.model.selections.length !== 0 && instance.isSelected(cell);
|
|
276
205
|
// let isMouseOver = false;
|
|
277
|
-
const [isMouseOverDragArea, setIsMouseOverDragArea] = useState(false);
|
|
278
206
|
const hasCellHidden = useMemo(() => {
|
|
279
207
|
return cell.hasCellHidden();
|
|
280
208
|
}, [cell]);
|
|
281
209
|
const isCollapsible = CellCollapsible.is(cell);
|
|
282
210
|
|
|
211
|
+
const wrapperclassName = useMemo(() => {
|
|
212
|
+
return `libro-dnd-cell-container ${isMultiSelected ? 'multi-selected' : ''} ${
|
|
213
|
+
hasCellHidden ? 'hidden' : ''
|
|
214
|
+
}`;
|
|
215
|
+
}, [isMultiSelected]);
|
|
216
|
+
|
|
283
217
|
return (
|
|
284
218
|
<div
|
|
285
|
-
className={
|
|
286
|
-
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
style={
|
|
219
|
+
className={wrapperclassName}
|
|
220
|
+
onDragOver={handleDragOver}
|
|
221
|
+
onDrop={handleDrop}
|
|
222
|
+
onDragEnd={handleDragEnd}
|
|
223
|
+
style={opacity}
|
|
290
224
|
ref={ref}
|
|
291
225
|
id={cell.id}
|
|
292
226
|
>
|
|
@@ -294,15 +228,16 @@ export const DndCellContainer: React.FC<DndContentProps> = ({
|
|
|
294
228
|
index={position || index}
|
|
295
229
|
addCell={cell.parent.addCellAbove}
|
|
296
230
|
/>
|
|
297
|
-
{isDragOver && <div className="libro-drag-hoverline" />}
|
|
231
|
+
{!isDragDown && isDragOver && <div className="libro-drag-hoverline" />}
|
|
298
232
|
{isMouseOverDragArea && <HolderOutlined className="libro-handle-style" />}
|
|
299
233
|
<div
|
|
300
234
|
className="libro-drag-area"
|
|
301
|
-
|
|
235
|
+
onDragStart={handleDragStart}
|
|
236
|
+
draggable={instance.model.cellsEditable}
|
|
302
237
|
onMouseDown={handleMouseDown}
|
|
303
238
|
onMouseUp={handleMouseUp}
|
|
304
|
-
onMouseOver={
|
|
305
|
-
onMouseLeave={
|
|
239
|
+
onMouseOver={onMouseOver}
|
|
240
|
+
onMouseLeave={onMouseLeave}
|
|
306
241
|
/>
|
|
307
242
|
<div
|
|
308
243
|
tabIndex={-1}
|
|
@@ -312,7 +247,7 @@ export const DndCellContainer: React.FC<DndContentProps> = ({
|
|
|
312
247
|
>
|
|
313
248
|
<ItemRender
|
|
314
249
|
isDragOver={!!isDragOver}
|
|
315
|
-
isDrag={!!
|
|
250
|
+
isDrag={!!isDraging}
|
|
316
251
|
cell={cell}
|
|
317
252
|
isMouseOverDragArea={isMouseOverDragArea}
|
|
318
253
|
/>
|
|
@@ -329,6 +264,7 @@ export const DndCellContainer: React.FC<DndContentProps> = ({
|
|
|
329
264
|
</Button>
|
|
330
265
|
</div>
|
|
331
266
|
)}
|
|
267
|
+
{isDragDown && isDragOver && <div className="libro-drag-hoverline-last-one" />}
|
|
332
268
|
</div>
|
|
333
269
|
);
|
|
334
270
|
};
|