@logicflow/core 2.2.0 → 2.2.2
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/dist/docs/api/logicflow-constructor/index.en.md +106 -0
- package/dist/docs/api/logicflow-constructor/index.zh.md +106 -0
- package/dist/docs/api/logicflow-constructor/use.en.md +61 -0
- package/dist/docs/api/logicflow-constructor/use.zh.md +61 -0
- package/dist/docs/api/logicflow-instance/canvas.en.md +197 -0
- package/dist/docs/api/logicflow-instance/canvas.zh.md +199 -0
- package/dist/docs/api/logicflow-instance/edge.en.md +273 -0
- package/dist/docs/api/logicflow-instance/edge.zh.md +273 -0
- package/dist/docs/api/logicflow-instance/edit-config.en.md +59 -0
- package/dist/docs/api/logicflow-instance/edit-config.zh.md +59 -0
- package/dist/docs/api/logicflow-instance/element.en.md +375 -0
- package/dist/docs/api/logicflow-instance/element.zh.md +379 -0
- package/dist/docs/api/logicflow-instance/event.en.md +326 -0
- package/dist/docs/api/logicflow-instance/event.zh.md +406 -0
- package/dist/docs/api/logicflow-instance/history.en.md +38 -0
- package/dist/docs/api/logicflow-instance/history.zh.md +38 -0
- package/dist/docs/api/logicflow-instance/index.en.md +41 -0
- package/dist/docs/api/logicflow-instance/index.zh.md +41 -0
- package/dist/docs/api/logicflow-instance/node.en.md +308 -0
- package/dist/docs/api/logicflow-instance/node.zh.md +308 -0
- package/dist/docs/api/logicflow-instance/register.en.md +76 -0
- package/dist/docs/api/logicflow-instance/register.zh.md +76 -0
- package/dist/docs/api/logicflow-instance/render-and-data.en.md +179 -0
- package/dist/docs/api/logicflow-instance/render-and-data.zh.md +181 -0
- package/dist/docs/api/logicflow-instance/text.en.md +60 -0
- package/dist/docs/api/logicflow-instance/text.zh.md +60 -0
- package/dist/docs/api/logicflow-instance/theme.en.md +179 -0
- package/dist/docs/api/logicflow-instance/theme.zh.md +179 -0
- package/dist/docs/api/runtime-model/edgeModel.en.md +29 -0
- package/dist/docs/api/runtime-model/edgeModel.zh.md +325 -0
- package/dist/docs/api/runtime-model/graphModel.en.md +275 -0
- package/dist/docs/api/runtime-model/graphModel.zh.md +1153 -0
- package/dist/docs/api/runtime-model/nodeModel.en.md +37 -0
- package/dist/docs/api/runtime-model/nodeModel.zh.md +644 -0
- package/dist/docs/api/type/MainTypes.en.md +598 -0
- package/dist/docs/api/type/MainTypes.zh.md +867 -0
- package/dist/docs/api/type/Theme.en.md +187 -0
- package/dist/docs/api/type/Theme.zh.md +187 -0
- package/dist/docs/api/type/canvas-types.en.md +25 -0
- package/dist/docs/api/type/canvas-types.zh.md +25 -0
- package/dist/docs/api/type/index.en.md +96 -0
- package/dist/docs/api/type/index.zh.md +99 -0
- package/dist/docs/api/type/node-types.en.md +21 -0
- package/dist/docs/api/type/node-types.zh.md +21 -0
- package/dist/docs/api/type/plugin-types.en.md +24 -0
- package/dist/docs/api/type/plugin-types.zh.md +24 -0
- package/dist/docs/index.md +11 -0
- package/dist/docs/tutorial/about.en.md +38 -0
- package/dist/docs/tutorial/about.zh.md +65 -0
- package/dist/docs/tutorial/advanced/dnd.en.md +62 -0
- package/dist/docs/tutorial/advanced/dnd.zh.md +52 -0
- package/dist/docs/tutorial/advanced/edge.en.md +64 -0
- package/dist/docs/tutorial/advanced/edge.zh.md +66 -0
- package/dist/docs/tutorial/advanced/keyboard.en.md +70 -0
- package/dist/docs/tutorial/advanced/keyboard.zh.md +67 -0
- package/dist/docs/tutorial/advanced/node.en.md +338 -0
- package/dist/docs/tutorial/advanced/node.zh.md +338 -0
- package/dist/docs/tutorial/advanced/react.en.md +106 -0
- package/dist/docs/tutorial/advanced/react.zh.md +114 -0
- package/dist/docs/tutorial/advanced/silent-mode.en.md +75 -0
- package/dist/docs/tutorial/advanced/silent-mode.zh.md +71 -0
- package/dist/docs/tutorial/advanced/snapline.en.md +54 -0
- package/dist/docs/tutorial/advanced/vue.en.md +249 -0
- package/dist/docs/tutorial/advanced/vue.zh.md +248 -0
- package/dist/docs/tutorial/ai.en.md +64 -0
- package/dist/docs/tutorial/ai.zh.md +64 -0
- package/dist/docs/tutorial/basic/background.en.md +50 -0
- package/dist/docs/tutorial/basic/canvas.en.md +164 -0
- package/dist/docs/tutorial/basic/canvas.zh.md +183 -0
- package/dist/docs/tutorial/basic/class.en.md +106 -0
- package/dist/docs/tutorial/basic/class.zh.md +103 -0
- package/dist/docs/tutorial/basic/edge.en.md +151 -0
- package/dist/docs/tutorial/basic/edge.zh.md +152 -0
- package/dist/docs/tutorial/basic/event.en.md +70 -0
- package/dist/docs/tutorial/basic/event.zh.md +66 -0
- package/dist/docs/tutorial/basic/grid.en.md +77 -0
- package/dist/docs/tutorial/basic/node.en.md +358 -0
- package/dist/docs/tutorial/basic/node.zh.md +318 -0
- package/dist/docs/tutorial/basic/theme.en.md +154 -0
- package/dist/docs/tutorial/basic/theme.zh.md +157 -0
- package/dist/docs/tutorial/extension/adapter.en.md +446 -0
- package/dist/docs/tutorial/extension/adapter.zh.md +429 -0
- package/dist/docs/tutorial/extension/bpmn-element.en.md +1427 -0
- package/dist/docs/tutorial/extension/bpmn-element.zh.md +1472 -0
- package/dist/docs/tutorial/extension/control.en.md +117 -0
- package/dist/docs/tutorial/extension/control.zh.md +118 -0
- package/dist/docs/tutorial/extension/curved-edge.en.md +46 -0
- package/dist/docs/tutorial/extension/curved-edge.zh.md +46 -0
- package/dist/docs/tutorial/extension/custom.en.md +142 -0
- package/dist/docs/tutorial/extension/custom.zh.md +138 -0
- package/dist/docs/tutorial/extension/dnd-panel.en.md +109 -0
- package/dist/docs/tutorial/extension/dnd-panel.zh.md +109 -0
- package/dist/docs/tutorial/extension/dynamic-group.en.md +606 -0
- package/dist/docs/tutorial/extension/dynamic-group.zh.md +606 -0
- package/dist/docs/tutorial/extension/group.en.md +217 -0
- package/dist/docs/tutorial/extension/group.zh.md +209 -0
- package/dist/docs/tutorial/extension/highlight.en.md +50 -0
- package/dist/docs/tutorial/extension/highlight.zh.md +50 -0
- package/dist/docs/tutorial/extension/insert-node-in-polyline.en.md +52 -0
- package/dist/docs/tutorial/extension/insert-node-in-polyline.zh.md +47 -0
- package/dist/docs/tutorial/extension/intro.en.md +72 -0
- package/dist/docs/tutorial/extension/intro.zh.md +95 -0
- package/dist/docs/tutorial/extension/label.en.md +136 -0
- package/dist/docs/tutorial/extension/label.zh.md +135 -0
- package/dist/docs/tutorial/extension/layout.en.md +156 -0
- package/dist/docs/tutorial/extension/layout.zh.md +156 -0
- package/dist/docs/tutorial/extension/menu.en.md +319 -0
- package/dist/docs/tutorial/extension/menu.zh.md +377 -0
- package/dist/docs/tutorial/extension/minimap.en.md +164 -0
- package/dist/docs/tutorial/extension/minimap.zh.md +180 -0
- package/dist/docs/tutorial/extension/node-resize.en.md +199 -0
- package/dist/docs/tutorial/extension/node-resize.zh.md +221 -0
- package/dist/docs/tutorial/extension/pool.en.md +227 -0
- package/dist/docs/tutorial/extension/pool.zh.md +227 -0
- package/dist/docs/tutorial/extension/proximity-connect.en.md +104 -0
- package/dist/docs/tutorial/extension/proximity-connect.zh.md +107 -0
- package/dist/docs/tutorial/extension/selection.en.md +166 -0
- package/dist/docs/tutorial/extension/selection.zh.md +150 -0
- package/dist/docs/tutorial/extension/snapshot.en.md +276 -0
- package/dist/docs/tutorial/extension/snapshot.zh.md +276 -0
- package/dist/docs/tutorial/get-started.en.md +501 -0
- package/dist/docs/tutorial/get-started.zh.md +139 -0
- package/dist/docs/tutorial/update.en.md +213 -0
- package/dist/docs/tutorial/update.zh.md +212 -0
- package/dist/index.css +3 -2
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.map +1 -1
- package/es/LogicFlow.d.ts +9 -0
- package/es/LogicFlow.js +0 -1
- package/es/constant/index.d.ts +1 -1
- package/es/constant/index.js +1 -1
- package/es/constant/theme.d.ts +136 -0
- package/es/constant/theme.js +680 -0
- package/es/index.css +3 -2
- package/es/model/GraphModel.d.ts +10 -2
- package/es/model/GraphModel.js +48 -14
- package/es/model/TransformModel.js +9 -9
- package/es/model/edge/BaseEdgeModel.js +7 -2
- package/es/model/edge/PolylineEdgeModel.d.ts +7 -0
- package/es/model/edge/PolylineEdgeModel.js +136 -7
- package/es/model/node/BaseNodeModel.d.ts +12 -1
- package/es/model/node/BaseNodeModel.js +9 -2
- package/es/model/node/HtmlNodeModel.d.ts +12 -0
- package/es/model/node/HtmlNodeModel.js +19 -0
- package/es/model/node/PolygonNodeModel.js +3 -3
- package/es/options.d.ts +4 -2
- package/es/style/index.css +3 -2
- package/es/style/index.less +3 -2
- package/es/style/raw.d.ts +1 -1
- package/es/style/raw.js +1 -1
- package/es/tool/MultipleSelectTool.js +10 -5
- package/es/util/drag.js +0 -1
- package/es/util/edge.d.ts +40 -1
- package/es/util/edge.js +43 -9
- package/es/util/geometry.d.ts +8 -0
- package/es/util/geometry.js +79 -0
- package/es/util/theme.d.ts +2 -65
- package/es/util/theme.js +4 -281
- package/es/view/Anchor.d.ts +1 -0
- package/es/view/Anchor.js +24 -21
- package/es/view/Control.d.ts +5 -0
- package/es/view/Control.js +44 -57
- package/es/view/edge/BaseEdge.js +9 -0
- package/es/view/edge/PolylineEdge.js +13 -2
- package/es/view/node/BaseNode.d.ts +1 -0
- package/es/view/node/BaseNode.js +23 -11
- package/es/view/node/HtmlNode.js +2 -4
- package/es/view/overlay/CanvasOverlay.js +5 -2
- package/es/view/overlay/Grid.d.ts +12 -1
- package/es/view/overlay/Grid.js +85 -23
- package/es/view/overlay/OutlineOverlay.d.ts +1 -0
- package/es/view/overlay/OutlineOverlay.js +18 -17
- package/es/view/overlay/gridConfig.d.ts +46 -0
- package/es/view/overlay/gridConfig.js +99 -0
- package/es/view/shape/Polygon.d.ts +0 -7
- package/es/view/shape/Polygon.js +12 -43
- package/lib/LogicFlow.d.ts +9 -0
- package/lib/LogicFlow.js +0 -1
- package/lib/constant/index.d.ts +1 -1
- package/lib/constant/index.js +16 -2
- package/lib/constant/theme.d.ts +136 -0
- package/lib/constant/theme.js +683 -0
- package/lib/index.css +3 -2
- package/lib/model/GraphModel.d.ts +10 -2
- package/lib/model/GraphModel.js +49 -15
- package/lib/model/TransformModel.js +9 -9
- package/lib/model/edge/BaseEdgeModel.js +7 -2
- package/lib/model/edge/PolylineEdgeModel.d.ts +7 -0
- package/lib/model/edge/PolylineEdgeModel.js +136 -7
- package/lib/model/node/BaseNodeModel.d.ts +12 -1
- package/lib/model/node/BaseNodeModel.js +9 -2
- package/lib/model/node/HtmlNodeModel.d.ts +12 -0
- package/lib/model/node/HtmlNodeModel.js +19 -0
- package/lib/model/node/PolygonNodeModel.js +3 -3
- package/lib/options.d.ts +4 -2
- package/lib/style/index.css +3 -2
- package/lib/style/index.less +3 -2
- package/lib/style/raw.d.ts +1 -1
- package/lib/style/raw.js +1 -1
- package/lib/tool/MultipleSelectTool.js +10 -5
- package/lib/util/drag.js +0 -1
- package/lib/util/edge.d.ts +40 -1
- package/lib/util/edge.js +43 -9
- package/lib/util/geometry.d.ts +8 -0
- package/lib/util/geometry.js +81 -1
- package/lib/util/theme.d.ts +2 -65
- package/lib/util/theme.js +15 -292
- package/lib/view/Anchor.d.ts +1 -0
- package/lib/view/Anchor.js +24 -21
- package/lib/view/Control.d.ts +5 -0
- package/lib/view/Control.js +44 -57
- package/lib/view/edge/BaseEdge.js +9 -0
- package/lib/view/edge/PolylineEdge.js +13 -2
- package/lib/view/node/BaseNode.d.ts +1 -0
- package/lib/view/node/BaseNode.js +22 -10
- package/lib/view/node/HtmlNode.js +1 -3
- package/lib/view/overlay/CanvasOverlay.js +5 -2
- package/lib/view/overlay/Grid.d.ts +12 -1
- package/lib/view/overlay/Grid.js +83 -21
- package/lib/view/overlay/OutlineOverlay.d.ts +1 -0
- package/lib/view/overlay/OutlineOverlay.js +18 -17
- package/lib/view/overlay/gridConfig.d.ts +46 -0
- package/lib/view/overlay/gridConfig.js +104 -0
- package/lib/view/shape/Polygon.d.ts +0 -7
- package/lib/view/shape/Polygon.js +13 -45
- package/package.json +9 -2
- package/scripts/postinstall-ai-prompt.js +67 -0
- package/.turbo/turbo-build$colon$dev.log +0 -10
- package/.turbo/turbo-build.log +0 -33
- package/CHANGELOG.md +0 -1849
- package/__tests__/algorithm/egde.test.ts +0 -131
- package/__tests__/algorithm/index.test.ts +0 -74
- package/__tests__/algorithm/outline.test.ts +0 -43
- package/__tests__/bugs/1545-spec.test.ts +0 -42
- package/__tests__/event/event.test.ts +0 -22
- package/__tests__/history/history.test.ts +0 -28
- package/__tests__/logicflow.test.ts +0 -575
- package/__tests__/model/graphmodel.test.ts +0 -87
- package/__tests__/util/compatible.test.ts +0 -48
- package/__tests__/util/edge.test.ts +0 -224
- package/__tests__/util/geometry.test.ts +0 -14
- package/__tests__/util/graph.test.ts +0 -16
- package/__tests__/util/matrix.test.ts +0 -41
- package/__tests__/util/node.test.ts +0 -68
- package/__tests__/util/sampling.test.ts +0 -12
- package/__tests__/util/vector.test.ts +0 -50
- package/__tests__/util/zIndex.test.ts +0 -10
- package/src/LogicFlow.tsx +0 -2008
- package/src/algorithm/edge.ts +0 -67
- package/src/algorithm/index.ts +0 -70
- package/src/algorithm/outline.ts +0 -77
- package/src/algorithm/rotate.ts +0 -55
- package/src/common/drag.ts +0 -219
- package/src/common/history.ts +0 -108
- package/src/common/index.ts +0 -6
- package/src/common/keyboard.ts +0 -108
- package/src/common/matrix.ts +0 -122
- package/src/common/vector.ts +0 -93
- package/src/constant/index.ts +0 -179
- package/src/event/event.md +0 -66
- package/src/event/eventArgs.ts +0 -643
- package/src/event/eventEmitter.ts +0 -156
- package/src/history/index.ts +0 -119
- package/src/index.less +0 -1
- package/src/index.ts +0 -26
- package/src/keyboard/index.ts +0 -112
- package/src/keyboard/shortcut.ts +0 -200
- package/src/model/BaseModel.ts +0 -250
- package/src/model/EditConfigModel.ts +0 -334
- package/src/model/GraphModel.ts +0 -1788
- package/src/model/NestedTransformModel.ts +0 -121
- package/src/model/SnaplineModel.ts +0 -256
- package/src/model/TransformModel.ts +0 -258
- package/src/model/edge/BaseEdgeModel.ts +0 -777
- package/src/model/edge/BezierEdgeModel.ts +0 -197
- package/src/model/edge/LineEdgeModel.ts +0 -36
- package/src/model/edge/PolylineEdgeModel.ts +0 -672
- package/src/model/edge/index.ts +0 -4
- package/src/model/index.ts +0 -9
- package/src/model/node/BaseNodeModel.ts +0 -949
- package/src/model/node/CircleNodeModel.ts +0 -91
- package/src/model/node/DiamondNodeModel.ts +0 -132
- package/src/model/node/EllipseNodeModel.ts +0 -98
- package/src/model/node/HtmlNodeModel.ts +0 -50
- package/src/model/node/PolygonNodeModel.ts +0 -150
- package/src/model/node/RectNodeModel.ts +0 -69
- package/src/model/node/TextNodeModel.ts +0 -54
- package/src/model/node/index.ts +0 -8
- package/src/options.ts +0 -145
- package/src/style/index.less +0 -261
- package/src/style/raw.ts +0 -220
- package/src/tool/MultipleSelectTool.tsx +0 -132
- package/src/tool/TextEditTool.tsx +0 -193
- package/src/tool/index.ts +0 -101
- package/src/typings.d.ts +0 -5
- package/src/util/animation.ts +0 -29
- package/src/util/browser.ts +0 -4
- package/src/util/compatible.ts +0 -15
- package/src/util/drag.ts +0 -220
- package/src/util/edge.ts +0 -1060
- package/src/util/geometry.ts +0 -55
- package/src/util/graph.ts +0 -46
- package/src/util/index.ts +0 -17
- package/src/util/matrix.ts +0 -129
- package/src/util/mobx.ts +0 -23
- package/src/util/node.ts +0 -543
- package/src/util/raf.ts +0 -28
- package/src/util/resize.ts +0 -606
- package/src/util/sampling.ts +0 -85
- package/src/util/theme.ts +0 -375
- package/src/util/uuid.ts +0 -26
- package/src/util/vector.ts +0 -93
- package/src/util/zIndex.ts +0 -6
- package/src/view/Anchor.tsx +0 -445
- package/src/view/Control.tsx +0 -512
- package/src/view/Graph.tsx +0 -141
- package/src/view/Rotate.tsx +0 -113
- package/src/view/behavior/dnd.ts +0 -162
- package/src/view/behavior/index.ts +0 -2
- package/src/view/behavior/snapline.ts +0 -16
- package/src/view/edge/AdjustPoint.tsx +0 -425
- package/src/view/edge/Arrow.tsx +0 -54
- package/src/view/edge/BaseEdge.tsx +0 -650
- package/src/view/edge/BezierEdge.tsx +0 -101
- package/src/view/edge/LineEdge.tsx +0 -81
- package/src/view/edge/PolylineEdge.tsx +0 -299
- package/src/view/edge/index.ts +0 -6
- package/src/view/index.ts +0 -8
- package/src/view/node/BaseNode.tsx +0 -571
- package/src/view/node/CircleNode.tsx +0 -21
- package/src/view/node/DiamondNode.tsx +0 -24
- package/src/view/node/EllipseNode.tsx +0 -22
- package/src/view/node/HtmlNode.tsx +0 -95
- package/src/view/node/PolygonNode.tsx +0 -28
- package/src/view/node/RectNode.tsx +0 -30
- package/src/view/node/TextNode.tsx +0 -39
- package/src/view/node/index.ts +0 -8
- package/src/view/overlay/BackgroundOverlay.tsx +0 -34
- package/src/view/overlay/BezierAdjustOverlay.tsx +0 -150
- package/src/view/overlay/CanvasOverlay.tsx +0 -288
- package/src/view/overlay/Grid.tsx +0 -162
- package/src/view/overlay/ModificationOverlay.tsx +0 -31
- package/src/view/overlay/OutlineOverlay.tsx +0 -170
- package/src/view/overlay/SnaplineOverlay.tsx +0 -44
- package/src/view/overlay/ToolOverlay.tsx +0 -65
- package/src/view/overlay/getTransformHoc.tsx +0 -50
- package/src/view/overlay/index.ts +0 -8
- package/src/view/shape/Circle.tsx +0 -41
- package/src/view/shape/Ellipse.tsx +0 -42
- package/src/view/shape/Line.tsx +0 -39
- package/src/view/shape/Path.tsx +0 -22
- package/src/view/shape/Polygon.tsx +0 -91
- package/src/view/shape/Polyline.tsx +0 -31
- package/src/view/shape/Rect.tsx +0 -44
- package/src/view/shape/Text.tsx +0 -169
- package/src/view/shape/index.ts +0 -8
- package/src/view/text/BaseText.tsx +0 -134
- package/src/view/text/LineText.tsx +0 -168
- package/src/view/text/index.ts +0 -2
- package/stats.html +0 -4842
- package/tsconfig.json +0 -18
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
---
|
|
2
|
+
nav: Guide
|
|
3
|
+
group:
|
|
4
|
+
title: Basics
|
|
5
|
+
order: 1
|
|
6
|
+
title: Edge
|
|
7
|
+
order: 2
|
|
8
|
+
toc: content
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
Like nodes, LogicFlow has some basic edges built in.
|
|
12
|
+
|
|
13
|
+
1. line
|
|
14
|
+
2. polyline
|
|
15
|
+
3. bezier
|
|
16
|
+
|
|
17
|
+
The effect is as follows:
|
|
18
|
+
|
|
19
|
+
<code id="edge-shapes" src="../../../src/tutorial/basic/edge/shapes"></code>
|
|
20
|
+
|
|
21
|
+
## Selecting built-in edges inherited by custom edges
|
|
22
|
+
|
|
23
|
+
```tsx | pure
|
|
24
|
+
// line
|
|
25
|
+
import { LineEdge, LineEdgeModel } from '@logicflow/core'
|
|
26
|
+
// polyline
|
|
27
|
+
import { PolylineEdge, PolylineEdgeModel } from '@logicflow/core'
|
|
28
|
+
// bezier
|
|
29
|
+
import { BezierEdge, BezierEdgeModel } from '@logicflow/core'
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Inheritance-based customization of edges
|
|
33
|
+
|
|
34
|
+
Like nodes, LogicFlow edges support inheritance-based customization. Again, you only need to inherit
|
|
35
|
+
from both `view` and `model`.
|
|
36
|
+
However, unlike nodes, in most cases it is not recommended to customize `view` when customizing
|
|
37
|
+
edges due to the editing complexity of edges.
|
|
38
|
+
You just need to customize the style class in [edgeModel](../../api/runtime-model/edgeModel.en.md).
|
|
39
|
+
|
|
40
|
+
<code id="edge-custom" src="../../../src/tutorial/basic/edge/custom"></code>
|
|
41
|
+
|
|
42
|
+
:::info{title=提示}
|
|
43
|
+
Custom edges also need to be registered using `register`.
|
|
44
|
+
:::
|
|
45
|
+
## Modify edge style
|
|
46
|
+
Similar to node style attributes, edge styles can also be customized via [theme configuration](../../api/logicflow-instance/theme.en.md). The edge style is then redefined by this.
|
|
47
|
+
|
|
48
|
+
- If you need to define styles according to the state of the edge, you can put the passed parameters into `properties`, and in `getEdgeStyle`, you can judge the parameters in `properties` and return different styles according to different parameters.
|
|
49
|
+
- To achieve the hover effect, you can listen for the `edge:mouseenter` and `edge:mouseleave` events, modify the parameters in `properties`, and then call the `edge.updateStyle()` method to update the edge style.
|
|
50
|
+
- It is not recommended to use the `setStyle` method to set the style of the edges. This method is generally used to skip the rendering of custom edges when developing plugins.
|
|
51
|
+
|
|
52
|
+
<code id="edge-style" src="../../../src/tutorial/basic/edge/style"></code>
|
|
53
|
+
## Customize side text position
|
|
54
|
+
|
|
55
|
+
By default, the position of the text on the edge is the position when the user double-clicks on the
|
|
56
|
+
edge. If the text is added to the edge via the API, the text position will be as follows.
|
|
57
|
+
|
|
58
|
+
- line: the middle of the start and end points
|
|
59
|
+
- polyline: middle of the longest line segment
|
|
60
|
+
- bezier: middle of start, end, and adjustment points.
|
|
61
|
+
|
|
62
|
+
LogicFlow allows developers to customize the text position, e.g. the text position will always be
|
|
63
|
+
next to the start of the edge. The way to define this is to set the property `customTextPosition` to
|
|
64
|
+
true, then override the `getTextPosition` method, the coordinates sent back by this method are the
|
|
65
|
+
coordinates of the text.
|
|
66
|
+
|
|
67
|
+
<code id="edge-text" src="../../../src/tutorial/basic/edge/textPosition"></code>
|
|
68
|
+
|
|
69
|
+
## Customize the type of edges between nodes
|
|
70
|
+
|
|
71
|
+
By default, edges generated by manually connecting nodes from anchors are of the type specified by
|
|
72
|
+
the initialization `edgeType`, which can also be specified by `lf.setDefaultEdgeType(edgeType)`. But
|
|
73
|
+
when the edge types needed to connect different nodes to each other are different, the only way to
|
|
74
|
+
customize the types of the edges between nodes is to customize the edge types between nodes.
|
|
75
|
+
|
|
76
|
+
```tsx | pure
|
|
77
|
+
const lf = new LogicFlow({
|
|
78
|
+
...,
|
|
79
|
+
// Set default margins manually
|
|
80
|
+
edgeType: 'bezier',
|
|
81
|
+
// currentEdge information when moving existing edges, otherwise null
|
|
82
|
+
edgeGenerator: (sourceNode, targetNode, currentEdge) => {
|
|
83
|
+
// custom-edge
|
|
84
|
+
if (sourceNode.type === 'rect') return 'custom-edge'
|
|
85
|
+
}
|
|
86
|
+
})
|
|
87
|
+
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
## Customize arrows
|
|
91
|
+
|
|
92
|
+
After version `1.1.27`, LogicFlow supports individual customization of the arrows at each end of a
|
|
93
|
+
line. As with previous customization methods, full customization is supported by customizing basic
|
|
94
|
+
data such as size by theme and by overriding the corresponding methods.
|
|
95
|
+
|
|
96
|
+
### Theme settings
|
|
97
|
+
|
|
98
|
+
```tsx | pure
|
|
99
|
+
lf.setTheme({
|
|
100
|
+
arrow: {
|
|
101
|
+
offset: 4, // Arrow vertical line length
|
|
102
|
+
verticalLength: 2, // Arrow bottom line length
|
|
103
|
+
},
|
|
104
|
+
});
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
### Customizing arrow shapes
|
|
108
|
+
|
|
109
|
+
When customizing the line view, you can override the `getEndArrow` and `getStartArrow` methods to
|
|
110
|
+
customize the shapes of the ends of the line, which can be any of the `svg` shapes returned by the
|
|
111
|
+
two methods.
|
|
112
|
+
|
|
113
|
+
Here's an example of controlling the appearance of a line by using the arrowType in the line's
|
|
114
|
+
properties.
|
|
115
|
+
|
|
116
|
+
<code id="custom-arrow" src="../../../src/tutorial/basic/edge/arrow"></code>
|
|
117
|
+
|
|
118
|
+
### Customize the adjustment point style
|
|
119
|
+
|
|
120
|
+
When initializing a LogicFlow instance, you can enable the function of adjusting the start and end
|
|
121
|
+
points of edges with the parameter `adjustEdgeStartAndEnd`.
|
|
122
|
+
|
|
123
|
+
When customizing the line view, you can override the `getAdjustPointShape` method to achieve the
|
|
124
|
+
custom adjust point shape.
|
|
125
|
+
|
|
126
|
+
```tsx | pure
|
|
127
|
+
// lf.js
|
|
128
|
+
const lf = new LogicFlow({
|
|
129
|
+
adjustEdgeStartAndEnd: true,
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
// edge.js
|
|
133
|
+
class CustomEdge extends LineEdge {
|
|
134
|
+
getAdjustPointShape(x, y, edgeModel) {
|
|
135
|
+
return h("g", {}, [
|
|
136
|
+
h("image", {
|
|
137
|
+
x: x - 9,
|
|
138
|
+
y: y - 9,
|
|
139
|
+
width: 18,
|
|
140
|
+
height: 18,
|
|
141
|
+
cursor: "move",
|
|
142
|
+
href: "data:image/svg+xml;base64,PCFET0NUWVBFIHN2ZyBQVUJMSUMgIi0vL1czQy8vRFREIFNWRyAxLjEvL0VOIiAiaHR0cDovL3d3dy53My5vcmcvR3JhcGhpY3MvU1ZHLzEuMS9EVEQvc3ZnMTEuZHRkIj48c3ZnIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIHdpZHRoPSIyMnB4IiBoZWlnaHQ9IjIycHgiIHZlcnNpb249IjEuMSI+PGNpcmNsZSBjeD0iMTEiIGN5PSIxMSIgcj0iNyIgc3Ryb2tlPSIjZmZmIiBmaWxsPSIjMjliNmYyIi8+PGNpcmNsZSBjeD0iMTEiIGN5PSIxMSIgcj0iMyIgc3Ryb2tlPSIjZmZmIiBmaWxsPSJ0cmFuc3BhcmVudCIvPjwvc3ZnPg==",
|
|
143
|
+
}),
|
|
144
|
+
]);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
<a href="https://codesandbox.io/embed/logicflow026-edgeanimation-forked-fdg3v0?fontsize=14&hidenavigation=1&theme=dark" target="_blank">
|
|
150
|
+
Go to CodeSandbox for examples</a>
|
|
151
|
+
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
---
|
|
2
|
+
nav: 指南
|
|
3
|
+
group:
|
|
4
|
+
title: 基础
|
|
5
|
+
order: 1
|
|
6
|
+
title: 边
|
|
7
|
+
order: 2
|
|
8
|
+
toc: content
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
本页从内置边出发,介绍如何定义符合业务语义的自定义边。更复杂的连线交互和路径控制,会在 [进阶-边](../advanced/edge.zh.md) 中继续展开。
|
|
12
|
+
|
|
13
|
+
::::info{title=阅读提示}
|
|
14
|
+
- 适合已经读过 [快速上手](../get-started.zh.md) 和 [实例与图数据](class.zh.md) 的读者
|
|
15
|
+
- 前置知识:知道节点、边、`graphData` 和 `render` 的基本用法
|
|
16
|
+
- 本页不展开更复杂的边交互和框架节点方案,这些内容请继续阅读 [进阶-边](../advanced/edge.zh.md)
|
|
17
|
+
- 相关 API:[`edgeModel`](../../api/runtime-model/edgeModel.zh.md)、[`主题`](../../api/logicflow-instance/theme.zh.md)、[`事件`](../../api/logicflow-instance/event.zh.md)
|
|
18
|
+
::::
|
|
19
|
+
|
|
20
|
+
和节点一样,LogicFlow 也内置一些基础的边。LogicFlow 的内置边包括:
|
|
21
|
+
|
|
22
|
+
1. 直线 - line
|
|
23
|
+
2. 直角折线 - polyline
|
|
24
|
+
3. 贝塞尔曲线 - bezier
|
|
25
|
+
|
|
26
|
+
效果如下:
|
|
27
|
+
|
|
28
|
+
<code id="edge-shapes" src="../../../src/tutorial/basic/edge/shapes"></code>
|
|
29
|
+
|
|
30
|
+
## 选择自定义边继承的内置边
|
|
31
|
+
|
|
32
|
+
```tsx | pure
|
|
33
|
+
// 直线
|
|
34
|
+
import { LineEdge, LineEdgeModel } from '@logicflow/core'
|
|
35
|
+
// 折线
|
|
36
|
+
import { PolylineEdge, PolylineEdgeModel } from '@logicflow/core'
|
|
37
|
+
// 贝塞尔曲线
|
|
38
|
+
import { BezierEdge, BezierEdgeModel } from '@logicflow/core'
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## 基于继承的自定义边
|
|
42
|
+
|
|
43
|
+
和节点一样,LogicFlow 的边也支持基于继承的自定义机制。同样也只需同时继承`view`和`model`。
|
|
44
|
+
但是和节点不一样的是,由于边的编辑复杂度问题,绝大多数情况下,自定义边时不推荐自定义`view`。
|
|
45
|
+
只需要在自定义 [edgeModel](../../api/runtime-model/edgeModel.zh.md) 中定义样式相关逻辑即可。
|
|
46
|
+
|
|
47
|
+
<code id="edge-custom" src="../../../src/tutorial/basic/edge/custom"></code>
|
|
48
|
+
|
|
49
|
+
:::info{title=提示}
|
|
50
|
+
自定义边同样需要使用`register`注册哦。
|
|
51
|
+
:::
|
|
52
|
+
## 修改边样式
|
|
53
|
+
和节点的样式属性一样边样式也支持通过 [主题配置](../../api/logicflow-instance/theme.zh.md) 自定义边的样式则是它重新定义。
|
|
54
|
+
|
|
55
|
+
- 如果需要按照边的状态定义样式,可以把传递的参数放入`properties`中,在`getEdgeStyle`中判断`properties`中的参数,根据不同的参数返回不同的样式。
|
|
56
|
+
- 如果需要实现hover的效果,可以监听`edge:mouseenter`和`edge:mouseleave`事件,修改完`properties`中的参数,然后调用`edge.updateStyle()`方法更新边的样式。
|
|
57
|
+
- 不建议使用`setStyle`方法设置边的样式,这个方法一般用于插件开发时跳过自定义边的渲染。
|
|
58
|
+
|
|
59
|
+
<code id="edge-style" src="../../../src/tutorial/basic/edge/style"></code>
|
|
60
|
+
## 自定义边文本位置
|
|
61
|
+
|
|
62
|
+
默认情况下,边上文本的位置是用户双击点击边时的位置。如果是通过 API 的方式给边添加的文本,文本位置按照如下规则。
|
|
63
|
+
|
|
64
|
+
- line: 起点和终点中间
|
|
65
|
+
- polyline: 最长线段中间
|
|
66
|
+
- bezier: 起点、终点、调整点中间
|
|
67
|
+
|
|
68
|
+
LogicFlow 支持开发者自定义文本位置,例如文本位置永远在边起点旁边。定义方式为将属性`customTextPosition`
|
|
69
|
+
设置为 true, 然后重写`getTextPosition`方法, 此方法返回的坐标就是文本的坐标。
|
|
70
|
+
|
|
71
|
+
<code id="edge-text" src="../../../src/tutorial/basic/edge/textPosition"></code>
|
|
72
|
+
|
|
73
|
+
## 自定义节点之间边的类型
|
|
74
|
+
|
|
75
|
+
默认情况下,通过从锚点手动连接节点生成的边为初始化`edgeType`
|
|
76
|
+
指定的类型,也可以通过`lf.setDefaultEdgeType(edgeType)`来指定。但是当需要不同的节点之间连接的边类型不一样时,就只有自定义节点之间边的类型了。
|
|
77
|
+
|
|
78
|
+
```tsx | pure
|
|
79
|
+
const lf = new LogicFlow({
|
|
80
|
+
...,
|
|
81
|
+
// 手动设置默认边
|
|
82
|
+
edgeType: 'bezier',
|
|
83
|
+
// 移动已有边时会有 currentEdge 信息, 否则为空
|
|
84
|
+
edgeGenerator: (sourceNode, targetNode, currentEdge) => {
|
|
85
|
+
// 起始节点类型 rect 时使用 自定义的边 custom-edge
|
|
86
|
+
if (sourceNode.type === 'rect') return 'custom-edge'
|
|
87
|
+
}
|
|
88
|
+
})
|
|
89
|
+
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
## 自定义箭头
|
|
93
|
+
|
|
94
|
+
在`1.1.27`版本后,LogicFlow 支持单独自定义连线两端的箭头。和之前的自定义方式一样,支持通过主题自定义大小等基本数据和通过重写对应的方法实现完全的自定义。
|
|
95
|
+
|
|
96
|
+
### 主题设置
|
|
97
|
+
|
|
98
|
+
```tsx | pure
|
|
99
|
+
lf.setTheme({
|
|
100
|
+
arrow: {
|
|
101
|
+
offset: 4, // 箭头垂线长度
|
|
102
|
+
verticalLength: 2, // 箭头底线长度
|
|
103
|
+
},
|
|
104
|
+
});
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
### 自定义箭头形状
|
|
108
|
+
|
|
109
|
+
在自定义连线 view 的时候,可以重写`getEndArrow`和`getStartArrow`
|
|
110
|
+
方法来实现自定义连线两端的图形,这两个方法可以返回的任意`svg`图形。
|
|
111
|
+
|
|
112
|
+
这里以通过连线属性中的 arrowType 来控制连线不同的外观为例。
|
|
113
|
+
|
|
114
|
+
<code id="custom-arrow" src="../../../src/tutorial/basic/edge/arrow"></code>
|
|
115
|
+
|
|
116
|
+
### 自定义调整点样式
|
|
117
|
+
|
|
118
|
+
在初始化 LogicFlow 实例的时候,可以通过参数`adjustEdgeStartAndEnd`来开启调整边的起始点和结束点的功能。
|
|
119
|
+
|
|
120
|
+
在自定义连线 view 的时候,可以重写`getAdjustPointShape`方法来实现自定义调整点的样式。
|
|
121
|
+
|
|
122
|
+
```tsx | pure
|
|
123
|
+
// lf.js
|
|
124
|
+
const lf = new LogicFlow({
|
|
125
|
+
adjustEdgeStartAndEnd: true,
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
// edge.js
|
|
129
|
+
class CustomEdge extends LineEdge {
|
|
130
|
+
getAdjustPointShape(x, y, edgeModel) {
|
|
131
|
+
return h("g", {}, [
|
|
132
|
+
h("image", {
|
|
133
|
+
x: x - 9,
|
|
134
|
+
y: y - 9,
|
|
135
|
+
width: 18,
|
|
136
|
+
height: 18,
|
|
137
|
+
cursor: "move",
|
|
138
|
+
href: "data:image/svg+xml;base64,PCFET0NUWVBFIHN2ZyBQVUJMSUMgIi0vL1czQy8vRFREIFNWRyAxLjEvL0VOIiAiaHR0cDovL3d3dy53My5vcmcvR3JhcGhpY3MvU1ZHLzEuMS9EVEQvc3ZnMTEuZHRkIj48c3ZnIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIHdpZHRoPSIyMnB4IiBoZWlnaHQ9IjIycHgiIHZlcnNpb249IjEuMSI+PGNpcmNsZSBjeD0iMTEiIGN5PSIxMSIgcj0iNyIgc3Ryb2tlPSIjZmZmIiBmaWxsPSIjMjliNmYyIi8+PGNpcmNsZSBjeD0iMTEiIGN5PSIxMSIgcj0iMyIgc3Ryb2tlPSIjZmZmIiBmaWxsPSJ0cmFuc3BhcmVudCIvPjwvc3ZnPg==",
|
|
139
|
+
}),
|
|
140
|
+
]);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
<a href="https://codesandbox.io/embed/logicflow026-edgeanimation-forked-fdg3v0?fontsize=14&hidenavigation=1&theme=dark" target="_blank"> 去 CodeSandbox 查看示例</a>
|
|
146
|
+
|
|
147
|
+
## 下一步阅读
|
|
148
|
+
|
|
149
|
+
1. [进阶-边](../advanced/edge.zh.md):继续看动画、数据扩展和更复杂的边能力
|
|
150
|
+
2. [事件 API](../../api/logicflow-instance/event.zh.md):查看边事件和交互事件
|
|
151
|
+
3. [edgeModel API](../../api/runtime-model/edgeModel.zh.md):精确查阅可用属性和方法
|
|
152
|
+
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
---
|
|
2
|
+
nav: Guide
|
|
3
|
+
group:
|
|
4
|
+
title: Basics
|
|
5
|
+
order: 1
|
|
6
|
+
title: Event
|
|
7
|
+
order: 6
|
|
8
|
+
toc: content
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
Events are triggered when we interact with the canvas using the mouse or other means. By listening
|
|
12
|
+
to these events, we can get the data generated when they are triggered, and then use this data to
|
|
13
|
+
realize the required functions. See [event API](../../api/logicflow-instance/event.en.md) for details on
|
|
14
|
+
listening to events.
|
|
15
|
+
|
|
16
|
+
## Listening to events
|
|
17
|
+
|
|
18
|
+
The `on` method is provided on the `lf` instance to support listening to events.
|
|
19
|
+
|
|
20
|
+
```tsx | pure
|
|
21
|
+
lf.on("node:dnd-add", (data) => {});
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
LogicFlow supports splitting event names with commas.
|
|
25
|
+
|
|
26
|
+
```tsx | pure
|
|
27
|
+
lf.on("node:click,edge:click", (data) => {});
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## Customizing events
|
|
31
|
+
|
|
32
|
+
In addition to the listening events supported on lf, events can be listened to and triggered using
|
|
33
|
+
the [eventCenter](../../api/runtime-model/graphModel.en.md#eventcenter) object. `eventCenter` is a property on
|
|
34
|
+
a `graphModel`. So when customizing a node, we can use `eventCenter` to trigger custom events.
|
|
35
|
+
|
|
36
|
+
```tsx | pure
|
|
37
|
+
class ButtonNode extends HtmlNode {
|
|
38
|
+
setHtml(rootEl) {
|
|
39
|
+
const { properties } = this.props.model
|
|
40
|
+
|
|
41
|
+
const el = document.createElement('div')
|
|
42
|
+
el.className = 'uml-wrapper'
|
|
43
|
+
const html = `
|
|
44
|
+
<div>
|
|
45
|
+
<div class="uml-head">Head</div>
|
|
46
|
+
<div class="uml-body">
|
|
47
|
+
<div><button onclick="setData()">+</button> ${properties.name}</div>
|
|
48
|
+
<div>${properties.body}</div>
|
|
49
|
+
</div>
|
|
50
|
+
<div class="uml-footer">
|
|
51
|
+
<div>setHead(Head $head)</div>
|
|
52
|
+
<div>setBody(Body $body)</div>
|
|
53
|
+
</div>
|
|
54
|
+
</div>
|
|
55
|
+
`
|
|
56
|
+
el.innerHTML = html
|
|
57
|
+
rootEl.innerHTML = ''
|
|
58
|
+
rootEl.appendChild(el)
|
|
59
|
+
window.setData = () => {
|
|
60
|
+
const { graphModel, model } = this.props
|
|
61
|
+
graphModel.eventCenter.emit('custom:button-click', model)
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## example
|
|
68
|
+
|
|
69
|
+
<a href="https://codesandbox.io/embed/logicflow-step7-dpmgb?fontsize=14&hidenavigation=1&theme=dark&view=preview" target="_blank">
|
|
70
|
+
Go to CodeSandbox for examples</a>
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
---
|
|
2
|
+
nav: 指南
|
|
3
|
+
group:
|
|
4
|
+
title: 基础
|
|
5
|
+
order: 1
|
|
6
|
+
title: 事件
|
|
7
|
+
order: 6
|
|
8
|
+
toc: content
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
当我们使用鼠标或其它方式与画布交互时,会触发的对应的事件。通过监听这些事件,可以获取其在触发时所产生的数据,根据这些数据来实现需要的功能。详细可监听事件见[事件 API](../../api/logicflow-instance/event.zh.md)。
|
|
12
|
+
|
|
13
|
+
## 监听事件
|
|
14
|
+
|
|
15
|
+
`lf`实例上提供`on`方法支持监听事件。
|
|
16
|
+
|
|
17
|
+
```tsx | pure
|
|
18
|
+
lf.on("node:dnd-add", (data) => {});
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
LogicFlow 支持用逗号分割事件名。
|
|
22
|
+
|
|
23
|
+
```tsx | pure
|
|
24
|
+
lf.on('node:click,edge:click', (data) => {})
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## 自定义事件
|
|
28
|
+
|
|
29
|
+
除了 lf 上支持的监听事件外,还可以使用 [eventCenter](../../api/runtime-model/graphModel.zh.md#eventcenter)
|
|
30
|
+
对象来监听和触发事件。`eventCenter`是一个`graphModel`
|
|
31
|
+
上的一个属性。所以在自定义节点的时候,我们可以使用`eventCenter`触发自定义事件。
|
|
32
|
+
|
|
33
|
+
```tsx | pure
|
|
34
|
+
class ButtonNode extends HtmlNode {
|
|
35
|
+
setHtml(rootEl) {
|
|
36
|
+
const { properties } = this.props.model
|
|
37
|
+
|
|
38
|
+
const el = document.createElement('div')
|
|
39
|
+
el.className = 'uml-wrapper'
|
|
40
|
+
const html = `
|
|
41
|
+
<div>
|
|
42
|
+
<div class="uml-head">Head</div>
|
|
43
|
+
<div class="uml-body">
|
|
44
|
+
<div><button onclick="setData()">+</button> ${properties.name}</div>
|
|
45
|
+
<div>${properties.body}</div>
|
|
46
|
+
</div>
|
|
47
|
+
<div class="uml-footer">
|
|
48
|
+
<div>setHead(Head $head)</div>
|
|
49
|
+
<div>setBody(Body $body)</div>
|
|
50
|
+
</div>
|
|
51
|
+
</div>
|
|
52
|
+
`
|
|
53
|
+
el.innerHTML = html
|
|
54
|
+
rootEl.innerHTML = ''
|
|
55
|
+
rootEl.appendChild(el)
|
|
56
|
+
window.setData = () => {
|
|
57
|
+
const { graphModel, model } = this.props
|
|
58
|
+
graphModel.eventCenter.emit('custom:button-click', model)
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## 示例
|
|
65
|
+
|
|
66
|
+
<a href="https://codesandbox.io/embed/logicflow-step7-dpmgb?fontsize=14&hidenavigation=1&theme=dark&view=preview" target="_blank"> 去 CodeSandbox 查看示例</a>
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
---
|
|
2
|
+
nav: Guide
|
|
3
|
+
group:
|
|
4
|
+
title: Basics
|
|
5
|
+
order: 1
|
|
6
|
+
title: Grid
|
|
7
|
+
order: 4
|
|
8
|
+
toc: content
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
A mesh is the smallest unit for rendering/moving nodes. The primary purpose of a mesh is to ensure
|
|
12
|
+
that the position of each node center point is on the mesh when moving nodes. This is more conducive
|
|
13
|
+
to direct node alignment. Generally speaking, the larger the interval of the grid, the better the
|
|
14
|
+
nodes are aligned when editing the flowchart; the smaller the interval of the grid, the smoother the
|
|
15
|
+
feeling of dragging nodes.
|
|
16
|
+
|
|
17
|
+
Grid is off by default, and the minimum unit of rendering/movement is 1px. If grid is on, the
|
|
18
|
+
default size of grid is 20px, which means that the nodes are aligned to the network with the minimum
|
|
19
|
+
unit of 20 when rendering them, and the minimum distance of 20px each time they are moved when
|
|
20
|
+
moving them.
|
|
21
|
+
|
|
22
|
+
:::warning{title=注意}
|
|
23
|
+
When setting node coordinates, the coordinates are transformed according to the size of the grid.
|
|
24
|
+
For example, if the center point is set at { x: 124, y: 138 }, the actual position of the rendered
|
|
25
|
+
node on the canvas would be { x: 120, y: 140 }. Therefore, when replacing the old flow designer in
|
|
26
|
+
the project with LogicFlow, it is necessary to handle the coordinates of historical data.<br>
|
|
27
|
+
In practical development, if you want nodes to align both to the center and to the sides, the custom
|
|
28
|
+
node's width and height should be multiples of the grid size. This means that the width of all nodes
|
|
29
|
+
is preferably in even multiples such as 20, 40, 80, 120, assuming the grid size is 20.
|
|
30
|
+
:::
|
|
31
|
+
|
|
32
|
+
## Enable Grid
|
|
33
|
+
|
|
34
|
+
When creating the canvas, set grid properties through the configuration grid.
|
|
35
|
+
|
|
36
|
+
To enable the grid and apply default properties:
|
|
37
|
+
|
|
38
|
+
```tsx | pure
|
|
39
|
+
const lf1 = new LogicFlow({
|
|
40
|
+
grid: true,
|
|
41
|
+
})
|
|
42
|
+
|
|
43
|
+
// or
|
|
44
|
+
|
|
45
|
+
const lf2 = new LogicFlow({
|
|
46
|
+
grid: {
|
|
47
|
+
size: 20,
|
|
48
|
+
visible: true,
|
|
49
|
+
type: 'dot',
|
|
50
|
+
config: {
|
|
51
|
+
color: '#ababab',
|
|
52
|
+
thickness: 1,
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
})
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## Set Grid Properties
|
|
59
|
+
|
|
60
|
+
Supports setting grid properties such as size, type, grid line color, and width.
|
|
61
|
+
|
|
62
|
+
```tsx | pure
|
|
63
|
+
export type GridOptions = {
|
|
64
|
+
size?: number // Set grid size.
|
|
65
|
+
visible?: boolean, // Set visibility; if set to false, grid lines will not be displayed, but the size grid effect will still be retained.
|
|
66
|
+
type?: 'dot' | 'mesh', // Set grid type; currently supports dot and mesh types.
|
|
67
|
+
config?: {
|
|
68
|
+
color: string, // Set grid color.
|
|
69
|
+
thickness?: number, // Set grid line width.
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## example
|
|
75
|
+
|
|
76
|
+
<a href="https://codesandbox.io/embed/logicflow-base8-hxtqr?fontsize=14&hidenavigation=1&theme=dark&view=preview" target="_blank">
|
|
77
|
+
Go to CodeSandbox for examples</a>
|