@yimoka/designable-playground 0.0.0-stage → 0.1.1
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/README.md +8 -2
- package/dist/demo/components/Alert/index.d.ts +4 -0
- package/dist/demo/components/Alert/index.js +41 -0
- package/dist/demo/components/ArrayCards/index.d.ts +17 -0
- package/dist/demo/components/ArrayCards/index.js +62 -0
- package/dist/demo/components/ArrayList/index.d.ts +25 -0
- package/dist/demo/components/ArrayList/index.js +143 -0
- package/dist/demo/components/ArrayTable/index.d.ts +39 -0
- package/dist/demo/components/ArrayTable/index.js +247 -0
- package/dist/demo/components/AutoComplete/index.d.ts +4 -0
- package/dist/demo/components/AutoComplete/index.js +52 -0
- package/dist/demo/components/Avatar/index.d.ts +4 -0
- package/dist/demo/components/Avatar/index.js +34 -0
- package/dist/demo/components/Badge/index.d.ts +4 -0
- package/dist/demo/components/Badge/index.js +35 -0
- package/dist/demo/components/Button/index.d.ts +4 -0
- package/dist/demo/components/Button/index.js +86 -0
- package/dist/demo/components/Card/index.d.ts +4 -0
- package/dist/demo/components/Card/index.js +72 -0
- package/dist/demo/components/Carousel/index.d.ts +4 -0
- package/dist/demo/components/Carousel/index.js +33 -0
- package/dist/demo/components/Cascader/index.d.ts +4 -0
- package/dist/demo/components/Cascader/index.js +60 -0
- package/dist/demo/components/Checkbox/index.d.ts +8 -0
- package/dist/demo/components/Checkbox/index.js +55 -0
- package/dist/demo/components/ColorPicker/index.d.ts +4 -0
- package/dist/demo/components/ColorPicker/index.js +38 -0
- package/dist/demo/components/DatePicker/index.d.ts +4 -0
- package/dist/demo/components/DatePicker/index.js +61 -0
- package/dist/demo/components/DateRangePicker/index.d.ts +4 -0
- package/dist/demo/components/DateRangePicker/index.js +58 -0
- package/dist/demo/components/Divider/index.d.ts +4 -0
- package/dist/demo/components/Divider/index.js +39 -0
- package/dist/demo/components/Empty/index.d.ts +4 -0
- package/dist/demo/components/Empty/index.js +29 -0
- package/dist/demo/components/Flex/index.d.ts +4 -0
- package/dist/demo/components/Flex/index.js +51 -0
- package/dist/demo/components/Form/index.d.ts +21 -0
- package/dist/demo/components/Form/index.js +116 -0
- package/dist/demo/components/FormCollapse/index.d.ts +28 -0
- package/dist/demo/components/FormCollapse/index.js +164 -0
- package/dist/demo/components/FormGrid/index.d.ts +22 -0
- package/dist/demo/components/FormGrid/index.js +134 -0
- package/dist/demo/components/FormItem/index.d.ts +14 -0
- package/dist/demo/components/FormItem/index.js +33 -0
- package/dist/demo/components/FormLayout/index.d.ts +26 -0
- package/dist/demo/components/FormLayout/index.js +260 -0
- package/dist/demo/components/FormTab/index.d.ts +15 -0
- package/dist/demo/components/FormTab/index.js +186 -0
- package/dist/demo/components/GridCol/index.d.ts +4 -0
- package/dist/demo/components/GridCol/index.js +53 -0
- package/dist/demo/components/GridRow/index.d.ts +4 -0
- package/dist/demo/components/GridRow/index.js +70 -0
- package/dist/demo/components/HTMLContent/index.d.ts +4 -0
- package/dist/demo/components/HTMLContent/index.js +34 -0
- package/dist/demo/components/I18nEditor/index.d.ts +8 -0
- package/dist/demo/components/I18nEditor/index.js +64 -0
- package/dist/demo/components/Image/index.d.ts +4 -0
- package/dist/demo/components/Image/index.js +36 -0
- package/dist/demo/components/Input/index.d.ts +4 -0
- package/dist/demo/components/Input/index.js +36 -0
- package/dist/demo/components/InputSearch/index.d.ts +4 -0
- package/dist/demo/components/InputSearch/index.js +40 -0
- package/dist/demo/components/Link/index.d.ts +4 -0
- package/dist/demo/components/Link/index.js +37 -0
- package/dist/demo/components/Mentions/index.d.ts +4 -0
- package/dist/demo/components/Mentions/index.js +41 -0
- package/dist/demo/components/NumberPicker/index.d.ts +6 -0
- package/dist/demo/components/NumberPicker/index.js +63 -0
- package/dist/demo/components/ObjectContainer/index.d.ts +14 -0
- package/dist/demo/components/ObjectContainer/index.js +46 -0
- package/dist/demo/components/Password/index.d.ts +6 -0
- package/dist/demo/components/Password/index.js +44 -0
- package/dist/demo/components/QRCode/index.d.ts +4 -0
- package/dist/demo/components/QRCode/index.js +34 -0
- package/dist/demo/components/Radio/index.d.ts +6 -0
- package/dist/demo/components/Radio/index.js +49 -0
- package/dist/demo/components/Rate/index.d.ts +6 -0
- package/dist/demo/components/Rate/index.js +43 -0
- package/dist/demo/components/Search/index.d.ts +4 -0
- package/dist/demo/components/Search/index.js +42 -0
- package/dist/demo/components/SearchSelect/index.d.ts +4 -0
- package/dist/demo/components/SearchSelect/index.js +53 -0
- package/dist/demo/components/Select/index.d.ts +4 -0
- package/dist/demo/components/Select/index.js +59 -0
- package/dist/demo/components/Slider/index.d.ts +6 -0
- package/dist/demo/components/Slider/index.js +61 -0
- package/dist/demo/components/Space/index.d.ts +9 -0
- package/dist/demo/components/Space/index.js +61 -0
- package/dist/demo/components/Statistic/index.d.ts +4 -0
- package/dist/demo/components/Statistic/index.js +33 -0
- package/dist/demo/components/Switch/index.d.ts +4 -0
- package/dist/demo/components/Switch/index.js +49 -0
- package/dist/demo/components/Tabs/index.d.ts +10 -0
- package/dist/demo/components/Tabs/index.js +181 -0
- package/dist/demo/components/Tag/index.d.ts +4 -0
- package/dist/demo/components/Tag/index.js +33 -0
- package/dist/demo/components/Text/index.d.ts +11 -0
- package/dist/demo/components/Text/index.js +64 -0
- package/dist/demo/components/TextArea/index.d.ts +6 -0
- package/dist/demo/components/TextArea/index.js +43 -0
- package/dist/demo/components/TimePicker/index.d.ts +4 -0
- package/dist/demo/components/TimePicker/index.js +69 -0
- package/dist/demo/components/TimeRangePicker/index.d.ts +4 -0
- package/dist/demo/components/TimeRangePicker/index.js +68 -0
- package/dist/demo/components/Transfer/index.d.ts +6 -0
- package/dist/demo/components/Transfer/index.js +59 -0
- package/dist/demo/components/TreeSelect/index.d.ts +4 -0
- package/dist/demo/components/TreeSelect/index.js +63 -0
- package/dist/demo/components/Upload/index.d.ts +8 -0
- package/dist/demo/components/Upload/index.js +64 -0
- package/dist/demo/components/index.d.ts +55 -0
- package/dist/demo/components/index.js +55 -0
- package/dist/demo/components/shared.d.ts +143 -0
- package/dist/demo/components/shared.js +315 -0
- package/dist/src/Playground.d.ts +3 -0
- package/dist/src/Playground.js +304 -0
- package/dist/src/antd/AntdPlayground.d.ts +16 -0
- package/dist/src/antd/AntdPlayground.js +136 -0
- package/dist/src/antd/index.d.ts +1 -0
- package/dist/src/antd/index.js +1 -0
- package/dist/src/context.d.ts +4 -0
- package/dist/src/context.js +13 -0
- package/dist/src/examples/index.d.ts +267 -0
- package/dist/src/examples/index.js +824 -0
- package/dist/src/hooks/index.d.ts +4 -0
- package/dist/src/hooks/index.js +4 -0
- package/dist/src/hooks/remoteSchemaAdapter.d.ts +53 -0
- package/dist/src/hooks/remoteSchemaAdapter.js +262 -0
- package/dist/src/hooks/usePlayground.d.ts +38 -0
- package/dist/src/hooks/usePlayground.js +642 -0
- package/dist/src/hooks/usePlaygroundRemotePersistence.d.ts +135 -0
- package/dist/src/hooks/usePlaygroundRemotePersistence.js +736 -0
- package/dist/src/hooks/useSchemaEditorDraft.d.ts +4 -0
- package/dist/src/hooks/useSchemaEditorDraft.js +44 -0
- package/dist/src/index.d.ts +14 -0
- package/dist/src/index.js +14 -0
- package/dist/src/layouts/PlaygroundLayout/ErrorBoundaries.d.ts +59 -0
- package/dist/src/layouts/PlaygroundLayout/ErrorBoundaries.js +161 -0
- package/dist/src/layouts/PlaygroundLayout/index.d.ts +7 -0
- package/dist/src/layouts/PlaygroundLayout/index.js +443 -0
- package/dist/src/layouts/index.d.ts +1 -0
- package/dist/src/layouts/index.js +1 -0
- package/dist/src/panels/CompositePanel/index.d.ts +6 -0
- package/dist/src/panels/CompositePanel/index.js +139 -0
- package/dist/src/panels/ToolbarPanel/index.d.ts +3 -0
- package/dist/src/panels/ToolbarPanel/index.js +24 -0
- package/dist/src/panels/index.d.ts +2 -0
- package/dist/src/panels/index.js +2 -0
- package/dist/src/presets/antd.d.ts +19 -0
- package/dist/src/presets/antd.js +112 -0
- package/dist/src/presets/index.d.ts +4 -0
- package/dist/src/presets/index.js +3 -0
- package/dist/src/presets/runtime-array-helpers.d.ts +8 -0
- package/dist/src/presets/runtime-array-helpers.js +147 -0
- package/dist/src/presets/runtime-component-props.d.ts +3 -0
- package/dist/src/presets/runtime-component-props.js +5 -0
- package/dist/src/presets/runtime-components.d.ts +5 -0
- package/dist/src/presets/runtime-components.js +419 -0
- package/dist/src/presets/runtime-form-components.d.ts +9 -0
- package/dist/src/presets/runtime-form-components.js +94 -0
- package/dist/src/presets/scenario-catalog.d.ts +6 -0
- package/dist/src/presets/scenario-catalog.js +128 -0
- package/dist/src/presets/scenarios.d.ts +52 -0
- package/dist/src/presets/scenarios.js +603 -0
- package/dist/src/runtime/actions.d.ts +19 -0
- package/dist/src/runtime/actions.js +307 -0
- package/dist/src/runtime/contracts.d.ts +149 -0
- package/dist/src/runtime/contracts.js +1 -0
- package/dist/src/runtime/document-bindings.d.ts +3 -0
- package/dist/src/runtime/document-bindings.js +101 -0
- package/dist/src/runtime/document-core.d.ts +57 -0
- package/dist/src/runtime/document-core.js +379 -0
- package/dist/src/runtime/document-entity.d.ts +12 -0
- package/dist/src/runtime/document-entity.js +351 -0
- package/dist/src/runtime/document-expressions.d.ts +35 -0
- package/dist/src/runtime/document-expressions.js +346 -0
- package/dist/src/runtime/document-security.d.ts +34 -0
- package/dist/src/runtime/document-security.js +538 -0
- package/dist/src/runtime/document.d.ts +16 -0
- package/dist/src/runtime/document.js +212 -0
- package/dist/src/runtime/environment.d.ts +16 -0
- package/dist/src/runtime/environment.js +76 -0
- package/dist/src/runtime/i18n-schema.d.ts +36 -0
- package/dist/src/runtime/i18n-schema.js +338 -0
- package/dist/src/runtime/i18n.d.ts +25 -0
- package/dist/src/runtime/i18n.js +447 -0
- package/dist/src/runtime/index.d.ts +8 -0
- package/dist/src/runtime/index.js +8 -0
- package/dist/src/runtime/navigation.d.ts +5 -0
- package/dist/src/runtime/navigation.js +43 -0
- package/dist/src/runtime/playground.d.ts +30 -0
- package/dist/src/runtime/playground.js +243 -0
- package/dist/src/runtime/preview-boundaries.d.ts +13 -0
- package/dist/src/runtime/preview-boundaries.js +43 -0
- package/dist/src/runtime/preview.d.ts +44 -0
- package/dist/src/runtime/preview.js +574 -0
- package/dist/src/runtime/settings/RuntimeJsonEditor.d.ts +10 -0
- package/dist/src/runtime/settings/RuntimeJsonEditor.js +21 -0
- package/dist/src/runtime/settings/RuntimeStoreEntitySettings.d.ts +15 -0
- package/dist/src/runtime/settings/RuntimeStoreEntitySettings.js +65 -0
- package/dist/src/runtime/templates.d.ts +1560 -0
- package/dist/src/runtime/templates.js +508 -0
- package/dist/src/runtime/website-contact-template.d.ts +1 -0
- package/dist/src/runtime/website-contact-template.js +66 -0
- package/dist/src/runtime/website-template-shared.d.ts +14 -0
- package/dist/src/runtime/website-template-shared.js +210 -0
- package/dist/src/runtime/website-templates.d.ts +5 -0
- package/dist/src/runtime/website-templates.js +976 -0
- package/dist/src/shared/clipboard.d.ts +4 -0
- package/dist/src/shared/clipboard.js +56 -0
- package/dist/src/shared/componentRegistry.d.ts +133 -0
- package/dist/src/shared/componentRegistry.js +381 -0
- package/dist/src/shared/formilyCompatibility.d.ts +8 -0
- package/dist/src/shared/formilyCompatibility.js +40 -0
- package/dist/src/shared/index.d.ts +6 -0
- package/dist/src/shared/index.js +6 -0
- package/dist/src/shared/productionAcceptance.d.ts +63 -0
- package/dist/src/shared/productionAcceptance.js +201 -0
- package/dist/src/shared/schema-options.d.ts +16 -0
- package/dist/src/shared/schema-options.js +138 -0
- package/dist/src/shared/schema.d.ts +63 -0
- package/dist/src/shared/schema.js +627 -0
- package/dist/src/shared/styleSecurity.d.ts +2 -0
- package/dist/src/shared/styleSecurity.js +35 -0
- package/dist/src/transformers/formily.d.ts +34 -0
- package/dist/src/transformers/formily.js +943 -0
- package/dist/src/transformers/index.d.ts +1 -0
- package/dist/src/transformers/index.js +1 -0
- package/dist/src/types.d.ts +186 -0
- package/dist/src/types.js +1 -0
- package/dist/src/widgets/ActionsWidget/index.d.ts +3 -0
- package/dist/src/widgets/ActionsWidget/index.js +10 -0
- package/dist/src/widgets/ComponentTreeWidget/index.d.ts +3 -0
- package/dist/src/widgets/ComponentTreeWidget/index.js +333 -0
- package/dist/src/widgets/NodeActionsWidget/index.d.ts +2 -0
- package/dist/src/widgets/NodeActionsWidget/index.js +125 -0
- package/dist/src/widgets/OutlineTreeWidget/index.d.ts +3 -0
- package/dist/src/widgets/OutlineTreeWidget/index.js +432 -0
- package/dist/src/widgets/OutlineTreeWidget/shared.d.ts +32 -0
- package/dist/src/widgets/OutlineTreeWidget/shared.js +79 -0
- package/dist/src/widgets/PreviewWidget/index.d.ts +2 -0
- package/dist/src/widgets/PreviewWidget/index.js +1566 -0
- package/dist/src/widgets/ProductionReadinessWidget/index.d.ts +18 -0
- package/dist/src/widgets/ProductionReadinessWidget/index.js +356 -0
- package/dist/src/widgets/RemotePersistenceStatusWidget/index.d.ts +18 -0
- package/dist/src/widgets/RemotePersistenceStatusWidget/index.js +438 -0
- package/dist/src/widgets/RemoteVersionHistoryWidget/index.d.ts +39 -0
- package/dist/src/widgets/RemoteVersionHistoryWidget/index.js +475 -0
- package/dist/src/widgets/ResourceWidget/index.d.ts +3 -0
- package/dist/src/widgets/ResourceWidget/index.js +491 -0
- package/dist/src/widgets/SchemaCodeView/index.d.ts +7 -0
- package/dist/src/widgets/SchemaCodeView/index.js +225 -0
- package/dist/src/widgets/SchemaEditorWidget/index.d.ts +10 -0
- package/dist/src/widgets/SchemaEditorWidget/index.js +484 -0
- package/dist/src/widgets/SettingsPanelWidget/index.d.ts +3 -0
- package/dist/src/widgets/SettingsPanelWidget/index.js +190 -0
- package/dist/src/widgets/StorageActionsWidget/index.d.ts +2 -0
- package/dist/src/widgets/StorageActionsWidget/index.js +284 -0
- package/dist/src/widgets/index.d.ts +13 -0
- package/dist/src/widgets/index.js +13 -0
- package/package.json +100 -4
|
@@ -0,0 +1,432 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { observer } from '@formily/reactive-react';
|
|
3
|
+
import { TextWidget, useOperation, usePrefix, useSelection, useTree } from '@yimoka/designable-react';
|
|
4
|
+
import { Empty } from 'antd';
|
|
5
|
+
import cls from 'classnames';
|
|
6
|
+
import React from 'react';
|
|
7
|
+
import { handleOutlineKeyboardMove, moveOutlineNode } from "./shared.js";
|
|
8
|
+
const OUTLINE_INDENT_STEP = 3;
|
|
9
|
+
const OUTLINE_MAX_LEVEL = 10;
|
|
10
|
+
const OUTLINE_SWITCHER_WIDTH = 6;
|
|
11
|
+
const getOutlineMoveOptions = (intent) => ({
|
|
12
|
+
dropPosition: intent === 'after' ? 1 : -1,
|
|
13
|
+
dropToGap: intent !== 'inside',
|
|
14
|
+
});
|
|
15
|
+
const hasPointerDragMoved = (dragState, event) => {
|
|
16
|
+
if (!dragState.hasCoordinates)
|
|
17
|
+
return true;
|
|
18
|
+
return Math.hypot(event.clientX - dragState.x, event.clientY - dragState.y) >= 4;
|
|
19
|
+
};
|
|
20
|
+
const getPointerDragState = (node, event) => {
|
|
21
|
+
const hasCoordinates = Number.isFinite(event.clientX) && Number.isFinite(event.clientY);
|
|
22
|
+
return {
|
|
23
|
+
hasCoordinates,
|
|
24
|
+
id: node.id,
|
|
25
|
+
x: hasCoordinates ? event.clientX : 0,
|
|
26
|
+
y: hasCoordinates ? event.clientY : 0,
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
const finishOutlineMove = (dragId, selection, operation) => {
|
|
30
|
+
operation?.dragClean?.();
|
|
31
|
+
operation?.hover?.clear?.();
|
|
32
|
+
operation?.snapshot?.('move:outline:node');
|
|
33
|
+
selection?.select?.(dragId);
|
|
34
|
+
};
|
|
35
|
+
const getOutlineDropRatio = (event, targetElement) => {
|
|
36
|
+
const rect = targetElement.getBoundingClientRect();
|
|
37
|
+
const height = rect.height || 1;
|
|
38
|
+
const offsetY = Math.min(Math.max(event.clientY - rect.top, 0), height);
|
|
39
|
+
return offsetY / height;
|
|
40
|
+
};
|
|
41
|
+
const canAppendOutlineNode = (node, dragNode) => !!node.children?.length && (!dragNode || node.allowAppend([dragNode]));
|
|
42
|
+
const resolveOutlineGapIntent = (ratio) => {
|
|
43
|
+
if (ratio > 0.5)
|
|
44
|
+
return 'after';
|
|
45
|
+
return 'before';
|
|
46
|
+
};
|
|
47
|
+
const getOutlineDropIntent = (node, event, dragNode, targetElement = event.currentTarget) => {
|
|
48
|
+
if (node.isRoot)
|
|
49
|
+
return 'inside';
|
|
50
|
+
const ratio = getOutlineDropRatio(event, targetElement);
|
|
51
|
+
const canAppend = canAppendOutlineNode(node, dragNode);
|
|
52
|
+
if (canAppend && ratio >= 0.28 && ratio <= 0.72)
|
|
53
|
+
return 'inside';
|
|
54
|
+
return resolveOutlineGapIntent(ratio);
|
|
55
|
+
};
|
|
56
|
+
const getNodeFieldName = (node) => {
|
|
57
|
+
const name = node.props?.name;
|
|
58
|
+
if (typeof name === 'string' && name.trim())
|
|
59
|
+
return name;
|
|
60
|
+
return undefined;
|
|
61
|
+
};
|
|
62
|
+
const getOutlineNodeAriaLabel = (node, fieldName) => `${node.componentName} ${fieldName ?? node.id}`;
|
|
63
|
+
const getOutlineNodeCursor = (node) => {
|
|
64
|
+
if (node.isRoot)
|
|
65
|
+
return 'default';
|
|
66
|
+
return 'grab';
|
|
67
|
+
};
|
|
68
|
+
const getOutlineNodeMinHeight = (showMeta) => {
|
|
69
|
+
if (showMeta)
|
|
70
|
+
return 20;
|
|
71
|
+
return 17;
|
|
72
|
+
};
|
|
73
|
+
const getOutlineNodeTitleText = (node, title) => {
|
|
74
|
+
if (title)
|
|
75
|
+
return _jsx(TextWidget, { children: title });
|
|
76
|
+
return node.componentName || node.id;
|
|
77
|
+
};
|
|
78
|
+
const getOutlineNodeTitleHandlers = (node, pointerHandlers) => ({
|
|
79
|
+
onMouseDown: (event) => {
|
|
80
|
+
pointerHandlers?.onMouseDown(node, event);
|
|
81
|
+
},
|
|
82
|
+
onMouseMove: (event) => {
|
|
83
|
+
pointerHandlers?.onMouseMove(node, event);
|
|
84
|
+
},
|
|
85
|
+
onMouseUp: (event) => {
|
|
86
|
+
pointerHandlers?.onMouseUp(node, event);
|
|
87
|
+
},
|
|
88
|
+
onPointerCancel: () => {
|
|
89
|
+
pointerHandlers?.onPointerCancel();
|
|
90
|
+
},
|
|
91
|
+
onPointerDown: (event) => {
|
|
92
|
+
pointerHandlers?.onPointerDown(node, event);
|
|
93
|
+
},
|
|
94
|
+
onPointerMove: (event) => {
|
|
95
|
+
pointerHandlers?.onPointerMove(node, event);
|
|
96
|
+
},
|
|
97
|
+
onPointerUp: (event) => {
|
|
98
|
+
pointerHandlers?.onPointerUp(node, event);
|
|
99
|
+
},
|
|
100
|
+
});
|
|
101
|
+
const OutlineNodeTitle = ({ level, node, pointerHandlers, }) => {
|
|
102
|
+
const title = node.getMessage?.('title');
|
|
103
|
+
const fieldName = getNodeFieldName(node);
|
|
104
|
+
const childCount = node.children?.length ?? 0;
|
|
105
|
+
const showMeta = !!fieldName && fieldName !== node.componentName;
|
|
106
|
+
return (_jsxs("div", { "aria-label": getOutlineNodeAriaLabel(node, fieldName), "data-outline-node-component": node.componentName, "data-outline-node-id": node.id, "data-outline-node-level": level, style: {
|
|
107
|
+
alignItems: 'center',
|
|
108
|
+
cursor: getOutlineNodeCursor(node),
|
|
109
|
+
display: 'flex',
|
|
110
|
+
gap: 0,
|
|
111
|
+
minHeight: getOutlineNodeMinHeight(showMeta),
|
|
112
|
+
minWidth: 0,
|
|
113
|
+
padding: '0',
|
|
114
|
+
width: '100%',
|
|
115
|
+
}, ...getOutlineNodeTitleHandlers(node, pointerHandlers), children: [_jsxs("span", { style: { flex: 1, minWidth: 0 }, children: [_jsx("span", { style: {
|
|
116
|
+
alignItems: 'center',
|
|
117
|
+
color: node.isRoot ? '#1f2a37' : '#253040',
|
|
118
|
+
display: 'flex',
|
|
119
|
+
fontSize: 12,
|
|
120
|
+
fontWeight: 600,
|
|
121
|
+
lineHeight: '12px',
|
|
122
|
+
minWidth: 0,
|
|
123
|
+
}, children: _jsx("span", { style: {
|
|
124
|
+
whiteSpace: 'nowrap',
|
|
125
|
+
overflow: 'hidden',
|
|
126
|
+
textOverflow: 'ellipsis',
|
|
127
|
+
}, children: getOutlineNodeTitleText(node, title) }) }), showMeta && (_jsxs("span", { style: {
|
|
128
|
+
color: '#7b8797',
|
|
129
|
+
display: 'block',
|
|
130
|
+
fontSize: 10,
|
|
131
|
+
lineHeight: '10px',
|
|
132
|
+
overflow: 'hidden',
|
|
133
|
+
textOverflow: 'ellipsis',
|
|
134
|
+
whiteSpace: 'nowrap',
|
|
135
|
+
}, children: [node.componentName, " / ", fieldName] }))] }), childCount > 0 && (_jsx("span", { style: {
|
|
136
|
+
background: '#f0f7ff',
|
|
137
|
+
border: '1px solid #d8eaff',
|
|
138
|
+
borderRadius: 8,
|
|
139
|
+
color: '#1677ff',
|
|
140
|
+
flexShrink: 0,
|
|
141
|
+
fontSize: 9,
|
|
142
|
+
fontWeight: 600,
|
|
143
|
+
lineHeight: '11px',
|
|
144
|
+
marginLeft: 0,
|
|
145
|
+
minWidth: 11,
|
|
146
|
+
padding: '0 2px',
|
|
147
|
+
textAlign: 'center',
|
|
148
|
+
}, children: childCount }))] }));
|
|
149
|
+
};
|
|
150
|
+
const getExpandedKeys = (node) => [
|
|
151
|
+
node.id,
|
|
152
|
+
...(node.children?.flatMap(child => getExpandedKeys(child)) ?? []),
|
|
153
|
+
];
|
|
154
|
+
const getOutlineIndent = (level) => (Math.min(Math.max(level, 0), OUTLINE_MAX_LEVEL) * OUTLINE_INDENT_STEP);
|
|
155
|
+
const getOutlineHoverIntent = (node, hoverState) => {
|
|
156
|
+
if (hoverState?.id !== node.id)
|
|
157
|
+
return undefined;
|
|
158
|
+
return hoverState.intent;
|
|
159
|
+
};
|
|
160
|
+
const getOutlineTreeItemClassName = (prefix, isSelected, hoverIntent) => cls(`${prefix}-treenode`, {
|
|
161
|
+
[`${prefix}-treenode-selected`]: isSelected,
|
|
162
|
+
[`${prefix}-treenode-drop-before`]: hoverIntent === 'before',
|
|
163
|
+
[`${prefix}-treenode-drop-inside`]: hoverIntent === 'inside',
|
|
164
|
+
[`${prefix}-treenode-drop-after`]: hoverIntent === 'after',
|
|
165
|
+
});
|
|
166
|
+
const OutlineSwitcher = ({ isExpanded, node, prefix, toggleExpanded, }) => {
|
|
167
|
+
if (!node.children?.length) {
|
|
168
|
+
if (node.isRoot)
|
|
169
|
+
return null;
|
|
170
|
+
return _jsx("span", { "aria-hidden": true, className: `${prefix}-switcher-placeholder` });
|
|
171
|
+
}
|
|
172
|
+
return (_jsx("button", { "aria-label": `${isExpanded ? '收起' : '展开'} ${node.componentName}`, className: `${prefix}-switcher`, type: "button", onClick: (event) => {
|
|
173
|
+
event.stopPropagation();
|
|
174
|
+
toggleExpanded(node);
|
|
175
|
+
}, children: isExpanded ? '▾' : '▸' }));
|
|
176
|
+
};
|
|
177
|
+
const getOutlineDropTarget = (tree, event, fallbackNode) => {
|
|
178
|
+
const pointedElement = typeof document === 'undefined' || typeof document.elementFromPoint !== 'function'
|
|
179
|
+
? undefined
|
|
180
|
+
: document.elementFromPoint(event.clientX, event.clientY);
|
|
181
|
+
const targetElement = pointedElement?.closest('[data-outline-node-id]');
|
|
182
|
+
const targetId = targetElement?.dataset.outlineNodeId;
|
|
183
|
+
const targetNode = targetId ? tree.findById(targetId) : undefined;
|
|
184
|
+
if (targetElement && targetNode) {
|
|
185
|
+
return {
|
|
186
|
+
element: targetElement,
|
|
187
|
+
node: targetNode,
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
if (event.currentTarget instanceof HTMLElement) {
|
|
191
|
+
return {
|
|
192
|
+
element: event.currentTarget,
|
|
193
|
+
node: fallbackNode,
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
return undefined;
|
|
197
|
+
};
|
|
198
|
+
const getOutlineTreeStyleText = (prefix) => `
|
|
199
|
+
.${prefix} {
|
|
200
|
+
box-sizing: border-box;
|
|
201
|
+
color: #253040;
|
|
202
|
+
font-size: 12px;
|
|
203
|
+
padding: 0;
|
|
204
|
+
}
|
|
205
|
+
.${prefix} .${prefix}-treenode {
|
|
206
|
+
align-items: center;
|
|
207
|
+
box-sizing: border-box;
|
|
208
|
+
display: flex;
|
|
209
|
+
margin: 0;
|
|
210
|
+
min-height: 18px;
|
|
211
|
+
padding-bottom: 0;
|
|
212
|
+
padding-right: 0;
|
|
213
|
+
padding-top: 0;
|
|
214
|
+
width: 100%;
|
|
215
|
+
}
|
|
216
|
+
.${prefix} .${prefix}-switcher {
|
|
217
|
+
align-items: center;
|
|
218
|
+
appearance: none;
|
|
219
|
+
background: transparent;
|
|
220
|
+
border: 0;
|
|
221
|
+
color: #111827;
|
|
222
|
+
cursor: pointer;
|
|
223
|
+
display: inline-flex;
|
|
224
|
+
flex: none;
|
|
225
|
+
font-size: 9px;
|
|
226
|
+
height: 13px;
|
|
227
|
+
justify-content: center;
|
|
228
|
+
line-height: 1;
|
|
229
|
+
margin: 0;
|
|
230
|
+
padding: 0;
|
|
231
|
+
width: ${OUTLINE_SWITCHER_WIDTH}px;
|
|
232
|
+
}
|
|
233
|
+
.${prefix} .${prefix}-switcher-placeholder {
|
|
234
|
+
display: inline-flex;
|
|
235
|
+
flex: none;
|
|
236
|
+
height: 13px;
|
|
237
|
+
width: ${OUTLINE_SWITCHER_WIDTH}px;
|
|
238
|
+
}
|
|
239
|
+
.${prefix} .${prefix}-node-content {
|
|
240
|
+
border-radius: 5px;
|
|
241
|
+
flex: 1;
|
|
242
|
+
max-width: none;
|
|
243
|
+
min-width: 0;
|
|
244
|
+
padding: 0 !important;
|
|
245
|
+
transition: background 0.12s ease;
|
|
246
|
+
}
|
|
247
|
+
.${prefix} .${prefix}-node-content:hover {
|
|
248
|
+
background: #f0f7ff !important;
|
|
249
|
+
}
|
|
250
|
+
.${prefix} .${prefix}-treenode-selected .${prefix}-node-content {
|
|
251
|
+
background: #e8f4ff !important;
|
|
252
|
+
}
|
|
253
|
+
.${prefix} .${prefix}-treenode-drop-inside .${prefix}-node-content {
|
|
254
|
+
background: #eaf4ff !important;
|
|
255
|
+
box-shadow: inset 0 0 0 1px #70b8ff;
|
|
256
|
+
}
|
|
257
|
+
.${prefix} .${prefix}-treenode-drop-before,
|
|
258
|
+
.${prefix} .${prefix}-treenode-drop-after {
|
|
259
|
+
position: relative;
|
|
260
|
+
}
|
|
261
|
+
.${prefix} .${prefix}-treenode-drop-before::before,
|
|
262
|
+
.${prefix} .${prefix}-treenode-drop-after::after {
|
|
263
|
+
background: #1677ff;
|
|
264
|
+
border-radius: 999px;
|
|
265
|
+
content: '';
|
|
266
|
+
height: 2px;
|
|
267
|
+
left: 2px;
|
|
268
|
+
position: absolute;
|
|
269
|
+
right: 2px;
|
|
270
|
+
z-index: 1;
|
|
271
|
+
}
|
|
272
|
+
.${prefix} .${prefix}-treenode-drop-before::before {
|
|
273
|
+
top: 0;
|
|
274
|
+
}
|
|
275
|
+
.${prefix} .${prefix}-treenode-drop-after::after {
|
|
276
|
+
bottom: 0;
|
|
277
|
+
}
|
|
278
|
+
`;
|
|
279
|
+
const useOutlineTreeStyles = (prefix) => {
|
|
280
|
+
React.useEffect(() => {
|
|
281
|
+
if (typeof document === 'undefined')
|
|
282
|
+
return;
|
|
283
|
+
const styleId = `designable-${prefix}-styles`;
|
|
284
|
+
let style = document.getElementById(styleId);
|
|
285
|
+
if (!style) {
|
|
286
|
+
style = document.createElement('style');
|
|
287
|
+
style.id = styleId;
|
|
288
|
+
style.setAttribute('data-designable-outline-style', prefix);
|
|
289
|
+
document.head.appendChild(style);
|
|
290
|
+
}
|
|
291
|
+
style.textContent = getOutlineTreeStyleText(prefix);
|
|
292
|
+
}, [prefix]);
|
|
293
|
+
};
|
|
294
|
+
const useOutlinePointerDrag = (tree, selection, operation) => {
|
|
295
|
+
const pointerDragRef = React.useRef(null);
|
|
296
|
+
const [hoverState, setHoverState] = React.useState(null);
|
|
297
|
+
const clearPointerDrag = React.useCallback(() => {
|
|
298
|
+
pointerDragRef.current = null;
|
|
299
|
+
setHoverState(null);
|
|
300
|
+
}, []);
|
|
301
|
+
const finishPointerMove = React.useCallback((dragId, dropNode, event, dropElement) => {
|
|
302
|
+
if (!tree)
|
|
303
|
+
return;
|
|
304
|
+
const dragNode = tree.findById(dragId);
|
|
305
|
+
const intent = getOutlineDropIntent(dropNode, event, dragNode, dropElement);
|
|
306
|
+
const moved = moveOutlineNode(tree, dragId, dropNode.id, getOutlineMoveOptions(intent));
|
|
307
|
+
setHoverState(null);
|
|
308
|
+
if (!moved)
|
|
309
|
+
return;
|
|
310
|
+
finishOutlineMove(dragId, selection, operation);
|
|
311
|
+
}, [operation, selection, tree]);
|
|
312
|
+
const beginPointerDrag = React.useCallback((node, event) => {
|
|
313
|
+
if (node.isRoot)
|
|
314
|
+
return;
|
|
315
|
+
pointerDragRef.current = getPointerDragState(node, event);
|
|
316
|
+
}, []);
|
|
317
|
+
const movePointerDrag = React.useCallback((node, event) => {
|
|
318
|
+
if (!tree)
|
|
319
|
+
return;
|
|
320
|
+
const dragState = pointerDragRef.current;
|
|
321
|
+
if (!dragState || dragState.id === node.id)
|
|
322
|
+
return;
|
|
323
|
+
const dragNode = tree.findById(dragState.id);
|
|
324
|
+
const dropTarget = getOutlineDropTarget(tree, event, node);
|
|
325
|
+
if (!dropTarget || dropTarget.node.id === dragState.id)
|
|
326
|
+
return;
|
|
327
|
+
const nextIntent = getOutlineDropIntent(dropTarget.node, event, dragNode, dropTarget.element);
|
|
328
|
+
setHoverState((current) => {
|
|
329
|
+
if (current?.id === dropTarget.node.id && current.intent === nextIntent)
|
|
330
|
+
return current;
|
|
331
|
+
return { id: dropTarget.node.id, intent: nextIntent };
|
|
332
|
+
});
|
|
333
|
+
}, [tree]);
|
|
334
|
+
const endPointerDrag = React.useCallback((node, event) => {
|
|
335
|
+
if (!tree)
|
|
336
|
+
return;
|
|
337
|
+
const dragState = pointerDragRef.current;
|
|
338
|
+
pointerDragRef.current = null;
|
|
339
|
+
if (!dragState)
|
|
340
|
+
return;
|
|
341
|
+
const dropTarget = getOutlineDropTarget(tree, event, node);
|
|
342
|
+
if (!dropTarget || dragState.id === dropTarget.node.id)
|
|
343
|
+
return;
|
|
344
|
+
if (!hasPointerDragMoved(dragState, event)) {
|
|
345
|
+
setHoverState(null);
|
|
346
|
+
return;
|
|
347
|
+
}
|
|
348
|
+
finishPointerMove(dragState.id, dropTarget.node, event, dropTarget.element);
|
|
349
|
+
}, [finishPointerMove, tree]);
|
|
350
|
+
const pointerHandlers = React.useMemo(() => ({
|
|
351
|
+
onMouseDown: (node, event) => {
|
|
352
|
+
if (event.button !== 0)
|
|
353
|
+
return;
|
|
354
|
+
beginPointerDrag(node, event);
|
|
355
|
+
},
|
|
356
|
+
onMouseMove: movePointerDrag,
|
|
357
|
+
onMouseUp: endPointerDrag,
|
|
358
|
+
onPointerCancel: clearPointerDrag,
|
|
359
|
+
onPointerDown: (node, event) => {
|
|
360
|
+
if (node.isRoot)
|
|
361
|
+
return;
|
|
362
|
+
beginPointerDrag(node, event);
|
|
363
|
+
},
|
|
364
|
+
onPointerMove: movePointerDrag,
|
|
365
|
+
onPointerUp: endPointerDrag,
|
|
366
|
+
}), [beginPointerDrag, clearPointerDrag, endPointerDrag, movePointerDrag]);
|
|
367
|
+
return {
|
|
368
|
+
clearPointerDrag,
|
|
369
|
+
hoverState,
|
|
370
|
+
pointerHandlers,
|
|
371
|
+
};
|
|
372
|
+
};
|
|
373
|
+
const getOutlineKeyboardDirection = (event) => {
|
|
374
|
+
if (!event.altKey)
|
|
375
|
+
return undefined;
|
|
376
|
+
if (event.key === 'ArrowUp')
|
|
377
|
+
return -1;
|
|
378
|
+
if (event.key === 'ArrowDown')
|
|
379
|
+
return 1;
|
|
380
|
+
return undefined;
|
|
381
|
+
};
|
|
382
|
+
export const OutlineTreeWidget = observer((props) => {
|
|
383
|
+
const tree = useTree();
|
|
384
|
+
const selection = useSelection();
|
|
385
|
+
const operation = useOperation();
|
|
386
|
+
const prefix = usePrefix('outline-tree');
|
|
387
|
+
useOutlineTreeStyles(prefix);
|
|
388
|
+
const [collapsedKeys, setCollapsedKeys] = React.useState(() => new Set());
|
|
389
|
+
const { clearPointerDrag, hoverState, pointerHandlers, } = useOutlinePointerDrag(tree, selection, operation);
|
|
390
|
+
if (!tree) {
|
|
391
|
+
return (_jsx("div", { className: cls(prefix, props.className), style: props.style, children: _jsx(Empty, { description: "\u6682\u65E0\u5927\u7EB2" }) }));
|
|
392
|
+
}
|
|
393
|
+
const expandedKeys = getExpandedKeys(tree).filter(key => !collapsedKeys.has(String(key)));
|
|
394
|
+
const selectedKeys = selection?.selected ?? [];
|
|
395
|
+
const handleKeyDown = (event) => {
|
|
396
|
+
const direction = getOutlineKeyboardDirection(event);
|
|
397
|
+
if (!direction)
|
|
398
|
+
return;
|
|
399
|
+
const moved = handleOutlineKeyboardMove(tree, selectedKeys, direction, selection, operation);
|
|
400
|
+
if (!moved)
|
|
401
|
+
return;
|
|
402
|
+
event.preventDefault();
|
|
403
|
+
event.stopPropagation();
|
|
404
|
+
};
|
|
405
|
+
const toggleExpanded = (node) => {
|
|
406
|
+
if (!node.children?.length)
|
|
407
|
+
return;
|
|
408
|
+
setCollapsedKeys((current) => {
|
|
409
|
+
const next = new Set(current);
|
|
410
|
+
if (next.has(node.id)) {
|
|
411
|
+
next.delete(node.id);
|
|
412
|
+
}
|
|
413
|
+
else {
|
|
414
|
+
next.add(node.id);
|
|
415
|
+
}
|
|
416
|
+
return next;
|
|
417
|
+
});
|
|
418
|
+
};
|
|
419
|
+
const renderNode = (node, level = 0) => {
|
|
420
|
+
const isExpanded = expandedKeys.includes(node.id);
|
|
421
|
+
const hasChildren = !!node.children?.length;
|
|
422
|
+
const isSelected = selectedKeys.includes(node.id);
|
|
423
|
+
const hoverIntent = getOutlineHoverIntent(node, hoverState);
|
|
424
|
+
return (_jsxs(React.Fragment, { children: [_jsxs("div", { "aria-expanded": hasChildren ? isExpanded : undefined, "aria-level": level + 1, "aria-selected": isSelected, className: getOutlineTreeItemClassName(prefix, isSelected, hoverIntent), "data-outline-drop-intent": hoverIntent, role: "treeitem", style: {
|
|
425
|
+
paddingLeft: getOutlineIndent(level),
|
|
426
|
+
}, children: [_jsx(OutlineSwitcher, { isExpanded: isExpanded, node: node, prefix: prefix, toggleExpanded: toggleExpanded }), _jsx("div", { className: `${prefix}-node-content`, onClick: () => {
|
|
427
|
+
selection?.select?.(node.id);
|
|
428
|
+
}, children: _jsx(OutlineNodeTitle, { level: level, node: node, pointerHandlers: pointerHandlers }) })] }), isExpanded && node.children?.map(child => renderNode(child, level + 1))] }, node.id));
|
|
429
|
+
};
|
|
430
|
+
return (_jsx("div", { "aria-label": "\u7EC4\u4EF6\u5927\u7EB2", className: cls(prefix, props.className), role: "tree", style: { ...props.style }, tabIndex: 0, onKeyDown: handleKeyDown, onPointerCancel: clearPointerDrag, children: renderNode(tree) }));
|
|
431
|
+
});
|
|
432
|
+
OutlineTreeWidget.displayName = 'OutlineTreeWidget';
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { TreeNode } from '@yimoka/designable-core';
|
|
2
|
+
import type { Key } from 'react';
|
|
3
|
+
interface IOutlineMoveOptions {
|
|
4
|
+
dropPosition: number;
|
|
5
|
+
dropToGap?: boolean;
|
|
6
|
+
}
|
|
7
|
+
export interface IOutlineDropInfo {
|
|
8
|
+
dragNode: {
|
|
9
|
+
key: Key;
|
|
10
|
+
};
|
|
11
|
+
node: {
|
|
12
|
+
key: Key;
|
|
13
|
+
pos: string;
|
|
14
|
+
};
|
|
15
|
+
dropPosition: number;
|
|
16
|
+
dropToGap?: boolean;
|
|
17
|
+
}
|
|
18
|
+
interface IOutlineSelection {
|
|
19
|
+
select?: (id: string) => void;
|
|
20
|
+
}
|
|
21
|
+
interface IOutlineOperation {
|
|
22
|
+
dragClean?: () => void;
|
|
23
|
+
hover?: {
|
|
24
|
+
clear?: () => void;
|
|
25
|
+
};
|
|
26
|
+
snapshot?: (type?: string) => void;
|
|
27
|
+
}
|
|
28
|
+
export declare const moveOutlineNode: (tree: TreeNode, dragId: string, dropId: string, options: IOutlineMoveOptions) => boolean;
|
|
29
|
+
export declare const handleOutlineDrop: (tree: TreeNode, info: IOutlineDropInfo, selection?: IOutlineSelection, operation?: IOutlineOperation) => boolean;
|
|
30
|
+
export declare const moveOutlineNodeBySiblingStep: (tree: TreeNode, dragId: string, direction: -1 | 1) => boolean;
|
|
31
|
+
export declare const handleOutlineKeyboardMove: (tree: TreeNode, selectedIds: string[], direction: -1 | 1, selection?: IOutlineSelection, operation?: IOutlineOperation) => boolean;
|
|
32
|
+
export {};
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
const canMoveNode = (move) => {
|
|
2
|
+
if (!move.dragNode || !move.dropNode)
|
|
3
|
+
return false;
|
|
4
|
+
if (move.dragNode === move.dropNode || move.dragNode.isRoot)
|
|
5
|
+
return false;
|
|
6
|
+
return !move.dragNode.contains(move.dropNode);
|
|
7
|
+
};
|
|
8
|
+
export const moveOutlineNode = (tree, dragId, dropId, options) => {
|
|
9
|
+
const dragNode = tree.findById(dragId);
|
|
10
|
+
const dropNode = tree.findById(dropId);
|
|
11
|
+
const move = { dragNode, dropNode };
|
|
12
|
+
if (!canMoveNode(move))
|
|
13
|
+
return false;
|
|
14
|
+
const detachStandaloneNode = () => {
|
|
15
|
+
if (move.dragNode.isInOperation || !move.dragNode.parent)
|
|
16
|
+
return;
|
|
17
|
+
move.dragNode.parent.children = move.dragNode.parent.children.filter(child => child !== move.dragNode);
|
|
18
|
+
};
|
|
19
|
+
if (!options.dropToGap) {
|
|
20
|
+
if (!move.dropNode.allowAppend([move.dragNode]))
|
|
21
|
+
return false;
|
|
22
|
+
detachStandaloneNode();
|
|
23
|
+
return move.dropNode.append(move.dragNode).length > 0;
|
|
24
|
+
}
|
|
25
|
+
if (!move.dropNode.parent || !move.dropNode.allowSibling([move.dragNode]))
|
|
26
|
+
return false;
|
|
27
|
+
detachStandaloneNode();
|
|
28
|
+
if (options.dropPosition > 0) {
|
|
29
|
+
return move.dropNode.insertAfter(move.dragNode).length > 0;
|
|
30
|
+
}
|
|
31
|
+
return move.dropNode.insertBefore(move.dragNode).length > 0;
|
|
32
|
+
};
|
|
33
|
+
const resolveDropPosition = (info) => {
|
|
34
|
+
const dropNodePositionParts = String(info.node.pos).split('-');
|
|
35
|
+
const dropNodePosition = Number(dropNodePositionParts[dropNodePositionParts.length - 1]);
|
|
36
|
+
return info.dropPosition - dropNodePosition;
|
|
37
|
+
};
|
|
38
|
+
const finishOutlineMove = (dragId, selection, operation) => {
|
|
39
|
+
operation?.dragClean?.();
|
|
40
|
+
operation?.hover?.clear?.();
|
|
41
|
+
operation?.snapshot?.('move:outline:node');
|
|
42
|
+
selection?.select?.(dragId);
|
|
43
|
+
};
|
|
44
|
+
export const handleOutlineDrop = (tree, info, selection, operation) => {
|
|
45
|
+
const dragId = String(info.dragNode.key);
|
|
46
|
+
const dropId = String(info.node.key);
|
|
47
|
+
const moved = moveOutlineNode(tree, dragId, dropId, {
|
|
48
|
+
dropPosition: resolveDropPosition(info),
|
|
49
|
+
dropToGap: info.dropToGap,
|
|
50
|
+
});
|
|
51
|
+
if (!moved)
|
|
52
|
+
return false;
|
|
53
|
+
finishOutlineMove(dragId, selection, operation);
|
|
54
|
+
return true;
|
|
55
|
+
};
|
|
56
|
+
export const moveOutlineNodeBySiblingStep = (tree, dragId, direction) => {
|
|
57
|
+
const dragNode = tree.findById(dragId);
|
|
58
|
+
if (!dragNode?.parent || dragNode.isRoot)
|
|
59
|
+
return false;
|
|
60
|
+
const siblings = dragNode.parent.children;
|
|
61
|
+
const currentIndex = siblings.indexOf(dragNode);
|
|
62
|
+
const targetNode = siblings[currentIndex + direction];
|
|
63
|
+
if (!targetNode)
|
|
64
|
+
return false;
|
|
65
|
+
return moveOutlineNode(tree, dragId, targetNode.id, {
|
|
66
|
+
dropPosition: direction,
|
|
67
|
+
dropToGap: true,
|
|
68
|
+
});
|
|
69
|
+
};
|
|
70
|
+
export const handleOutlineKeyboardMove = (tree, selectedIds, direction, selection, operation) => {
|
|
71
|
+
const dragId = selectedIds.find(id => !tree.findById(id)?.isRoot);
|
|
72
|
+
if (!dragId)
|
|
73
|
+
return false;
|
|
74
|
+
const moved = moveOutlineNodeBySiblingStep(tree, dragId, direction);
|
|
75
|
+
if (!moved)
|
|
76
|
+
return false;
|
|
77
|
+
finishOutlineMove(dragId, selection, operation);
|
|
78
|
+
return true;
|
|
79
|
+
};
|