liteflow-editor-process 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/LICENSE +21 -0
- package/README.md +1020 -0
- package/dist/LiteFlowEditor/assets/and-icon.svg +20 -0
- package/dist/LiteFlowEditor/assets/catch-icon.svg +14 -0
- package/dist/LiteFlowEditor/assets/chain-icon.svg +11 -0
- package/dist/LiteFlowEditor/assets/common-icon.svg +18 -0
- package/dist/LiteFlowEditor/assets/end-icon.svg +14 -0
- package/dist/LiteFlowEditor/assets/for-icon.svg +20 -0
- package/dist/LiteFlowEditor/assets/if-icon.svg +14 -0
- package/dist/LiteFlowEditor/assets/indicator-icons.svg +16 -0
- package/dist/LiteFlowEditor/assets/intermediate-end-icon.svg +20 -0
- package/dist/LiteFlowEditor/assets/intermediate-event-catch-error.svg +40 -0
- package/dist/LiteFlowEditor/assets/iterator-icon.svg +7 -0
- package/dist/LiteFlowEditor/assets/little-warning-icon.svg +1 -0
- package/dist/LiteFlowEditor/assets/not-icon.svg +20 -0
- package/dist/LiteFlowEditor/assets/or-icon.svg +20 -0
- package/dist/LiteFlowEditor/assets/start-icon.svg +16 -0
- package/dist/LiteFlowEditor/assets/switch-icon.svg +15 -0
- package/dist/LiteFlowEditor/assets/then-icon.svg +23 -0
- package/dist/LiteFlowEditor/assets/virtual-icon.svg +21 -0
- package/dist/LiteFlowEditor/assets/warning-icon.svg +1 -0
- package/dist/LiteFlowEditor/assets/when-icon.svg +21 -0
- package/dist/LiteFlowEditor/assets/while-icon.svg +24 -0
- package/dist/LiteFlowEditor/cells/and.d.ts +2 -0
- package/dist/LiteFlowEditor/cells/and.js +8 -0
- package/dist/LiteFlowEditor/cells/catch.d.ts +2 -0
- package/dist/LiteFlowEditor/cells/catch.js +8 -0
- package/dist/LiteFlowEditor/cells/chain.d.ts +2 -0
- package/dist/LiteFlowEditor/cells/chain.js +8 -0
- package/dist/LiteFlowEditor/cells/common.d.ts +2 -0
- package/dist/LiteFlowEditor/cells/common.js +8 -0
- package/dist/LiteFlowEditor/cells/end.d.ts +2 -0
- package/dist/LiteFlowEditor/cells/end.js +11 -0
- package/dist/LiteFlowEditor/cells/for.d.ts +2 -0
- package/dist/LiteFlowEditor/cells/for.js +8 -0
- package/dist/LiteFlowEditor/cells/if.d.ts +2 -0
- package/dist/LiteFlowEditor/cells/if.js +9 -0
- package/dist/LiteFlowEditor/cells/index.d.ts +25 -0
- package/dist/LiteFlowEditor/cells/index.js +219 -0
- package/dist/LiteFlowEditor/cells/intermediate-end.d.ts +2 -0
- package/dist/LiteFlowEditor/cells/intermediate-end.js +11 -0
- package/dist/LiteFlowEditor/cells/iterator.d.ts +2 -0
- package/dist/LiteFlowEditor/cells/iterator.js +8 -0
- package/dist/LiteFlowEditor/cells/not.d.ts +2 -0
- package/dist/LiteFlowEditor/cells/not.js +8 -0
- package/dist/LiteFlowEditor/cells/or.d.ts +2 -0
- package/dist/LiteFlowEditor/cells/or.js +8 -0
- package/dist/LiteFlowEditor/cells/start.d.ts +2 -0
- package/dist/LiteFlowEditor/cells/start.js +11 -0
- package/dist/LiteFlowEditor/cells/switch.d.ts +2 -0
- package/dist/LiteFlowEditor/cells/switch.js +9 -0
- package/dist/LiteFlowEditor/cells/then.d.ts +2 -0
- package/dist/LiteFlowEditor/cells/then.js +11 -0
- package/dist/LiteFlowEditor/cells/virtual.d.ts +2 -0
- package/dist/LiteFlowEditor/cells/virtual.js +8 -0
- package/dist/LiteFlowEditor/cells/when.d.ts +2 -0
- package/dist/LiteFlowEditor/cells/when.js +11 -0
- package/dist/LiteFlowEditor/cells/while.d.ts +2 -0
- package/dist/LiteFlowEditor/cells/while.js +8 -0
- package/dist/LiteFlowEditor/common/anchor.d.ts +2 -0
- package/dist/LiteFlowEditor/common/anchor.js +10 -0
- package/dist/LiteFlowEditor/common/connector.d.ts +2 -0
- package/dist/LiteFlowEditor/common/connector.js +20 -0
- package/dist/LiteFlowEditor/common/edge.d.ts +61 -0
- package/dist/LiteFlowEditor/common/edge.js +57 -0
- package/dist/LiteFlowEditor/common/events.d.ts +4 -0
- package/dist/LiteFlowEditor/common/events.js +97 -0
- package/dist/LiteFlowEditor/common/index.d.ts +4 -0
- package/dist/LiteFlowEditor/common/index.js +11 -0
- package/dist/LiteFlowEditor/common/layout.d.ts +12 -0
- package/dist/LiteFlowEditor/common/layout.js +308 -0
- package/dist/LiteFlowEditor/common/router.d.ts +2 -0
- package/dist/LiteFlowEditor/common/router.js +40 -0
- package/dist/LiteFlowEditor/common/shortcuts.d.ts +10 -0
- package/dist/LiteFlowEditor/common/shortcuts.js +183 -0
- package/dist/LiteFlowEditor/components/NodeBadge/index.d.ts +6 -0
- package/dist/LiteFlowEditor/components/NodeBadge/index.js +24 -0
- package/dist/LiteFlowEditor/components/NodeBadge/index.module.less +10 -0
- package/dist/LiteFlowEditor/components/NodeToolBar/index.d.ts +6 -0
- package/dist/LiteFlowEditor/components/NodeToolBar/index.js +121 -0
- package/dist/LiteFlowEditor/components/NodeToolBar/index.module.less +133 -0
- package/dist/LiteFlowEditor/components/NodeView/index.d.ts +7 -0
- package/dist/LiteFlowEditor/components/NodeView/index.js +14 -0
- package/dist/LiteFlowEditor/components/NodeView/index.module.less +14 -0
- package/dist/LiteFlowEditor/components/index.d.ts +3 -0
- package/dist/LiteFlowEditor/components/index.js +3 -0
- package/dist/LiteFlowEditor/constant/index.d.ts +79 -0
- package/dist/LiteFlowEditor/constant/index.js +215 -0
- package/dist/LiteFlowEditor/context/GraphContext.d.ts +13 -0
- package/dist/LiteFlowEditor/context/GraphContext.js +10 -0
- package/dist/LiteFlowEditor/context/ScriptContext.d.ts +37 -0
- package/dist/LiteFlowEditor/context/ScriptContext.js +15 -0
- package/dist/LiteFlowEditor/hooks/index.d.ts +5 -0
- package/dist/LiteFlowEditor/hooks/index.js +5 -0
- package/dist/LiteFlowEditor/hooks/useClickAway.d.ts +5 -0
- package/dist/LiteFlowEditor/hooks/useClickAway.js +38 -0
- package/dist/LiteFlowEditor/hooks/useGraph.d.ts +1 -0
- package/dist/LiteFlowEditor/hooks/useGraph.js +7 -0
- package/dist/LiteFlowEditor/hooks/useGraphWrapper.d.ts +2 -0
- package/dist/LiteFlowEditor/hooks/useGraphWrapper.js +7 -0
- package/dist/LiteFlowEditor/hooks/useHistory.d.ts +2 -0
- package/dist/LiteFlowEditor/hooks/useHistory.js +69 -0
- package/dist/LiteFlowEditor/hooks/useModel.d.ts +3 -0
- package/dist/LiteFlowEditor/hooks/useModel.js +7 -0
- package/dist/LiteFlowEditor/hooks/useUpdateEffect.d.ts +7 -0
- package/dist/LiteFlowEditor/hooks/useUpdateEffect.js +17 -0
- package/dist/LiteFlowEditor/i18n/en_US/translation.json +138 -0
- package/dist/LiteFlowEditor/i18n/index.d.ts +2 -0
- package/dist/LiteFlowEditor/i18n/index.js +28 -0
- package/dist/LiteFlowEditor/i18n/zh_CN/translation.json +139 -0
- package/dist/LiteFlowEditor/i18n/zh_TW/translation.json +139 -0
- package/dist/LiteFlowEditor/index.d.ts +37 -0
- package/dist/LiteFlowEditor/index.js +299 -0
- package/dist/LiteFlowEditor/index.module.less +127 -0
- package/dist/LiteFlowEditor/mock/index.d.ts +2 -0
- package/dist/LiteFlowEditor/mock/index.js +272 -0
- package/dist/LiteFlowEditor/model/builder.d.ts +43 -0
- package/dist/LiteFlowEditor/model/builder.js +239 -0
- package/dist/LiteFlowEditor/model/chain.d.ts +83 -0
- package/dist/LiteFlowEditor/model/chain.js +278 -0
- package/dist/LiteFlowEditor/model/el/and-operator.d.ts +53 -0
- package/dist/LiteFlowEditor/model/el/and-operator.js +178 -0
- package/dist/LiteFlowEditor/model/el/catch-operator.d.ts +81 -0
- package/dist/LiteFlowEditor/model/el/catch-operator.js +338 -0
- package/dist/LiteFlowEditor/model/el/chain-operator.d.ts +53 -0
- package/dist/LiteFlowEditor/model/el/chain-operator.js +170 -0
- package/dist/LiteFlowEditor/model/el/for-operator.d.ts +56 -0
- package/dist/LiteFlowEditor/model/el/for-operator.js +171 -0
- package/dist/LiteFlowEditor/model/el/if-operator.d.ts +64 -0
- package/dist/LiteFlowEditor/model/el/if-operator.js +265 -0
- package/dist/LiteFlowEditor/model/el/index.d.ts +40 -0
- package/dist/LiteFlowEditor/model/el/index.js +47 -0
- package/dist/LiteFlowEditor/model/el/iterator-operator.d.ts +56 -0
- package/dist/LiteFlowEditor/model/el/iterator-operator.js +183 -0
- package/dist/LiteFlowEditor/model/el/node-operator.d.ts +62 -0
- package/dist/LiteFlowEditor/model/el/node-operator.js +136 -0
- package/dist/LiteFlowEditor/model/el/not-operator.d.ts +68 -0
- package/dist/LiteFlowEditor/model/el/not-operator.js +231 -0
- package/dist/LiteFlowEditor/model/el/or-operator.d.ts +53 -0
- package/dist/LiteFlowEditor/model/el/or-operator.js +178 -0
- package/dist/LiteFlowEditor/model/el/switch-operator.d.ts +56 -0
- package/dist/LiteFlowEditor/model/el/switch-operator.js +173 -0
- package/dist/LiteFlowEditor/model/el/then-operator.d.ts +66 -0
- package/dist/LiteFlowEditor/model/el/then-operator.js +159 -0
- package/dist/LiteFlowEditor/model/el/when-operator.d.ts +58 -0
- package/dist/LiteFlowEditor/model/el/when-operator.js +181 -0
- package/dist/LiteFlowEditor/model/el/while-operator.d.ts +56 -0
- package/dist/LiteFlowEditor/model/el/while-operator.js +171 -0
- package/dist/LiteFlowEditor/model/node.d.ts +182 -0
- package/dist/LiteFlowEditor/model/node.js +463 -0
- package/dist/LiteFlowEditor/model/utils/createTag.d.ts +1 -0
- package/dist/LiteFlowEditor/model/utils/createTag.js +5 -0
- package/dist/LiteFlowEditor/model/utils/end.d.ts +87 -0
- package/dist/LiteFlowEditor/model/utils/end.js +185 -0
- package/dist/LiteFlowEditor/model/utils/index.d.ts +7 -0
- package/dist/LiteFlowEditor/model/utils/index.js +10 -0
- package/dist/LiteFlowEditor/model/utils/start.d.ts +87 -0
- package/dist/LiteFlowEditor/model/utils/start.js +185 -0
- package/dist/LiteFlowEditor/model/utils/virtual.d.ts +78 -0
- package/dist/LiteFlowEditor/model/utils/virtual.js +167 -0
- package/dist/LiteFlowEditor/model-checker/checkers/AnalysisNodeChecker.d.ts +7 -0
- package/dist/LiteFlowEditor/model-checker/checkers/AnalysisNodeChecker.js +44 -0
- package/dist/LiteFlowEditor/model-checker/checkers/CurScheduleSetChecker.d.ts +7 -0
- package/dist/LiteFlowEditor/model-checker/checkers/CurScheduleSetChecker.js +26 -0
- package/dist/LiteFlowEditor/model-checker/checkers/InputListChecker.d.ts +7 -0
- package/dist/LiteFlowEditor/model-checker/checkers/InputListChecker.js +39 -0
- package/dist/LiteFlowEditor/model-checker/checkers/InputListValueChecker.d.ts +7 -0
- package/dist/LiteFlowEditor/model-checker/checkers/InputListValueChecker.js +154 -0
- package/dist/LiteFlowEditor/model-checker/checkers/IteratorBindChecker.d.ts +7 -0
- package/dist/LiteFlowEditor/model-checker/checkers/IteratorBindChecker.js +27 -0
- package/dist/LiteFlowEditor/model-checker/checkers/QueryDimensionChecker.d.ts +7 -0
- package/dist/LiteFlowEditor/model-checker/checkers/QueryDimensionChecker.js +33 -0
- package/dist/LiteFlowEditor/model-checker/checkers/QueryLogChecker.d.ts +7 -0
- package/dist/LiteFlowEditor/model-checker/checkers/QueryLogChecker.js +27 -0
- package/dist/LiteFlowEditor/model-checker/checkers/ReportTemplateChecker.d.ts +7 -0
- package/dist/LiteFlowEditor/model-checker/checkers/ReportTemplateChecker.js +27 -0
- package/dist/LiteFlowEditor/model-checker/checkers/UnconfiguredComponentChecker.d.ts +7 -0
- package/dist/LiteFlowEditor/model-checker/checkers/UnconfiguredComponentChecker.js +27 -0
- package/dist/LiteFlowEditor/model-checker/checkers/index.d.ts +14 -0
- package/dist/LiteFlowEditor/model-checker/checkers/index.js +38 -0
- package/dist/LiteFlowEditor/model-checker/index.d.ts +22 -0
- package/dist/LiteFlowEditor/model-checker/index.js +43 -0
- package/dist/LiteFlowEditor/model-checker/types.d.ts +11 -0
- package/dist/LiteFlowEditor/model-checker/types.js +1 -0
- package/dist/LiteFlowEditor/panels/breadcrumb/index.d.ts +7 -0
- package/dist/LiteFlowEditor/panels/breadcrumb/index.js +67 -0
- package/dist/LiteFlowEditor/panels/breadcrumb/index.module.less +23 -0
- package/dist/LiteFlowEditor/panels/flowGraph/contextMenu/index.d.ts +11 -0
- package/dist/LiteFlowEditor/panels/flowGraph/contextMenu/index.js +98 -0
- package/dist/LiteFlowEditor/panels/flowGraph/contextMenu/index.module.less +7 -0
- package/dist/LiteFlowEditor/panels/flowGraph/contextMenu/menuConfig/blank.d.ts +8 -0
- package/dist/LiteFlowEditor/panels/flowGraph/contextMenu/menuConfig/blank.js +18 -0
- package/dist/LiteFlowEditor/panels/flowGraph/contextMenu/menuConfig/index.d.ts +3 -0
- package/dist/LiteFlowEditor/panels/flowGraph/contextMenu/menuConfig/index.js +3 -0
- package/dist/LiteFlowEditor/panels/flowGraph/contextMenu/menuConfig/node.d.ts +9 -0
- package/dist/LiteFlowEditor/panels/flowGraph/contextMenu/menuConfig/node.js +10 -0
- package/dist/LiteFlowEditor/panels/flowGraph/contextPad/index.d.ts +14 -0
- package/dist/LiteFlowEditor/panels/flowGraph/contextPad/index.js +108 -0
- package/dist/LiteFlowEditor/panels/flowGraph/contextPad/index.module.less +81 -0
- package/dist/LiteFlowEditor/panels/flowGraph/createFlowGraph.d.ts +3 -0
- package/dist/LiteFlowEditor/panels/flowGraph/createFlowGraph.js +199 -0
- package/dist/LiteFlowEditor/panels/flowGraph/miniMapSimpleNode/index.d.ts +7 -0
- package/dist/LiteFlowEditor/panels/flowGraph/miniMapSimpleNode/index.js +42 -0
- package/dist/LiteFlowEditor/panels/flowGraph/nodeEditorModal/index.d.ts +8 -0
- package/dist/LiteFlowEditor/panels/flowGraph/nodeEditorModal/index.js +110 -0
- package/dist/LiteFlowEditor/panels/flowGraph/nodeEditorModal/index.module.less +11 -0
- package/dist/LiteFlowEditor/panels/layout/index.d.ts +16 -0
- package/dist/LiteFlowEditor/panels/layout/index.js +117 -0
- package/dist/LiteFlowEditor/panels/layout/index.module.less +30 -0
- package/dist/LiteFlowEditor/panels/settingBar/basic/index.d.ts +7 -0
- package/dist/LiteFlowEditor/panels/settingBar/basic/index.js +50 -0
- package/dist/LiteFlowEditor/panels/settingBar/basic/index.module.less +17 -0
- package/dist/LiteFlowEditor/panels/settingBar/index.d.ts +7 -0
- package/dist/LiteFlowEditor/panels/settingBar/index.js +219 -0
- package/dist/LiteFlowEditor/panels/settingBar/index.module.less +45 -0
- package/dist/LiteFlowEditor/panels/settingBar/outline/index.d.ts +7 -0
- package/dist/LiteFlowEditor/panels/settingBar/outline/index.js +124 -0
- package/dist/LiteFlowEditor/panels/settingBar/outline/index.module.less +39 -0
- package/dist/LiteFlowEditor/panels/settingBar/parameters/index.d.ts +6 -0
- package/dist/LiteFlowEditor/panels/settingBar/parameters/index.js +415 -0
- package/dist/LiteFlowEditor/panels/settingBar/parameters/index.module.less +4 -0
- package/dist/LiteFlowEditor/panels/settingBar/properties/CustomDropdown.d.ts +13 -0
- package/dist/LiteFlowEditor/panels/settingBar/properties/CustomDropdown.js +62 -0
- package/dist/LiteFlowEditor/panels/settingBar/properties/DraggableWrapper.d.ts +48 -0
- package/dist/LiteFlowEditor/panels/settingBar/properties/DraggableWrapper.js +94 -0
- package/dist/LiteFlowEditor/panels/settingBar/properties/RichParamEditor-new.d.ts +33 -0
- package/dist/LiteFlowEditor/panels/settingBar/properties/RichParamEditor-new.js +433 -0
- package/dist/LiteFlowEditor/panels/settingBar/properties/RichParamEditor.d.ts +33 -0
- package/dist/LiteFlowEditor/panels/settingBar/properties/RichParamEditor.js +195 -0
- package/dist/LiteFlowEditor/panels/settingBar/properties/component.d.ts +10 -0
- package/dist/LiteFlowEditor/panels/settingBar/properties/component.js +2780 -0
- package/dist/LiteFlowEditor/panels/settingBar/properties/condition.d.ts +7 -0
- package/dist/LiteFlowEditor/panels/settingBar/properties/condition.js +54 -0
- package/dist/LiteFlowEditor/panels/settingBar/properties/index.d.ts +2 -0
- package/dist/LiteFlowEditor/panels/settingBar/properties/index.js +2 -0
- package/dist/LiteFlowEditor/panels/settingBar/properties/index.module.less +149 -0
- package/dist/LiteFlowEditor/panels/sideBar/index.d.ts +7 -0
- package/dist/LiteFlowEditor/panels/sideBar/index.js +153 -0
- package/dist/LiteFlowEditor/panels/sideBar/index.module.less +48 -0
- package/dist/LiteFlowEditor/panels/toolBar/index.d.ts +8 -0
- package/dist/LiteFlowEditor/panels/toolBar/index.js +42 -0
- package/dist/LiteFlowEditor/panels/toolBar/index.module.less +19 -0
- package/dist/LiteFlowEditor/panels/toolBar/widgets/check.d.ts +7 -0
- package/dist/LiteFlowEditor/panels/toolBar/widgets/check.js +40 -0
- package/dist/LiteFlowEditor/panels/toolBar/widgets/common/badge.d.ts +12 -0
- package/dist/LiteFlowEditor/panels/toolBar/widgets/common/badge.js +46 -0
- package/dist/LiteFlowEditor/panels/toolBar/widgets/common/makeBtnWidget.d.ts +15 -0
- package/dist/LiteFlowEditor/panels/toolBar/widgets/common/makeBtnWidget.js +133 -0
- package/dist/LiteFlowEditor/panels/toolBar/widgets/common/makeDropdownWidget.d.ts +14 -0
- package/dist/LiteFlowEditor/panels/toolBar/widgets/common/makeDropdownWidget.js +38 -0
- package/dist/LiteFlowEditor/panels/toolBar/widgets/fitWindow.d.ts +7 -0
- package/dist/LiteFlowEditor/panels/toolBar/widgets/fitWindow.js +17 -0
- package/dist/LiteFlowEditor/panels/toolBar/widgets/fullscreen.d.ts +4 -0
- package/dist/LiteFlowEditor/panels/toolBar/widgets/fullscreen.js +104 -0
- package/dist/LiteFlowEditor/panels/toolBar/widgets/global.less +6 -0
- package/dist/LiteFlowEditor/panels/toolBar/widgets/index.d.ts +7 -0
- package/dist/LiteFlowEditor/panels/toolBar/widgets/index.js +12 -0
- package/dist/LiteFlowEditor/panels/toolBar/widgets/index.module.less +169 -0
- package/dist/LiteFlowEditor/panels/toolBar/widgets/mock.d.ts +7 -0
- package/dist/LiteFlowEditor/panels/toolBar/widgets/mock.js +83 -0
- package/dist/LiteFlowEditor/panels/toolBar/widgets/redo.d.ts +7 -0
- package/dist/LiteFlowEditor/panels/toolBar/widgets/redo.js +16 -0
- package/dist/LiteFlowEditor/panels/toolBar/widgets/save.d.ts +7 -0
- package/dist/LiteFlowEditor/panels/toolBar/widgets/save.js +12 -0
- package/dist/LiteFlowEditor/panels/toolBar/widgets/selection.d.ts +7 -0
- package/dist/LiteFlowEditor/panels/toolBar/widgets/selection.js +23 -0
- package/dist/LiteFlowEditor/panels/toolBar/widgets/undo.d.ts +7 -0
- package/dist/LiteFlowEditor/panels/toolBar/widgets/undo.js +16 -0
- package/dist/LiteFlowEditor/panels/toolBar/widgets/view.d.ts +7 -0
- package/dist/LiteFlowEditor/panels/toolBar/widgets/view.js +37 -0
- package/dist/LiteFlowEditor/panels/toolBar/widgets/zoom.d.ts +7 -0
- package/dist/LiteFlowEditor/panels/toolBar/widgets/zoom.js +67 -0
- package/dist/LiteFlowEditor/utils/eventBus.d.ts +34 -0
- package/dist/LiteFlowEditor/utils/eventBus.js +86 -0
- package/dist/LiteFlowEditor/utils/flowChartUtils.d.ts +9 -0
- package/dist/LiteFlowEditor/utils/flowChartUtils.js +34 -0
- package/dist/LiteFlowEditor/utils/index.d.ts +33 -0
- package/dist/LiteFlowEditor/utils/index.js +245 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +4 -0
- package/package.json +97 -0
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import _taggedTemplateLiteral from "@babel/runtime/helpers/esm/taggedTemplateLiteral";
|
|
2
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
3
|
+
var _templateObject;
|
|
4
|
+
import React, { useEffect, useRef, useState } from 'react';
|
|
5
|
+
import { createPortal } from 'react-dom';
|
|
6
|
+
import { css } from '@emotion/css';
|
|
7
|
+
var getDropdownContainer = function getDropdownContainer() {
|
|
8
|
+
var container = document.getElementById('dropdown-root');
|
|
9
|
+
if (!container) {
|
|
10
|
+
container = document.createElement('div');
|
|
11
|
+
container.id = 'dropdown-root';
|
|
12
|
+
document.body.appendChild(container);
|
|
13
|
+
}
|
|
14
|
+
return container;
|
|
15
|
+
};
|
|
16
|
+
var CustomDropdown = function CustomDropdown(_ref) {
|
|
17
|
+
var open = _ref.open,
|
|
18
|
+
position = _ref.position,
|
|
19
|
+
onClose = _ref.onClose,
|
|
20
|
+
children = _ref.children;
|
|
21
|
+
var ref = useRef(null);
|
|
22
|
+
var _useState = useState(false),
|
|
23
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
24
|
+
visible = _useState2[0],
|
|
25
|
+
setVisible = _useState2[1];
|
|
26
|
+
|
|
27
|
+
// 控制visible状态,open后下一帧显示,关闭则隐藏
|
|
28
|
+
useEffect(function () {
|
|
29
|
+
if (open) {
|
|
30
|
+
requestAnimationFrame(function () {
|
|
31
|
+
return setVisible(true);
|
|
32
|
+
});
|
|
33
|
+
} else {
|
|
34
|
+
setVisible(false);
|
|
35
|
+
}
|
|
36
|
+
}, [open]);
|
|
37
|
+
var handleClickOutside = function handleClickOutside(event) {
|
|
38
|
+
if (ref.current && !ref.current.contains(event.target)) {
|
|
39
|
+
onClose();
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
var handleEscKey = function handleEscKey(e) {
|
|
43
|
+
if (e.key === 'Escape') onClose();
|
|
44
|
+
};
|
|
45
|
+
useEffect(function () {
|
|
46
|
+
if (open) {
|
|
47
|
+
document.addEventListener('mousedown', handleClickOutside);
|
|
48
|
+
document.addEventListener('keydown', handleEscKey);
|
|
49
|
+
}
|
|
50
|
+
return function () {
|
|
51
|
+
document.removeEventListener('mousedown', handleClickOutside);
|
|
52
|
+
document.removeEventListener('keydown', handleEscKey);
|
|
53
|
+
};
|
|
54
|
+
}, [open]);
|
|
55
|
+
if (!open) return null;
|
|
56
|
+
var computedWidth = typeof position.width === 'number' ? "".concat(position.width, "px") : position.width || '200px';
|
|
57
|
+
return /*#__PURE__*/createPortal( /*#__PURE__*/React.createElement("div", {
|
|
58
|
+
ref: ref,
|
|
59
|
+
className: css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n position: absolute;\n top: ", "px;\n left: ", "px;\n max-height: 230px;\n overflow: auto;\n z-index: 1000;\n background: white;\n border: 1px solid #ccc;\n border-radius: 4px;\n box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);\n min-width: ", ";\n opacity: 0;\n visibility: hidden;\n pointer-events: none;\n transform: translateY(-4px);\n transition: opacity 0.2s ease, transform 0.2s ease;\n\n ", "\n "])), position.top, position.left, computedWidth, visible && "\n opacity: 1;\n visibility: visible;\n pointer-events: auto;\n transform: translateY(0);\n ")
|
|
60
|
+
}, children), getDropdownContainer());
|
|
61
|
+
};
|
|
62
|
+
export default CustomDropdown;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
type DraggableWrapperProps<T> = {
|
|
3
|
+
/** 源数据数组 */
|
|
4
|
+
data: {
|
|
5
|
+
asColumn: string;
|
|
6
|
+
label: string;
|
|
7
|
+
[key: string]: any;
|
|
8
|
+
}[];
|
|
9
|
+
/** 唯一标识字段 */
|
|
10
|
+
rowKey: keyof {
|
|
11
|
+
asColumn: string;
|
|
12
|
+
label: string;
|
|
13
|
+
[key: string]: any;
|
|
14
|
+
};
|
|
15
|
+
/** 拖拽排序后,通知外部更新顺序 */
|
|
16
|
+
onChange: (newList: {
|
|
17
|
+
asColumn: string;
|
|
18
|
+
label: string;
|
|
19
|
+
[key: string]: any;
|
|
20
|
+
}[]) => void;
|
|
21
|
+
/** 你来负责渲染每一项,组件只处理拖拽行为 */
|
|
22
|
+
children: (params: {
|
|
23
|
+
item: {
|
|
24
|
+
asColumn: string;
|
|
25
|
+
label: string;
|
|
26
|
+
[key: string]: any;
|
|
27
|
+
};
|
|
28
|
+
index: number;
|
|
29
|
+
listeners: {
|
|
30
|
+
draggable: true;
|
|
31
|
+
onDragStart: (e: React.DragEvent) => void;
|
|
32
|
+
onDragOver: (e: React.DragEvent) => void;
|
|
33
|
+
onDrop: () => void;
|
|
34
|
+
onDragEnd: () => void;
|
|
35
|
+
};
|
|
36
|
+
isDragging: boolean;
|
|
37
|
+
isOver: boolean;
|
|
38
|
+
}) => React.ReactNode;
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* 可拖拽的列表组件
|
|
42
|
+
* @param data 源数据数组
|
|
43
|
+
* @param rowKey 唯一标识字段
|
|
44
|
+
* @param onChange 拖拽排序后,通知外部更新顺序
|
|
45
|
+
* @param children 你来负责渲染每一项,组件只处理拖拽行为
|
|
46
|
+
*/
|
|
47
|
+
declare function DraggableWrapper<T>({ data, rowKey, onChange, children, }: DraggableWrapperProps<T>): React.JSX.Element;
|
|
48
|
+
export default DraggableWrapper;
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
2
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
3
|
+
import React, { useState, useRef } from "react";
|
|
4
|
+
function throttle(fn) {
|
|
5
|
+
var delay = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 60;
|
|
6
|
+
var last = 0;
|
|
7
|
+
return function () {
|
|
8
|
+
var now = Date.now();
|
|
9
|
+
if (now - last >= delay) {
|
|
10
|
+
last = now;
|
|
11
|
+
fn.apply(void 0, arguments);
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* 可拖拽的列表组件
|
|
17
|
+
* @param data 源数据数组
|
|
18
|
+
* @param rowKey 唯一标识字段
|
|
19
|
+
* @param onChange 拖拽排序后,通知外部更新顺序
|
|
20
|
+
* @param children 你来负责渲染每一项,组件只处理拖拽行为
|
|
21
|
+
*/
|
|
22
|
+
function DraggableWrapper(_ref) {
|
|
23
|
+
var data = _ref.data,
|
|
24
|
+
rowKey = _ref.rowKey,
|
|
25
|
+
onChange = _ref.onChange,
|
|
26
|
+
children = _ref.children;
|
|
27
|
+
var _useState = useState(null),
|
|
28
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
29
|
+
dragIndex = _useState2[0],
|
|
30
|
+
setDragIndex = _useState2[1];
|
|
31
|
+
var _useState3 = useState(null),
|
|
32
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
33
|
+
hoverIndex = _useState4[0],
|
|
34
|
+
setHoverIndex = _useState4[1];
|
|
35
|
+
var draggingItemRef = useRef(null);
|
|
36
|
+
var handleDragStart = function handleDragStart(index, e) {
|
|
37
|
+
setDragIndex(index);
|
|
38
|
+
draggingItemRef.current = e.currentTarget;
|
|
39
|
+
setTimeout(function () {
|
|
40
|
+
if (draggingItemRef.current) {
|
|
41
|
+
draggingItemRef.current.style.opacity = "0.5";
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
};
|
|
45
|
+
var handleDragEnd = function handleDragEnd() {
|
|
46
|
+
if (draggingItemRef.current) {
|
|
47
|
+
draggingItemRef.current.style.opacity = "1";
|
|
48
|
+
}
|
|
49
|
+
draggingItemRef.current = null;
|
|
50
|
+
setDragIndex(null);
|
|
51
|
+
setHoverIndex(null);
|
|
52
|
+
};
|
|
53
|
+
var throttledHover = throttle(function (index) {
|
|
54
|
+
setHoverIndex(index);
|
|
55
|
+
}, 100);
|
|
56
|
+
var handleDragOver = function handleDragOver(e, index) {
|
|
57
|
+
e.preventDefault();
|
|
58
|
+
throttledHover(index);
|
|
59
|
+
};
|
|
60
|
+
var handleDrop = function handleDrop(index) {
|
|
61
|
+
if (dragIndex === null || dragIndex === index) return;
|
|
62
|
+
var newList = _toConsumableArray(data);
|
|
63
|
+
var _newList$splice = newList.splice(dragIndex, 1),
|
|
64
|
+
_newList$splice2 = _slicedToArray(_newList$splice, 1),
|
|
65
|
+
movedItem = _newList$splice2[0];
|
|
66
|
+
newList.splice(index, 0, movedItem);
|
|
67
|
+
onChange(newList);
|
|
68
|
+
setDragIndex(null);
|
|
69
|
+
setHoverIndex(null);
|
|
70
|
+
};
|
|
71
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, data.map(function (item, index) {
|
|
72
|
+
var listeners = {
|
|
73
|
+
draggable: true,
|
|
74
|
+
onDragStart: function onDragStart(e) {
|
|
75
|
+
return handleDragStart(index, e);
|
|
76
|
+
},
|
|
77
|
+
onDragOver: function onDragOver(e) {
|
|
78
|
+
return handleDragOver(e, index);
|
|
79
|
+
},
|
|
80
|
+
onDrop: function onDrop() {
|
|
81
|
+
return handleDrop(index);
|
|
82
|
+
},
|
|
83
|
+
onDragEnd: handleDragEnd
|
|
84
|
+
};
|
|
85
|
+
return children({
|
|
86
|
+
item: item,
|
|
87
|
+
index: index,
|
|
88
|
+
listeners: listeners,
|
|
89
|
+
isDragging: index === dragIndex,
|
|
90
|
+
isOver: index === hoverIndex && index !== dragIndex
|
|
91
|
+
});
|
|
92
|
+
}));
|
|
93
|
+
}
|
|
94
|
+
export default DraggableWrapper;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Text, Descendant, BaseEditor } from 'slate';
|
|
3
|
+
import { ReactEditor } from 'slate-react';
|
|
4
|
+
interface VariableElement {
|
|
5
|
+
type: 'variable';
|
|
6
|
+
label: string;
|
|
7
|
+
value: string;
|
|
8
|
+
children: Text[];
|
|
9
|
+
}
|
|
10
|
+
type CustomElement = VariableElement | {
|
|
11
|
+
type: 'paragraph';
|
|
12
|
+
children: Descendant[];
|
|
13
|
+
};
|
|
14
|
+
declare module 'slate' {
|
|
15
|
+
interface CustomTypes {
|
|
16
|
+
Editor: BaseEditor & ReactEditor;
|
|
17
|
+
Element: CustomElement;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
interface ParamItem {
|
|
21
|
+
label: string;
|
|
22
|
+
value?: string;
|
|
23
|
+
options: ParamItem[];
|
|
24
|
+
disabled?: boolean;
|
|
25
|
+
}
|
|
26
|
+
interface RichParamEditorProps {
|
|
27
|
+
value: Descendant[];
|
|
28
|
+
onChange: (value: Descendant[]) => void;
|
|
29
|
+
options: ParamItem[];
|
|
30
|
+
disabled?: boolean;
|
|
31
|
+
}
|
|
32
|
+
declare const RichParamEditor: React.FC<RichParamEditorProps>;
|
|
33
|
+
export default RichParamEditor;
|
|
@@ -0,0 +1,433 @@
|
|
|
1
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
|
+
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
3
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
4
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
5
|
+
import _taggedTemplateLiteral from "@babel/runtime/helpers/esm/taggedTemplateLiteral";
|
|
6
|
+
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10, _templateObject11;
|
|
7
|
+
import React, { useMemo, useCallback, useState, useRef, useEffect } from 'react';
|
|
8
|
+
import { createEditor, Transforms, Text, Editor, Element as SlateElement, Range } from 'slate';
|
|
9
|
+
import { Slate, Editable, withReact, ReactEditor } from 'slate-react';
|
|
10
|
+
import { css } from '@emotion/css';
|
|
11
|
+
import CustomDropdown from "./CustomDropdown";
|
|
12
|
+
// 变量标签组件
|
|
13
|
+
var VariableTag = function VariableTag(_ref) {
|
|
14
|
+
var attributes = _ref.attributes,
|
|
15
|
+
children = _ref.children,
|
|
16
|
+
element = _ref.element;
|
|
17
|
+
var el = element;
|
|
18
|
+
var handleClick = function handleClick(e) {
|
|
19
|
+
e.preventDefault();
|
|
20
|
+
e.stopPropagation();
|
|
21
|
+
};
|
|
22
|
+
return /*#__PURE__*/React.createElement("span", _extends({}, attributes, {
|
|
23
|
+
contentEditable: false,
|
|
24
|
+
onClick: handleClick,
|
|
25
|
+
className: css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n display: inline-block;\n margin: 2px 2px;\n padding: 2px 8px;\n background: linear-gradient(135deg, #e6f7ff 0%, #bae7ff 100%);\n border: 1px solid #91d5ff;\n border-radius: 6px;\n font-size: 12px;\n font-weight: 500;\n color: #1890ff;\n user-select: none;\n cursor: default;\n transition: all 0.2s cubic-bezier(0.645, 0.045, 0.355, 1);\n box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);\n &:hover {\n background: linear-gradient(135deg, #bae7ff 0%, #91d5ff 100%);\n border-color: #40a9ff;\n transform: translateY(-1px);\n box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);\n }\n "])))
|
|
26
|
+
}), el.label);
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
// 元素渲染组件
|
|
30
|
+
var Element = function Element(props) {
|
|
31
|
+
var attributes = props.attributes,
|
|
32
|
+
children = props.children,
|
|
33
|
+
element = props.element;
|
|
34
|
+
switch (element.type) {
|
|
35
|
+
case 'variable':
|
|
36
|
+
return /*#__PURE__*/React.createElement(VariableTag, props);
|
|
37
|
+
default:
|
|
38
|
+
return /*#__PURE__*/React.createElement("span", attributes, children);
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
// 支持变量的编辑器插件
|
|
43
|
+
var withVariables = function withVariables(editor) {
|
|
44
|
+
var isInline = editor.isInline,
|
|
45
|
+
isVoid = editor.isVoid,
|
|
46
|
+
normalizeNode = editor.normalizeNode;
|
|
47
|
+
editor.isInline = function (element) {
|
|
48
|
+
return element.type === 'variable' ? true : isInline(element);
|
|
49
|
+
};
|
|
50
|
+
editor.isVoid = function (element) {
|
|
51
|
+
return element.type === 'variable' ? true : isVoid(element);
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
// 确保变量节点后面有文本节点
|
|
55
|
+
editor.normalizeNode = function (entry) {
|
|
56
|
+
var _entry = _slicedToArray(entry, 2),
|
|
57
|
+
node = _entry[0],
|
|
58
|
+
path = _entry[1];
|
|
59
|
+
if (SlateElement.isElement(node) && node.type === 'variable') {
|
|
60
|
+
// 如果变量后面没有文本节点,添加一个空文本节点
|
|
61
|
+
var nextPath = [].concat(_toConsumableArray(path.slice(0, -1)), [path[path.length - 1] + 1]);
|
|
62
|
+
try {
|
|
63
|
+
var nextNode = Editor.node(editor, nextPath);
|
|
64
|
+
if (!nextNode || !Text.isText(nextNode[0])) {
|
|
65
|
+
Transforms.insertNodes(editor, {
|
|
66
|
+
text: ''
|
|
67
|
+
}, {
|
|
68
|
+
at: nextPath
|
|
69
|
+
});
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
} catch (_unused) {
|
|
73
|
+
// 如果路径不存在,说明变量是最后一个节点,需要添加文本节点
|
|
74
|
+
Transforms.insertNodes(editor, {
|
|
75
|
+
text: ''
|
|
76
|
+
}, {
|
|
77
|
+
at: nextPath
|
|
78
|
+
});
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
normalizeNode(entry);
|
|
83
|
+
};
|
|
84
|
+
return editor;
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
// 插入变量
|
|
88
|
+
var insertVariable = function insertVariable(editor, variable) {
|
|
89
|
+
if (!variable.value) return;
|
|
90
|
+
var variableElement = {
|
|
91
|
+
type: 'variable',
|
|
92
|
+
label: variable.label,
|
|
93
|
+
value: variable.value,
|
|
94
|
+
children: [{
|
|
95
|
+
text: ''
|
|
96
|
+
}]
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
// 删除触发字符
|
|
100
|
+
Transforms.delete(editor, {
|
|
101
|
+
unit: 'character',
|
|
102
|
+
reverse: true
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
// 插入变量和后续空格
|
|
106
|
+
Transforms.insertNodes(editor, [variableElement, {
|
|
107
|
+
text: ' '
|
|
108
|
+
}]);
|
|
109
|
+
|
|
110
|
+
// 移动光标到空格之后
|
|
111
|
+
Transforms.move(editor, {
|
|
112
|
+
unit: 'offset'
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
// 确保编辑器获取焦点
|
|
116
|
+
setTimeout(function () {
|
|
117
|
+
ReactEditor.focus(editor);
|
|
118
|
+
}, 0);
|
|
119
|
+
};
|
|
120
|
+
var RichParamEditor = function RichParamEditor(_ref2) {
|
|
121
|
+
var value = _ref2.value,
|
|
122
|
+
onChange = _ref2.onChange,
|
|
123
|
+
options = _ref2.options,
|
|
124
|
+
_ref2$disabled = _ref2.disabled,
|
|
125
|
+
disabled = _ref2$disabled === void 0 ? false : _ref2$disabled;
|
|
126
|
+
var editor = useMemo(function () {
|
|
127
|
+
return withVariables(withReact(createEditor()));
|
|
128
|
+
}, []);
|
|
129
|
+
var renderElement = useCallback(function (props) {
|
|
130
|
+
return /*#__PURE__*/React.createElement(Element, props);
|
|
131
|
+
}, []);
|
|
132
|
+
var editorContainerRef = useRef(null);
|
|
133
|
+
var timeoutRef = useRef(null);
|
|
134
|
+
var _useState = useState(null),
|
|
135
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
136
|
+
target = _useState2[0],
|
|
137
|
+
setTarget = _useState2[1];
|
|
138
|
+
var _useState3 = useState({
|
|
139
|
+
top: 0,
|
|
140
|
+
left: 0,
|
|
141
|
+
width: 0
|
|
142
|
+
}),
|
|
143
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
144
|
+
dropdownPos = _useState4[0],
|
|
145
|
+
setDropdownPos = _useState4[1];
|
|
146
|
+
var _useState5 = useState(0),
|
|
147
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
148
|
+
selectedIndex = _useState6[0],
|
|
149
|
+
setSelectedIndex = _useState6[1];
|
|
150
|
+
var _useState7 = useState(''),
|
|
151
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
152
|
+
searchText = _useState8[0],
|
|
153
|
+
setSearchText = _useState8[1];
|
|
154
|
+
var dropdownContentRef = useRef(null);
|
|
155
|
+
|
|
156
|
+
// 滚动到选中项
|
|
157
|
+
var scrollToSelected = useCallback(function (index) {
|
|
158
|
+
setTimeout(function () {
|
|
159
|
+
var container = dropdownContentRef.current;
|
|
160
|
+
if (!container) return;
|
|
161
|
+
var items = container.querySelectorAll('[data-option-index]');
|
|
162
|
+
var selectedItem = items[index];
|
|
163
|
+
if (selectedItem) {
|
|
164
|
+
var containerRect = container.getBoundingClientRect();
|
|
165
|
+
var itemRect = selectedItem.getBoundingClientRect();
|
|
166
|
+
if (itemRect.top < containerRect.top) {
|
|
167
|
+
container.scrollTop -= containerRect.top - itemRect.top + 8;
|
|
168
|
+
} else if (itemRect.bottom > containerRect.bottom) {
|
|
169
|
+
container.scrollTop += itemRect.bottom - containerRect.bottom + 8;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}, 0);
|
|
173
|
+
}, []);
|
|
174
|
+
|
|
175
|
+
// 清理定时器
|
|
176
|
+
useEffect(function () {
|
|
177
|
+
return function () {
|
|
178
|
+
if (timeoutRef.current) {
|
|
179
|
+
clearTimeout(timeoutRef.current);
|
|
180
|
+
}
|
|
181
|
+
};
|
|
182
|
+
}, []);
|
|
183
|
+
|
|
184
|
+
// 获取扁平化选项用于键盘导航和搜索
|
|
185
|
+
var flatOptions = useMemo(function () {
|
|
186
|
+
var flat = [];
|
|
187
|
+
options.forEach(function (group) {
|
|
188
|
+
if (group.value) flat.push(group);
|
|
189
|
+
flat.push.apply(flat, _toConsumableArray(group.options.filter(function (opt) {
|
|
190
|
+
return !opt.disabled;
|
|
191
|
+
})));
|
|
192
|
+
});
|
|
193
|
+
return flat;
|
|
194
|
+
}, [options]);
|
|
195
|
+
|
|
196
|
+
// 过滤选项
|
|
197
|
+
var filteredOptions = useMemo(function () {
|
|
198
|
+
if (!searchText) return options;
|
|
199
|
+
var filtered = options.map(function (group) {
|
|
200
|
+
return _objectSpread(_objectSpread({}, group), {}, {
|
|
201
|
+
options: group.options.filter(function (opt) {
|
|
202
|
+
var _opt$value;
|
|
203
|
+
return opt.label.toLowerCase().includes(searchText.toLowerCase()) || ((_opt$value = opt.value) === null || _opt$value === void 0 ? void 0 : _opt$value.toLowerCase().includes(searchText.toLowerCase()));
|
|
204
|
+
})
|
|
205
|
+
});
|
|
206
|
+
}).filter(function (group) {
|
|
207
|
+
return group.options.length > 0 || group.value && group.label.toLowerCase().includes(searchText.toLowerCase());
|
|
208
|
+
});
|
|
209
|
+
return filtered;
|
|
210
|
+
}, [options, searchText]);
|
|
211
|
+
|
|
212
|
+
// 更新下拉框位置
|
|
213
|
+
var updateDropdownPosition = useCallback(function () {
|
|
214
|
+
if (timeoutRef.current) {
|
|
215
|
+
clearTimeout(timeoutRef.current);
|
|
216
|
+
}
|
|
217
|
+
timeoutRef.current = setTimeout(function () {
|
|
218
|
+
if (editorContainerRef.current) {
|
|
219
|
+
var rect = editorContainerRef.current.getBoundingClientRect();
|
|
220
|
+
var scrollTop = window.pageYOffset || document.documentElement.scrollTop;
|
|
221
|
+
var scrollLeft = window.pageXOffset || document.documentElement.scrollLeft;
|
|
222
|
+
setDropdownPos({
|
|
223
|
+
top: rect.bottom + scrollTop + 4,
|
|
224
|
+
left: rect.left + scrollLeft,
|
|
225
|
+
width: Math.max(rect.width, 200)
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
}, 0);
|
|
229
|
+
}, []);
|
|
230
|
+
|
|
231
|
+
// 重置搜索状态
|
|
232
|
+
var resetSearchState = useCallback(function () {
|
|
233
|
+
setTarget(null);
|
|
234
|
+
setSelectedIndex(0);
|
|
235
|
+
setSearchText('');
|
|
236
|
+
}, []);
|
|
237
|
+
|
|
238
|
+
// 处理键盘事件
|
|
239
|
+
var handleKeyDown = function handleKeyDown(event) {
|
|
240
|
+
if (target) {
|
|
241
|
+
var availableOptions = flatOptions.filter(function (opt) {
|
|
242
|
+
return !searchText || opt.label.toLowerCase().includes(searchText.toLowerCase());
|
|
243
|
+
});
|
|
244
|
+
switch (event.key) {
|
|
245
|
+
case 'ArrowDown':
|
|
246
|
+
event.preventDefault();
|
|
247
|
+
setSelectedIndex(function (prev) {
|
|
248
|
+
return Math.min(prev + 1, availableOptions.length - 1);
|
|
249
|
+
});
|
|
250
|
+
scrollToSelected(selectedIndex);
|
|
251
|
+
break;
|
|
252
|
+
case 'ArrowUp':
|
|
253
|
+
event.preventDefault();
|
|
254
|
+
setSelectedIndex(function (prev) {
|
|
255
|
+
return Math.max(prev - 1, 0);
|
|
256
|
+
});
|
|
257
|
+
scrollToSelected(selectedIndex);
|
|
258
|
+
break;
|
|
259
|
+
case 'Enter':
|
|
260
|
+
event.preventDefault();
|
|
261
|
+
if (availableOptions[selectedIndex]) {
|
|
262
|
+
handleSelect(availableOptions[selectedIndex]);
|
|
263
|
+
}
|
|
264
|
+
return;
|
|
265
|
+
// 重要:直接返回,不执行后续逻辑
|
|
266
|
+
|
|
267
|
+
case 'Escape':
|
|
268
|
+
event.preventDefault();
|
|
269
|
+
resetSearchState();
|
|
270
|
+
break;
|
|
271
|
+
case 'Backspace':
|
|
272
|
+
if (searchText) {
|
|
273
|
+
setSearchText(function (prev) {
|
|
274
|
+
return prev.slice(0, -1);
|
|
275
|
+
});
|
|
276
|
+
} else {
|
|
277
|
+
resetSearchState();
|
|
278
|
+
}
|
|
279
|
+
break;
|
|
280
|
+
default:
|
|
281
|
+
// 处理搜索输入
|
|
282
|
+
if (event.key.length === 1) {
|
|
283
|
+
setSearchText(function (prev) {
|
|
284
|
+
return prev + event.key;
|
|
285
|
+
});
|
|
286
|
+
setSelectedIndex(0);
|
|
287
|
+
}
|
|
288
|
+
break;
|
|
289
|
+
}
|
|
290
|
+
return;
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
// 触发变量选择
|
|
294
|
+
if (event.key === '/') {
|
|
295
|
+
var selection = editor.selection;
|
|
296
|
+
if (selection && Range.isCollapsed(selection)) {
|
|
297
|
+
setTarget(selection);
|
|
298
|
+
setSelectedIndex(0);
|
|
299
|
+
setSearchText('');
|
|
300
|
+
updateDropdownPosition();
|
|
301
|
+
}
|
|
302
|
+
return;
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
// 处理回车
|
|
306
|
+
if (event.key === 'Enter') {
|
|
307
|
+
event.preventDefault();
|
|
308
|
+
Transforms.insertText(editor, '\n');
|
|
309
|
+
}
|
|
310
|
+
};
|
|
311
|
+
|
|
312
|
+
// 处理选择
|
|
313
|
+
var handleSelect = useCallback(function (item) {
|
|
314
|
+
if (item.disabled || !item.value) return;
|
|
315
|
+
if (target) {
|
|
316
|
+
// 先重置状态,避免插入变量时触发 handleChange 的下拉框逻辑
|
|
317
|
+
resetSearchState();
|
|
318
|
+
Transforms.select(editor, target);
|
|
319
|
+
insertVariable(editor, item);
|
|
320
|
+
}
|
|
321
|
+
}, [target, editor, resetSearchState]);
|
|
322
|
+
|
|
323
|
+
// 处理编辑器变化
|
|
324
|
+
var handleChange = useCallback(function (val) {
|
|
325
|
+
onChange(val);
|
|
326
|
+
|
|
327
|
+
// 如果下拉框已经打开,不再检查触发条件
|
|
328
|
+
if (target) return;
|
|
329
|
+
var selection = editor.selection;
|
|
330
|
+
if (selection && Range.isCollapsed(selection)) {
|
|
331
|
+
var _Editor$node = Editor.node(editor, selection.focus.path),
|
|
332
|
+
_Editor$node2 = _slicedToArray(_Editor$node, 1),
|
|
333
|
+
node = _Editor$node2[0];
|
|
334
|
+
var text = Text.isText(node) ? node.text : '';
|
|
335
|
+
if (text.endsWith('/')) {
|
|
336
|
+
var beforeSlash = text.slice(0, -1);
|
|
337
|
+
var lastSpaceIndex = beforeSlash.lastIndexOf(' ');
|
|
338
|
+
var lastNewlineIndex = beforeSlash.lastIndexOf('\n');
|
|
339
|
+
var lastBreakIndex = Math.max(lastSpaceIndex, lastNewlineIndex);
|
|
340
|
+
|
|
341
|
+
// 确保 / 前面是空格或换行符(避免在单词中间触发)
|
|
342
|
+
if (lastBreakIndex === beforeSlash.length - 1 || beforeSlash.length === 0) {
|
|
343
|
+
setTarget(selection);
|
|
344
|
+
setSelectedIndex(0);
|
|
345
|
+
setSearchText('');
|
|
346
|
+
updateDropdownPosition();
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
}, [editor, onChange, updateDropdownPosition, target]);
|
|
351
|
+
|
|
352
|
+
// 渲染下拉框内容
|
|
353
|
+
var renderDropdownContent = function renderDropdownContent() {
|
|
354
|
+
if (filteredOptions.length === 0) {
|
|
355
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
356
|
+
className: css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n padding: 16px;\n color: #8c8c8c;\n text-align: center;\n font-size: 14px;\n "])))
|
|
357
|
+
}, searchText ? "\u672A\u627E\u5230\u5339\u914D \"".concat(searchText, "\" \u7684\u53D8\u91CF") : '暂无可用变量');
|
|
358
|
+
}
|
|
359
|
+
var flatIndex = 0;
|
|
360
|
+
var availableOptions = flatOptions.filter(function (opt) {
|
|
361
|
+
return !searchText || opt.label.toLowerCase().includes(searchText.toLowerCase());
|
|
362
|
+
});
|
|
363
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
364
|
+
ref: dropdownContentRef,
|
|
365
|
+
className: css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n padding: 8px 0;\n max-height: 300px;\n overflow-y: auto;\n scroll-behavior: smooth;\n "])))
|
|
366
|
+
}, searchText && /*#__PURE__*/React.createElement("div", {
|
|
367
|
+
className: css(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n padding: 8px 12px;\n color: #8c8c8c;\n font-size: 12px;\n border-bottom: 1px solid #f0f0f0;\n margin-bottom: 4px;\n "])))
|
|
368
|
+
}, "\u641C\u7D22: ", searchText), filteredOptions.map(function (group) {
|
|
369
|
+
return /*#__PURE__*/React.createElement(React.Fragment, {
|
|
370
|
+
key: group.label
|
|
371
|
+
}, group.value && /*#__PURE__*/React.createElement("div", {
|
|
372
|
+
"data-option-index": availableOptions.indexOf(group),
|
|
373
|
+
className: css(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n padding: 10px 12px;\n color: #262626;\n font-weight: 600;\n font-size: 14px;\n cursor: pointer;\n background: ", ";\n border-left: 3px solid ", ";\n transition: all 0.2s ease;\n &:hover {\n background: #f0f9ff;\n }\n "])), selectedIndex === availableOptions.indexOf(group) ? '#e6f7ff' : 'transparent', selectedIndex === availableOptions.indexOf(group) ? '#1890ff' : 'transparent'),
|
|
374
|
+
onClick: function onClick() {
|
|
375
|
+
return handleSelect(group);
|
|
376
|
+
},
|
|
377
|
+
onMouseEnter: function onMouseEnter() {
|
|
378
|
+
return setSelectedIndex(availableOptions.indexOf(group));
|
|
379
|
+
}
|
|
380
|
+
}, group.label), !group.value && /*#__PURE__*/React.createElement("div", {
|
|
381
|
+
className: css(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["\n padding: 8px 12px;\n color: #8c8c8c;\n font-weight: 600;\n font-size: 11px;\n text-transform: uppercase;\n letter-spacing: 0.5px;\n background: #fafafa;\n border-top: 1px solid #f0f0f0;\n border-bottom: 1px solid #f0f0f0;\n "])))
|
|
382
|
+
}, group.label), group.options.map(function (opt) {
|
|
383
|
+
var optIndex = availableOptions.indexOf(opt);
|
|
384
|
+
if (optIndex === -1) return null;
|
|
385
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
386
|
+
key: opt.value,
|
|
387
|
+
"data-option-index": optIndex,
|
|
388
|
+
onClick: function onClick() {
|
|
389
|
+
return handleSelect(opt);
|
|
390
|
+
},
|
|
391
|
+
onMouseEnter: function onMouseEnter() {
|
|
392
|
+
return setSelectedIndex(optIndex);
|
|
393
|
+
},
|
|
394
|
+
className: css(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral(["\n padding: 8px 12px 8px 24px;\n cursor: pointer;\n color: #595959;\n font-size: 13px;\n background: ", ";\n border-left: 3px solid ", ";\n transition: all 0.2s ease;\n &:hover {\n background: #f0f9ff;\n }\n "])), selectedIndex === optIndex ? '#e6f7ff' : 'transparent', selectedIndex === optIndex ? '#1890ff' : 'transparent')
|
|
395
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
396
|
+
className: css(_templateObject8 || (_templateObject8 = _taggedTemplateLiteral(["font-weight: 500;"])))
|
|
397
|
+
}, opt.label), opt.value && /*#__PURE__*/React.createElement("div", {
|
|
398
|
+
className: css(_templateObject9 || (_templateObject9 = _taggedTemplateLiteral(["\n font-size: 11px;\n color: #8c8c8c;\n margin-top: 2px;\n "])))
|
|
399
|
+
}, opt.value));
|
|
400
|
+
}));
|
|
401
|
+
}));
|
|
402
|
+
};
|
|
403
|
+
return /*#__PURE__*/React.createElement(Slate, {
|
|
404
|
+
editor: editor,
|
|
405
|
+
value: value.length ? value : [{
|
|
406
|
+
type: 'paragraph',
|
|
407
|
+
children: [{
|
|
408
|
+
text: ''
|
|
409
|
+
}]
|
|
410
|
+
}],
|
|
411
|
+
onChange: handleChange
|
|
412
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
413
|
+
ref: editorContainerRef,
|
|
414
|
+
className: css(_templateObject10 || (_templateObject10 = _taggedTemplateLiteral(["\n position: relative;\n border: 1px solid #d9d9d9;\n padding: 10px 12px;\n min-height: 42px;\n border-radius: 8px;\n cursor: ", ";\n background: ", ";\n font-size: 14px;\n line-height: 1.6;\n transition: all 0.3s cubic-bezier(0.645, 0.045, 0.355, 1);\n &:hover {\n border-color: ", ";\n }\n &:focus-within {\n border-color: #40a9ff;\n box-shadow: 0 0 0 2px rgba(24, 144, 255, 0.2);\n }\n "])), disabled ? 'not-allowed' : 'text', disabled ? '#f5f5f5' : 'white', disabled ? '#d9d9d9' : '#40a9ff')
|
|
415
|
+
}, /*#__PURE__*/React.createElement(Editable, {
|
|
416
|
+
renderElement: renderElement,
|
|
417
|
+
onKeyDown: handleKeyDown,
|
|
418
|
+
placeholder: "\u8F93\u5165\u5185\u5BB9\uFF0C\u6309 / \u63D2\u5165\u53D8\u91CF",
|
|
419
|
+
readOnly: disabled,
|
|
420
|
+
style: {
|
|
421
|
+
outline: 'none',
|
|
422
|
+
minHeight: '22px',
|
|
423
|
+
wordBreak: 'break-word'
|
|
424
|
+
}
|
|
425
|
+
})), /*#__PURE__*/React.createElement(CustomDropdown, {
|
|
426
|
+
open: !!target,
|
|
427
|
+
position: dropdownPos,
|
|
428
|
+
onClose: resetSearchState
|
|
429
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
430
|
+
className: css(_templateObject11 || (_templateObject11 = _taggedTemplateLiteral(["\n background: white;\n border-radius: 8px;\n box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);\n border: 1px solid #e8e8e8;\n overflow: hidden;\n "])))
|
|
431
|
+
}, renderDropdownContent())));
|
|
432
|
+
};
|
|
433
|
+
export default RichParamEditor;
|