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,308 @@
|
|
|
1
|
+
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
2
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
3
|
+
import { DagreLayout } from '@antv/layout';
|
|
4
|
+
import { NODE_WIDTH, RANK_SEP, NODE_SEP, ConditionTypeEnum } from "../constant";
|
|
5
|
+
// import dagre from '@dagrejs/dagre';
|
|
6
|
+
// import ELK from 'elkjs/lib/elk.bundled.js';
|
|
7
|
+
// import cytoscape from 'cytoscape';
|
|
8
|
+
// import cyDagre from 'cytoscape-dagre';
|
|
9
|
+
// import cyElk from 'cytoscape-elk';
|
|
10
|
+
// import cyKlay from 'cytoscape-klay';
|
|
11
|
+
|
|
12
|
+
// cytoscape.use( cyDagre );
|
|
13
|
+
// cytoscape.use( cyElk );
|
|
14
|
+
// cytoscape.use( cyKlay );
|
|
15
|
+
|
|
16
|
+
var rankdir = 'LR';
|
|
17
|
+
var align = undefined;
|
|
18
|
+
var nodeSize = NODE_WIDTH;
|
|
19
|
+
var ranksep = RANK_SEP;
|
|
20
|
+
var nodesep = NODE_SEP;
|
|
21
|
+
var controlPoints = false;
|
|
22
|
+
var begin = [40, 40];
|
|
23
|
+
export var forceLayout = function forceLayout(flowGraph) {
|
|
24
|
+
var cfg = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
25
|
+
antvDagreLayout(flowGraph, cfg);
|
|
26
|
+
|
|
27
|
+
// dagreLayout(flowGraph, cfg);
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* 使用AntV的图布局包实现布局
|
|
32
|
+
* @param flowGraph 图实例
|
|
33
|
+
* @param cfg 配置
|
|
34
|
+
*/
|
|
35
|
+
function antvDagreLayout(flowGraph) {
|
|
36
|
+
var cfg = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
37
|
+
var dagreLayout = new DagreLayout({
|
|
38
|
+
begin: begin,
|
|
39
|
+
type: 'dagre',
|
|
40
|
+
rankdir: rankdir,
|
|
41
|
+
align: align,
|
|
42
|
+
nodeSize: nodeSize,
|
|
43
|
+
ranksep: ranksep,
|
|
44
|
+
nodesep: nodesep,
|
|
45
|
+
controlPoints: controlPoints
|
|
46
|
+
});
|
|
47
|
+
dagreLayout.updateCfg(_objectSpread({}, cfg));
|
|
48
|
+
var _dagreLayout$layout = dagreLayout.layout({
|
|
49
|
+
// @ts-ignore
|
|
50
|
+
nodes: flowGraph.getNodes().map(function (node) {
|
|
51
|
+
node.setZIndex(1);
|
|
52
|
+
return node.toJSON();
|
|
53
|
+
}),
|
|
54
|
+
// @ts-ignore
|
|
55
|
+
edges: flowGraph.getEdges().map(function (edge) {
|
|
56
|
+
edge.setZIndex(0);
|
|
57
|
+
return edge.toJSON();
|
|
58
|
+
})
|
|
59
|
+
}),
|
|
60
|
+
newNodes = _dagreLayout$layout.nodes;
|
|
61
|
+
flowGraph.freeze();
|
|
62
|
+
newNodes === null || newNodes === void 0 || newNodes.forEach(function (node) {
|
|
63
|
+
var cell = flowGraph.getCellById(node.id);
|
|
64
|
+
if (cell) {
|
|
65
|
+
cell.position(node.x, node.y);
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
fineTuneLayer(flowGraph);
|
|
69
|
+
|
|
70
|
+
// fineTuneCatchNodes(flowGraph);
|
|
71
|
+
|
|
72
|
+
flowGraph.unfreeze();
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* 解决Dagre布局部分节点层次过低问题
|
|
77
|
+
* @param flowGraph 图实例
|
|
78
|
+
*/
|
|
79
|
+
function fineTuneLayer(flowGraph) {
|
|
80
|
+
var queue = flowGraph.getRootNodes();
|
|
81
|
+
var layer = 0;
|
|
82
|
+
// const visited: KeyValue<boolean> = {};
|
|
83
|
+
var _loop = function _loop() {
|
|
84
|
+
var cells = [];
|
|
85
|
+
queue.forEach(function (next) {
|
|
86
|
+
// if (next === null || visited[next.id]) {
|
|
87
|
+
// return;
|
|
88
|
+
// }
|
|
89
|
+
// visited[next.id] = true;
|
|
90
|
+
var _next$position = next.position(),
|
|
91
|
+
y = _next$position.y;
|
|
92
|
+
next.position(begin[0] + layer * (ranksep + nodeSize + 40), y);
|
|
93
|
+
var neighbors = flowGraph.getNeighbors(next, {
|
|
94
|
+
outgoing: true
|
|
95
|
+
});
|
|
96
|
+
cells = cells.concat(neighbors);
|
|
97
|
+
});
|
|
98
|
+
layer++;
|
|
99
|
+
queue = cells;
|
|
100
|
+
};
|
|
101
|
+
while (queue.length) {
|
|
102
|
+
_loop();
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* 调整捕获异常节点/CATCH的布局
|
|
108
|
+
* @param flowGraph 图实例
|
|
109
|
+
*/
|
|
110
|
+
function fineTuneCatchNodes(flowGraph) {
|
|
111
|
+
var queue = flowGraph.getRootNodes();
|
|
112
|
+
var _loop2 = function _loop2() {
|
|
113
|
+
var cells = [];
|
|
114
|
+
queue.forEach(function (next) {
|
|
115
|
+
var _next$getData = next.getData(),
|
|
116
|
+
model = _next$getData.model;
|
|
117
|
+
var currentModel = model.proxy || model;
|
|
118
|
+
if (currentModel.type === ConditionTypeEnum.CATCH) {
|
|
119
|
+
if (next.shape === ConditionTypeEnum.CATCH) {
|
|
120
|
+
// CATCH start
|
|
121
|
+
beforeCatchStart(flowGraph, next);
|
|
122
|
+
} else {
|
|
123
|
+
// CATCH end
|
|
124
|
+
afterCatchEnd(flowGraph, next);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
var neighbors = flowGraph.getNeighbors(next, {
|
|
128
|
+
outgoing: true
|
|
129
|
+
});
|
|
130
|
+
cells = cells.concat(neighbors);
|
|
131
|
+
});
|
|
132
|
+
queue = cells;
|
|
133
|
+
};
|
|
134
|
+
while (queue.length) {
|
|
135
|
+
_loop2();
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
function beforeCatchStart(flowGraph, catchStart) {
|
|
139
|
+
var catchRootNode = flowGraph.getNeighbors(catchStart, {
|
|
140
|
+
outgoing: true
|
|
141
|
+
})[0];
|
|
142
|
+
var deltaY = catchStart.position().y - catchRootNode.position().y;
|
|
143
|
+
if (!deltaY) return;
|
|
144
|
+
var queue = [catchStart];
|
|
145
|
+
var _loop3 = function _loop3() {
|
|
146
|
+
var cells = [];
|
|
147
|
+
queue.forEach(function (next) {
|
|
148
|
+
var _next$position2 = next.position(),
|
|
149
|
+
x = _next$position2.x,
|
|
150
|
+
y = _next$position2.y;
|
|
151
|
+
next.position(x, y - deltaY);
|
|
152
|
+
var neighbors = flowGraph.getNeighbors(next, {
|
|
153
|
+
incoming: true
|
|
154
|
+
});
|
|
155
|
+
cells = cells.concat(neighbors);
|
|
156
|
+
});
|
|
157
|
+
queue = cells;
|
|
158
|
+
};
|
|
159
|
+
while (queue.length) {
|
|
160
|
+
_loop3();
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
function afterCatchEnd(flowGraph, catchEnd) {
|
|
164
|
+
var catchRootNode = flowGraph.getNeighbors(catchEnd, {
|
|
165
|
+
incoming: true
|
|
166
|
+
})[0];
|
|
167
|
+
var deltaY = catchEnd.position().y - catchRootNode.position().y;
|
|
168
|
+
if (!deltaY) return;
|
|
169
|
+
var queue = [catchEnd];
|
|
170
|
+
var _loop4 = function _loop4() {
|
|
171
|
+
var cells = [];
|
|
172
|
+
queue.forEach(function (next) {
|
|
173
|
+
var _next$position3 = next.position(),
|
|
174
|
+
x = _next$position3.x,
|
|
175
|
+
y = _next$position3.y;
|
|
176
|
+
next.position(x, y - deltaY);
|
|
177
|
+
var neighbors = flowGraph.getNeighbors(next, {
|
|
178
|
+
outgoing: true
|
|
179
|
+
});
|
|
180
|
+
cells = cells.concat(neighbors);
|
|
181
|
+
});
|
|
182
|
+
queue = cells;
|
|
183
|
+
};
|
|
184
|
+
while (queue.length) {
|
|
185
|
+
_loop4();
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
function getNodeOrderFrom(flowGraph) {
|
|
189
|
+
var nodeOrder = [];
|
|
190
|
+
var rootNodes = flowGraph.getRootNodes() || [];
|
|
191
|
+
if (rootNodes) {
|
|
192
|
+
var queue = _toConsumableArray(rootNodes);
|
|
193
|
+
var visited = {};
|
|
194
|
+
var _loop5 = function _loop5() {
|
|
195
|
+
var next = queue.pop();
|
|
196
|
+
if (next == null || visited[next.id]) {
|
|
197
|
+
return 1; // continue
|
|
198
|
+
}
|
|
199
|
+
visited[next.id] = true;
|
|
200
|
+
nodeOrder.push(next.id);
|
|
201
|
+
var neighbors = flowGraph.getNeighbors(next, {
|
|
202
|
+
outgoing: true
|
|
203
|
+
});
|
|
204
|
+
neighbors.sort(function (a, b) {
|
|
205
|
+
var _a$position = a.position(),
|
|
206
|
+
aY = _a$position.y;
|
|
207
|
+
var _b$position = b.position(),
|
|
208
|
+
bY = _b$position.y;
|
|
209
|
+
return aY - bY;
|
|
210
|
+
});
|
|
211
|
+
var lastIndex = queue.length;
|
|
212
|
+
neighbors.forEach(function (neighbor) {
|
|
213
|
+
queue.splice(lastIndex, 0, neighbor);
|
|
214
|
+
});
|
|
215
|
+
};
|
|
216
|
+
while (queue.length > 0) {
|
|
217
|
+
if (_loop5()) continue;
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
return nodeOrder;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* 使用Dagre原始包实现布局
|
|
225
|
+
* @param flowGraph 图实例
|
|
226
|
+
* @param cfg 配置
|
|
227
|
+
*/
|
|
228
|
+
// function dagreLayout(flowGraph: Graph, cfg: any = {}): void {
|
|
229
|
+
// const g = new dagre.graphlib.Graph();
|
|
230
|
+
// g.setGraph({ rankdir, nodesep: 50, ranksep: 50 });
|
|
231
|
+
// g.setDefaultEdgeLabel(() => ({}));
|
|
232
|
+
|
|
233
|
+
// flowGraph.getNodes().forEach((node) => {
|
|
234
|
+
// node.setZIndex(1);
|
|
235
|
+
// g.setNode(node.id, { width: nodeSize, height: nodeSize });
|
|
236
|
+
// })
|
|
237
|
+
|
|
238
|
+
// flowGraph.getEdges().forEach((edge) => {
|
|
239
|
+
// edge.setZIndex(0);
|
|
240
|
+
// const source = edge.getSourceNode() as Node;
|
|
241
|
+
// const target = edge.getTargetNode() as Node;
|
|
242
|
+
// g.setEdge(source?.id, target?.id);
|
|
243
|
+
// })
|
|
244
|
+
|
|
245
|
+
// dagre.layout(g);
|
|
246
|
+
|
|
247
|
+
// flowGraph.freeze();
|
|
248
|
+
|
|
249
|
+
// g.nodes().forEach((id) => {
|
|
250
|
+
// const node = flowGraph.getCellById(id) as Node;
|
|
251
|
+
// if (node) {
|
|
252
|
+
// const pos = g.node(id);
|
|
253
|
+
// node.position(pos.x, pos.y);
|
|
254
|
+
// }
|
|
255
|
+
// })
|
|
256
|
+
|
|
257
|
+
// flowGraph.unfreeze();
|
|
258
|
+
// }
|
|
259
|
+
|
|
260
|
+
/**
|
|
261
|
+
* 使用ELK实现布局
|
|
262
|
+
* @param flowGraph 图实例
|
|
263
|
+
* @param cfg 配置
|
|
264
|
+
*/
|
|
265
|
+
// function elkLayout(flowGraph: Graph, cfg: any = {}) {
|
|
266
|
+
// const elk = new ELK();
|
|
267
|
+
// const elkOptions: Record<string, any> = {
|
|
268
|
+
// 'elk.algorithm': 'layered',
|
|
269
|
+
// 'elk.layered.spacing.nodeNodeBetweenLayers': 80,
|
|
270
|
+
// 'elk.spacing.nodeNode': 20,
|
|
271
|
+
// 'elk.direction': 'RIGHT',
|
|
272
|
+
// };
|
|
273
|
+
// const nodes = flowGraph
|
|
274
|
+
// .getCells()
|
|
275
|
+
// .filter((cell) => cell.isNode())
|
|
276
|
+
// .map((cell) => cell.toJSON()) as any[];
|
|
277
|
+
// const edges = flowGraph
|
|
278
|
+
// .getCells()
|
|
279
|
+
// .filter((cell) => cell.isEdge())
|
|
280
|
+
// .map((cell) => cell.toJSON()) as any[];
|
|
281
|
+
// const elkGraph = {
|
|
282
|
+
// id: 'root',
|
|
283
|
+
// layoutOptions: elkOptions,
|
|
284
|
+
// children: nodes.map((node) => ({
|
|
285
|
+
// ...node,
|
|
286
|
+
// width: nodeSize,
|
|
287
|
+
// height: nodeSize,
|
|
288
|
+
// })),
|
|
289
|
+
// edges: edges.map((edge) => ({
|
|
290
|
+
// ...edge,
|
|
291
|
+
// source: edge.source.cell,
|
|
292
|
+
// target: edge.target.cell,
|
|
293
|
+
// })),
|
|
294
|
+
// };
|
|
295
|
+
// elk
|
|
296
|
+
// .layout(elkGraph as any)
|
|
297
|
+
// .then((layoutedGraph: any) => {
|
|
298
|
+
// flowGraph.freeze();
|
|
299
|
+
// layoutedGraph.children.forEach((node: any) => {
|
|
300
|
+
// const current: Node | undefined = flowGraph.getCellById(node?.id) as Node | undefined;
|
|
301
|
+
// if (current) {
|
|
302
|
+
// current.position(node.x, node.y);
|
|
303
|
+
// }
|
|
304
|
+
// });
|
|
305
|
+
// flowGraph.unfreeze();
|
|
306
|
+
// })
|
|
307
|
+
// .catch(console.error);
|
|
308
|
+
// }
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { Point, Registry } from '@antv/x6';
|
|
2
|
+
import anchor from "./anchor";
|
|
3
|
+
import { NODE_TYPE_INTERMEDIATE_END } from "../constant";
|
|
4
|
+
export default function router(vertices, args, view) {
|
|
5
|
+
var normalRouter = Registry.Router.presets.normal;
|
|
6
|
+
var points = vertices.map(function (p) {
|
|
7
|
+
return Point.create(p);
|
|
8
|
+
});
|
|
9
|
+
if (!(view.sourceView && view.sourceView.cell) || !(view.targetView && view.targetView.cell)) {
|
|
10
|
+
// @ts-ignore
|
|
11
|
+
return normalRouter.call(this, points, args, view);
|
|
12
|
+
}
|
|
13
|
+
var sourceCorner = anchor(view.sourceView);
|
|
14
|
+
var targetCorner = anchor(view.targetView);
|
|
15
|
+
if (
|
|
16
|
+
// 第四象限
|
|
17
|
+
sourceCorner.x < targetCorner.x && sourceCorner.y < targetCorner.y ||
|
|
18
|
+
// 第一象限
|
|
19
|
+
sourceCorner.x < targetCorner.x && sourceCorner.y > targetCorner.y) {
|
|
20
|
+
if (view.targetView.cell.shape === NODE_TYPE_INTERMEDIATE_END) {
|
|
21
|
+
points.push(Point.create(targetCorner.x, sourceCorner.y));
|
|
22
|
+
} else {
|
|
23
|
+
points.push(Point.create(sourceCorner.x, targetCorner.y));
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
// const pointX = targetCorner.x - (NODE_WIDTH + RANK_SEP + 40) / 2;
|
|
27
|
+
// if (
|
|
28
|
+
// // 第四象限
|
|
29
|
+
// (sourceCorner.x < targetCorner.x && sourceCorner.y < targetCorner.y) ||
|
|
30
|
+
// // 第一象限
|
|
31
|
+
// (sourceCorner.x < targetCorner.x && sourceCorner.y > targetCorner.y)
|
|
32
|
+
// ) {
|
|
33
|
+
// points.push(
|
|
34
|
+
// Point.create(pointX, sourceCorner.y),
|
|
35
|
+
// Point.create(pointX, targetCorner.y),
|
|
36
|
+
// );
|
|
37
|
+
// }
|
|
38
|
+
// @ts-ignore
|
|
39
|
+
return normalRouter.call(this, points, args, view);
|
|
40
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Graph } from '@antv/x6';
|
|
2
|
+
interface Shortcut {
|
|
3
|
+
keys: string | string[];
|
|
4
|
+
handler: (flowGraph: Graph) => void;
|
|
5
|
+
}
|
|
6
|
+
export declare const shortcuts: {
|
|
7
|
+
[key: string]: Shortcut;
|
|
8
|
+
};
|
|
9
|
+
declare const registerShortcuts: (flowGraph: Graph) => void;
|
|
10
|
+
export default registerShortcuts;
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
import { safeGet } from "../utils";
|
|
2
|
+
import { Modal } from 'antd';
|
|
3
|
+
import { MIN_ZOOM, MAX_ZOOM, ZOOM_STEP } from "../constant";
|
|
4
|
+
import { getSelectedNodes } from "../utils/flowChartUtils";
|
|
5
|
+
import { history } from "../hooks/useHistory";
|
|
6
|
+
import { useModel } from "../hooks/useModel";
|
|
7
|
+
export var shortcuts = {
|
|
8
|
+
save: {
|
|
9
|
+
keys: ['meta + s', 'ctrl + s'],
|
|
10
|
+
handler: function handler() {
|
|
11
|
+
// console.log('save');
|
|
12
|
+
console.log(useModel().toJSON());
|
|
13
|
+
return false;
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
undo: {
|
|
17
|
+
keys: ['meta + z', 'ctrl + z'],
|
|
18
|
+
handler: function handler() {
|
|
19
|
+
history.undo();
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
redo: {
|
|
24
|
+
keys: ['meta + shift + z', 'ctrl + shift + z'],
|
|
25
|
+
handler: function handler() {
|
|
26
|
+
history.redo();
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
zoomIn: {
|
|
31
|
+
keys: ['meta + shift + +', 'ctrl + shift + +'],
|
|
32
|
+
handler: function handler(flowGraph) {
|
|
33
|
+
var nextZoom = (flowGraph.zoom() + ZOOM_STEP).toPrecision(2);
|
|
34
|
+
flowGraph.zoomTo(Number(nextZoom), {
|
|
35
|
+
maxScale: MAX_ZOOM
|
|
36
|
+
});
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
zoomOut: {
|
|
41
|
+
keys: ['meta + shift + -', 'ctrl + shift + -'],
|
|
42
|
+
handler: function handler(flowGraph) {
|
|
43
|
+
var nextZoom = (flowGraph.zoom() - ZOOM_STEP).toPrecision(2);
|
|
44
|
+
flowGraph.zoomTo(Number(nextZoom), {
|
|
45
|
+
minScale: MIN_ZOOM
|
|
46
|
+
});
|
|
47
|
+
return false;
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
// copy: {
|
|
51
|
+
// keys: ['meta + c', 'ctrl + c'],
|
|
52
|
+
// handler(flowGraph: Graph) {
|
|
53
|
+
// const cells = flowGraph.getSelectedCells();
|
|
54
|
+
// if (cells.length > 0) {
|
|
55
|
+
// flowGraph.copy(cells);
|
|
56
|
+
// message.success('复制成功');
|
|
57
|
+
// }
|
|
58
|
+
// return false;
|
|
59
|
+
// },
|
|
60
|
+
// },
|
|
61
|
+
// paste: {
|
|
62
|
+
// keys: ['meta + v', 'ctrl + v'],
|
|
63
|
+
// handler(flowGraph: Graph) {
|
|
64
|
+
// if (!flowGraph.isClipboardEmpty()) {
|
|
65
|
+
// const cells = flowGraph.paste({ offset: 32 });
|
|
66
|
+
// flowGraph.cleanSelection();
|
|
67
|
+
// flowGraph.select(cells);
|
|
68
|
+
// }
|
|
69
|
+
// return false;
|
|
70
|
+
// },
|
|
71
|
+
// },
|
|
72
|
+
delete: {
|
|
73
|
+
keys: ['backspace', 'del'],
|
|
74
|
+
handler: function handler(flowGraph) {
|
|
75
|
+
var toDelCells = flowGraph.getSelectedCells().filter(function (cell) {
|
|
76
|
+
return cell.isNode();
|
|
77
|
+
});
|
|
78
|
+
if (toDelCells.length) {
|
|
79
|
+
Modal.confirm({
|
|
80
|
+
title: "\u786E\u8BA4\u8981\u5220\u9664\u9009\u4E2D\u7684\u8282\u70B9\uFF1F",
|
|
81
|
+
content: '点击确认按钮进行删除,点击取消按钮返回',
|
|
82
|
+
onOk: function onOk() {
|
|
83
|
+
toDelCells.forEach(function (node) {
|
|
84
|
+
var _model$remove;
|
|
85
|
+
var _ref = node.getData() || {},
|
|
86
|
+
model = _ref.model;
|
|
87
|
+
model === null || model === void 0 || (_model$remove = model.remove) === null || _model$remove === void 0 || _model$remove.call(model);
|
|
88
|
+
});
|
|
89
|
+
history.push();
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
return false;
|
|
94
|
+
}
|
|
95
|
+
},
|
|
96
|
+
selectAll: {
|
|
97
|
+
keys: ['meta + a', 'ctrl + a'],
|
|
98
|
+
handler: function handler(flowGraph) {
|
|
99
|
+
flowGraph.select(flowGraph.getCells());
|
|
100
|
+
return false;
|
|
101
|
+
}
|
|
102
|
+
},
|
|
103
|
+
bold: {
|
|
104
|
+
keys: ['meta + b', 'ctrl + b'],
|
|
105
|
+
handler: function handler(flowGraph) {
|
|
106
|
+
var cells = flowGraph.getSelectedCells();
|
|
107
|
+
if (cells.length > 0) {
|
|
108
|
+
var isAlreadyBold = safeGet(cells, '0.attrs.label.fontWeight', 'normal') === 'bold';
|
|
109
|
+
cells.forEach(function (cell) {
|
|
110
|
+
cell.setAttrs({
|
|
111
|
+
label: {
|
|
112
|
+
fontWeight: isAlreadyBold ? 'normal' : 'bold'
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
});
|
|
116
|
+
flowGraph.trigger('toolBar:forceUpdate');
|
|
117
|
+
}
|
|
118
|
+
return false;
|
|
119
|
+
}
|
|
120
|
+
},
|
|
121
|
+
italic: {
|
|
122
|
+
keys: ['meta + i', 'ctrl + i'],
|
|
123
|
+
handler: function handler(flowGraph) {
|
|
124
|
+
var cells = flowGraph.getSelectedCells();
|
|
125
|
+
if (cells.length > 0) {
|
|
126
|
+
var isAlreadyItalic = safeGet(cells, '0.attrs.label.fontStyle', 'normal') === 'italic';
|
|
127
|
+
cells.forEach(function (cell) {
|
|
128
|
+
cell.setAttrs({
|
|
129
|
+
label: {
|
|
130
|
+
fontStyle: isAlreadyItalic ? 'normal' : 'italic'
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
});
|
|
134
|
+
flowGraph.trigger('toolBar:forceUpdate');
|
|
135
|
+
}
|
|
136
|
+
return false;
|
|
137
|
+
}
|
|
138
|
+
},
|
|
139
|
+
underline: {
|
|
140
|
+
keys: ['meta + u', 'ctrl + u'],
|
|
141
|
+
handler: function handler(flowGraph) {
|
|
142
|
+
var cells = flowGraph.getSelectedCells();
|
|
143
|
+
if (cells.length > 0) {
|
|
144
|
+
var isAlreadyUnderline = safeGet(cells, '0.attrs.label.textDecoration', 'none') === 'underline';
|
|
145
|
+
cells.forEach(function (cell) {
|
|
146
|
+
cell.setAttrs({
|
|
147
|
+
label: {
|
|
148
|
+
textDecoration: isAlreadyUnderline ? 'none' : 'underline'
|
|
149
|
+
}
|
|
150
|
+
});
|
|
151
|
+
});
|
|
152
|
+
flowGraph.trigger('toolBar:forceUpdate');
|
|
153
|
+
}
|
|
154
|
+
return false;
|
|
155
|
+
}
|
|
156
|
+
},
|
|
157
|
+
bringToTop: {
|
|
158
|
+
keys: ['meta + ]', 'ctrl + ]'],
|
|
159
|
+
handler: function handler(flowGraph) {
|
|
160
|
+
getSelectedNodes(flowGraph).forEach(function (node) {
|
|
161
|
+
return node.toFront();
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
},
|
|
165
|
+
bringToBack: {
|
|
166
|
+
keys: ['meta + [', 'ctrl + ['],
|
|
167
|
+
handler: function handler(flowGraph) {
|
|
168
|
+
getSelectedNodes(flowGraph).forEach(function (node) {
|
|
169
|
+
return node.toBack();
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
};
|
|
174
|
+
var registerShortcuts = function registerShortcuts(flowGraph) {
|
|
175
|
+
Object.values(shortcuts).forEach(function (shortcut) {
|
|
176
|
+
var keys = shortcut.keys,
|
|
177
|
+
handler = shortcut.handler;
|
|
178
|
+
flowGraph.bindKey(keys, function () {
|
|
179
|
+
return handler(flowGraph);
|
|
180
|
+
});
|
|
181
|
+
});
|
|
182
|
+
};
|
|
183
|
+
export default registerShortcuts;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import classNames from 'classnames';
|
|
3
|
+
import { NODE_TYPE_INTERMEDIATE_END, NodeTypeEnum, ConditionTypeEnum } from "../../constant";
|
|
4
|
+
import { getIconByType } from "../../cells";
|
|
5
|
+
import styles from "./index.module.less";
|
|
6
|
+
var NodeBadge = function NodeBadge(props) {
|
|
7
|
+
var node = props.node;
|
|
8
|
+
var _node$getData = node.getData(),
|
|
9
|
+
model = _node$getData.model;
|
|
10
|
+
var badge = null;
|
|
11
|
+
if (model) {
|
|
12
|
+
var currentModel = model.proxy || model;
|
|
13
|
+
if (currentModel.type !== node.shape && currentModel.type !== NodeTypeEnum.COMMON && currentModel.type !== NodeTypeEnum.BOOLEAN && currentModel.type !== NodeTypeEnum.VIRTUAL && currentModel.type !== ConditionTypeEnum.CHAIN && NODE_TYPE_INTERMEDIATE_END !== node.shape) {
|
|
14
|
+
badge = /*#__PURE__*/React.createElement("div", {
|
|
15
|
+
className: classNames(styles.liteflowShapeBadgeWrapper)
|
|
16
|
+
}, /*#__PURE__*/React.createElement("img", {
|
|
17
|
+
className: styles.liteflowShapeBadgeSvg,
|
|
18
|
+
src: getIconByType(currentModel.type)
|
|
19
|
+
}));
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
return badge;
|
|
23
|
+
};
|
|
24
|
+
export default NodeBadge;
|