@logicflow/core 2.2.0 → 2.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/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 +6 -1
- 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
package/src/util/theme.ts
DELETED
|
@@ -1,375 +0,0 @@
|
|
|
1
|
-
import { cloneDeep, merge, assign } from 'lodash-es'
|
|
2
|
-
import LogicFlow from '../LogicFlow'
|
|
3
|
-
|
|
4
|
-
export const defaultTheme: LogicFlow.Theme = {
|
|
5
|
-
baseNode: {
|
|
6
|
-
fill: '#fff',
|
|
7
|
-
stroke: '#000',
|
|
8
|
-
strokeWidth: 2,
|
|
9
|
-
},
|
|
10
|
-
|
|
11
|
-
baseEdge: {
|
|
12
|
-
stroke: '#000',
|
|
13
|
-
strokeWidth: 2,
|
|
14
|
-
},
|
|
15
|
-
|
|
16
|
-
rect: {},
|
|
17
|
-
circle: {},
|
|
18
|
-
diamond: {},
|
|
19
|
-
ellipse: {},
|
|
20
|
-
polygon: {},
|
|
21
|
-
|
|
22
|
-
text: {
|
|
23
|
-
color: '#000',
|
|
24
|
-
stroke: 'none',
|
|
25
|
-
fontSize: 12,
|
|
26
|
-
background: {
|
|
27
|
-
fill: 'transparent',
|
|
28
|
-
},
|
|
29
|
-
},
|
|
30
|
-
|
|
31
|
-
anchor: {
|
|
32
|
-
stroke: '#000',
|
|
33
|
-
fill: '#fff',
|
|
34
|
-
r: 4,
|
|
35
|
-
hover: {
|
|
36
|
-
r: 10,
|
|
37
|
-
fill: '#949494',
|
|
38
|
-
fillOpacity: 0.5,
|
|
39
|
-
stroke: '#949494',
|
|
40
|
-
},
|
|
41
|
-
},
|
|
42
|
-
|
|
43
|
-
anchorLine: {
|
|
44
|
-
stroke: '#000',
|
|
45
|
-
strokeWidth: 2,
|
|
46
|
-
strokeDasharray: '3,2',
|
|
47
|
-
},
|
|
48
|
-
|
|
49
|
-
nodeText: {
|
|
50
|
-
color: '#000',
|
|
51
|
-
overflowMode: 'default',
|
|
52
|
-
fontSize: 12,
|
|
53
|
-
lineHeight: 1.2,
|
|
54
|
-
},
|
|
55
|
-
|
|
56
|
-
edgeText: {
|
|
57
|
-
textWidth: 100,
|
|
58
|
-
overflowMode: 'default',
|
|
59
|
-
fontSize: 12,
|
|
60
|
-
background: {
|
|
61
|
-
fill: '#fff',
|
|
62
|
-
},
|
|
63
|
-
},
|
|
64
|
-
|
|
65
|
-
line: {},
|
|
66
|
-
polyline: {},
|
|
67
|
-
|
|
68
|
-
bezier: {
|
|
69
|
-
fill: 'none',
|
|
70
|
-
adjustLine: {
|
|
71
|
-
stroke: '#949494',
|
|
72
|
-
},
|
|
73
|
-
adjustAnchor: {
|
|
74
|
-
r: 4,
|
|
75
|
-
fill: '#949494',
|
|
76
|
-
fillOpacity: 1,
|
|
77
|
-
stroke: '#949494',
|
|
78
|
-
},
|
|
79
|
-
},
|
|
80
|
-
|
|
81
|
-
arrow: {
|
|
82
|
-
offset: 10,
|
|
83
|
-
verticalLength: 5, // 箭头垂直于边的距离
|
|
84
|
-
},
|
|
85
|
-
|
|
86
|
-
snapline: {
|
|
87
|
-
stroke: '#949494',
|
|
88
|
-
strokeWidth: 1,
|
|
89
|
-
},
|
|
90
|
-
|
|
91
|
-
edgeAdjust: {
|
|
92
|
-
r: 4,
|
|
93
|
-
fill: '#fff',
|
|
94
|
-
stroke: '#949494',
|
|
95
|
-
strokeWidth: 2,
|
|
96
|
-
},
|
|
97
|
-
|
|
98
|
-
outline: {
|
|
99
|
-
fill: 'transparent',
|
|
100
|
-
stroke: '#949494',
|
|
101
|
-
strokeDasharray: '3,3',
|
|
102
|
-
hover: {
|
|
103
|
-
stroke: '#949494',
|
|
104
|
-
},
|
|
105
|
-
},
|
|
106
|
-
|
|
107
|
-
edgeAnimation: {
|
|
108
|
-
stroke: 'red',
|
|
109
|
-
strokeDasharray: '10,10',
|
|
110
|
-
strokeDashoffset: '100%',
|
|
111
|
-
animationName: 'lf_animate_dash',
|
|
112
|
-
animationDuration: '20s',
|
|
113
|
-
animationIterationCount: 'infinite',
|
|
114
|
-
animationTimingFunction: 'linear',
|
|
115
|
-
animationDirection: 'normal',
|
|
116
|
-
},
|
|
117
|
-
|
|
118
|
-
rotateControl: {
|
|
119
|
-
stroke: '#000',
|
|
120
|
-
fill: '#fff',
|
|
121
|
-
strokeWidth: 1.5,
|
|
122
|
-
},
|
|
123
|
-
|
|
124
|
-
resizeControl: {
|
|
125
|
-
width: 7,
|
|
126
|
-
height: 7,
|
|
127
|
-
fill: '#fff',
|
|
128
|
-
stroke: '#000',
|
|
129
|
-
},
|
|
130
|
-
|
|
131
|
-
resizeOutline: {
|
|
132
|
-
fill: 'none',
|
|
133
|
-
stroke: 'transparent', // 矩形默认不显示调整边框
|
|
134
|
-
strokeWidth: 1,
|
|
135
|
-
strokeDasharray: '3,3',
|
|
136
|
-
},
|
|
137
|
-
}
|
|
138
|
-
export const radiusMode: any = {
|
|
139
|
-
rect: { radius: 8 },
|
|
140
|
-
diamond: { radius: 8 },
|
|
141
|
-
polygon: { radius: 8 },
|
|
142
|
-
polyline: { radius: 8 },
|
|
143
|
-
arrow: {
|
|
144
|
-
strokeLinecap: 'round',
|
|
145
|
-
strokeLinejoin: 'round',
|
|
146
|
-
offset: 10,
|
|
147
|
-
verticalLength: 5, // 箭头垂直于边的距离
|
|
148
|
-
},
|
|
149
|
-
snapline: {
|
|
150
|
-
strokeLinecap: 'round',
|
|
151
|
-
strokeLinejoin: 'round',
|
|
152
|
-
stroke: '#949494',
|
|
153
|
-
strokeWidth: 1,
|
|
154
|
-
},
|
|
155
|
-
outline: {
|
|
156
|
-
radius: 8,
|
|
157
|
-
fill: 'transparent',
|
|
158
|
-
stroke: '#949494',
|
|
159
|
-
strokeDasharray: '3,3',
|
|
160
|
-
hover: {
|
|
161
|
-
stroke: '#949494',
|
|
162
|
-
},
|
|
163
|
-
},
|
|
164
|
-
resizeOutline: {
|
|
165
|
-
radius: 8,
|
|
166
|
-
fill: 'none',
|
|
167
|
-
stroke: 'transparent', // 矩形默认不显示调整边框
|
|
168
|
-
strokeWidth: 1,
|
|
169
|
-
strokeDasharray: '3,3',
|
|
170
|
-
},
|
|
171
|
-
}
|
|
172
|
-
export const darkMode: any = {
|
|
173
|
-
baseNode: {
|
|
174
|
-
fill: '#23272e',
|
|
175
|
-
stroke: '#fefeff',
|
|
176
|
-
},
|
|
177
|
-
baseEdge: {
|
|
178
|
-
stroke: '#fefeff',
|
|
179
|
-
},
|
|
180
|
-
rect: { radius: 8 },
|
|
181
|
-
diamond: { radius: 8 },
|
|
182
|
-
polygon: { radius: 8 },
|
|
183
|
-
polyline: { radius: 8 },
|
|
184
|
-
nodeText: {
|
|
185
|
-
color: '#fefeff',
|
|
186
|
-
overflowMode: 'default',
|
|
187
|
-
fontSize: 12,
|
|
188
|
-
lineHeight: 1.2,
|
|
189
|
-
},
|
|
190
|
-
arrow: {
|
|
191
|
-
strokeLinecap: 'round',
|
|
192
|
-
strokeLinejoin: 'round',
|
|
193
|
-
offset: 10,
|
|
194
|
-
verticalLength: 5, // 箭头垂直于边的距离
|
|
195
|
-
},
|
|
196
|
-
snapline: {
|
|
197
|
-
strokeLinecap: 'round',
|
|
198
|
-
strokeLinejoin: 'round',
|
|
199
|
-
stroke: '#949494',
|
|
200
|
-
strokeWidth: 1,
|
|
201
|
-
},
|
|
202
|
-
outline: {
|
|
203
|
-
radius: 8,
|
|
204
|
-
fill: 'transparent',
|
|
205
|
-
stroke: '#949494',
|
|
206
|
-
strokeDasharray: '3,3',
|
|
207
|
-
hover: {
|
|
208
|
-
stroke: '#949494',
|
|
209
|
-
},
|
|
210
|
-
},
|
|
211
|
-
resizeOutline: {
|
|
212
|
-
radius: 8,
|
|
213
|
-
fill: 'none',
|
|
214
|
-
stroke: 'transparent', // 矩形默认不显示调整边框
|
|
215
|
-
strokeWidth: 1,
|
|
216
|
-
strokeDasharray: '3,3',
|
|
217
|
-
},
|
|
218
|
-
}
|
|
219
|
-
export const colorfulMode: any = {
|
|
220
|
-
rect: { fill: '#72CBFF', stroke: '#3ABDF9', radius: 8 },
|
|
221
|
-
circle: { fill: '#FFE075', stroke: '#F9CE3A', radius: 8 },
|
|
222
|
-
ellipse: { fill: '#FFA8A8', stroke: '#FF6B66', radius: 8 },
|
|
223
|
-
text: { fill: '#72CBFF', radius: 8 },
|
|
224
|
-
diamond: { fill: '#96F7AF', stroke: '#40EF7E', radius: 8 },
|
|
225
|
-
polygon: { fill: '#E0A8FF', stroke: '#C271FF', radius: 8 },
|
|
226
|
-
polyline: { radius: 8 },
|
|
227
|
-
arrow: {
|
|
228
|
-
strokeLinecap: 'round',
|
|
229
|
-
strokeLinejoin: 'round',
|
|
230
|
-
offset: 10,
|
|
231
|
-
verticalLength: 5, // 箭头垂直于边的距离
|
|
232
|
-
},
|
|
233
|
-
snapline: {
|
|
234
|
-
strokeLinecap: 'round',
|
|
235
|
-
strokeLinejoin: 'round',
|
|
236
|
-
stroke: '#949494',
|
|
237
|
-
strokeWidth: 1,
|
|
238
|
-
},
|
|
239
|
-
outline: {
|
|
240
|
-
radius: 8,
|
|
241
|
-
fill: 'transparent',
|
|
242
|
-
stroke: '#949494',
|
|
243
|
-
strokeDasharray: '3,3',
|
|
244
|
-
hover: {
|
|
245
|
-
stroke: '#949494',
|
|
246
|
-
},
|
|
247
|
-
},
|
|
248
|
-
resizeOutline: {
|
|
249
|
-
radius: 8,
|
|
250
|
-
fill: 'none',
|
|
251
|
-
stroke: 'transparent', // 矩形默认不显示调整边框
|
|
252
|
-
strokeWidth: 1,
|
|
253
|
-
strokeDasharray: '3,3',
|
|
254
|
-
},
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
export const themeModeMap = {
|
|
258
|
-
colorful: colorfulMode,
|
|
259
|
-
dark: darkMode,
|
|
260
|
-
radius: radiusMode,
|
|
261
|
-
default: defaultTheme,
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
// 不同主题的背景色
|
|
265
|
-
export const darkBackground = {
|
|
266
|
-
background: '#23272e',
|
|
267
|
-
}
|
|
268
|
-
export const colorfulBackground = {
|
|
269
|
-
background: '#fefeff',
|
|
270
|
-
}
|
|
271
|
-
export const defaultBackground = {
|
|
272
|
-
background: '#ffffff',
|
|
273
|
-
}
|
|
274
|
-
export const backgroundModeMap = {
|
|
275
|
-
colorful: colorfulBackground,
|
|
276
|
-
dark: darkBackground,
|
|
277
|
-
radius: defaultBackground,
|
|
278
|
-
default: defaultBackground,
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
// 不同主题的网格样式
|
|
282
|
-
export const darkGrid = {
|
|
283
|
-
color: '#66676a',
|
|
284
|
-
thickness: 1,
|
|
285
|
-
}
|
|
286
|
-
export const colorfulGrid = {
|
|
287
|
-
color: '#dadada',
|
|
288
|
-
thickness: 1,
|
|
289
|
-
}
|
|
290
|
-
export const defaultGrid = {
|
|
291
|
-
color: '#acacac',
|
|
292
|
-
thickness: 1,
|
|
293
|
-
}
|
|
294
|
-
export const gridModeMap = {
|
|
295
|
-
colorful: colorfulGrid,
|
|
296
|
-
dark: darkGrid,
|
|
297
|
-
radius: defaultGrid,
|
|
298
|
-
default: defaultGrid,
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
/* 主题(全局样式)相关工具方法 */
|
|
302
|
-
export const setupTheme = (
|
|
303
|
-
customTheme?: Partial<LogicFlow.Theme>,
|
|
304
|
-
themeMode?: 'radius' | 'dark' | 'colorful' | 'default' | string,
|
|
305
|
-
): LogicFlow.Theme => {
|
|
306
|
-
let theme = cloneDeep(defaultTheme)
|
|
307
|
-
if (themeMode) {
|
|
308
|
-
theme = merge(theme, themeModeMap[themeMode])
|
|
309
|
-
}
|
|
310
|
-
if (customTheme) {
|
|
311
|
-
/**
|
|
312
|
-
* 为了不让默认样式被覆盖,使用 merge 方法
|
|
313
|
-
* @docs https://lodash.com/docs/4.17.15#merge
|
|
314
|
-
* 例如:锚点主题 hover,用户传入如下 ->
|
|
315
|
-
* lf.setTheme({
|
|
316
|
-
* anchor: {
|
|
317
|
-
* fill: 'red'
|
|
318
|
-
* }
|
|
319
|
-
* })
|
|
320
|
-
*
|
|
321
|
-
* 预期得到的结果如下:
|
|
322
|
-
* {
|
|
323
|
-
* // ...
|
|
324
|
-
* anchor: {
|
|
325
|
-
* stroke: '#000',
|
|
326
|
-
* fill: 'red',
|
|
327
|
-
* r: 4,
|
|
328
|
-
* hover: {
|
|
329
|
-
* r: 10,
|
|
330
|
-
* fill: '#949494',
|
|
331
|
-
* fillOpacity: 0.5,
|
|
332
|
-
* stroke: '#949494',
|
|
333
|
-
* },
|
|
334
|
-
* },
|
|
335
|
-
* // ...
|
|
336
|
-
* }
|
|
337
|
-
*/
|
|
338
|
-
theme = merge(theme, customTheme)
|
|
339
|
-
}
|
|
340
|
-
return theme
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
export const addThemeMode = (
|
|
344
|
-
themeMode: string,
|
|
345
|
-
style: Partial<LogicFlow.Theme>,
|
|
346
|
-
): void => {
|
|
347
|
-
if (themeModeMap[themeMode]) {
|
|
348
|
-
console.warn(`theme mode ${themeMode} already exists`)
|
|
349
|
-
return
|
|
350
|
-
}
|
|
351
|
-
themeModeMap[themeMode] = style
|
|
352
|
-
backgroundModeMap[themeMode] = style.background || defaultBackground
|
|
353
|
-
gridModeMap[themeMode] = style.grid || defaultGrid
|
|
354
|
-
}
|
|
355
|
-
|
|
356
|
-
export const removeThemeMode = (themeMode: string): void => {
|
|
357
|
-
delete themeModeMap[themeMode]
|
|
358
|
-
delete backgroundModeMap[themeMode]
|
|
359
|
-
delete gridModeMap[themeMode]
|
|
360
|
-
}
|
|
361
|
-
|
|
362
|
-
export const clearThemeMode = (): void => {
|
|
363
|
-
const resetTheme = {
|
|
364
|
-
colorful: {},
|
|
365
|
-
dark: {},
|
|
366
|
-
radius: {},
|
|
367
|
-
default: {},
|
|
368
|
-
}
|
|
369
|
-
assign(themeModeMap, resetTheme)
|
|
370
|
-
assign(backgroundModeMap, resetTheme)
|
|
371
|
-
assign(gridModeMap, resetTheme)
|
|
372
|
-
}
|
|
373
|
-
|
|
374
|
-
/* 更新 theme 方法 */
|
|
375
|
-
export const updateTheme = setupTheme
|
package/src/util/uuid.ts
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { v4 as uuidV4 } from 'uuid'
|
|
2
|
-
import LogicFlow from '../LogicFlow'
|
|
3
|
-
|
|
4
|
-
import GraphData = LogicFlow.GraphData
|
|
5
|
-
|
|
6
|
-
export const createUuid = (): string => uuidV4()
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* 重新刷新流程图的所有id
|
|
10
|
-
*/
|
|
11
|
-
export const refreshGraphId = (
|
|
12
|
-
graphData: GraphData,
|
|
13
|
-
prefix = '',
|
|
14
|
-
): GraphData => {
|
|
15
|
-
const nodeIdMap = graphData.nodes.reduce((nMap, node) => {
|
|
16
|
-
nMap[node.id] = prefix + uuidV4()
|
|
17
|
-
node.id = nMap[node.id]
|
|
18
|
-
return nMap
|
|
19
|
-
}, {})
|
|
20
|
-
graphData.edges.forEach((edge) => {
|
|
21
|
-
edge.id = prefix + uuidV4()
|
|
22
|
-
edge.sourceNodeId = nodeIdMap[edge.sourceNodeId]
|
|
23
|
-
edge.targetNodeId = nodeIdMap[edge.targetNodeId]
|
|
24
|
-
})
|
|
25
|
-
return graphData
|
|
26
|
-
}
|
package/src/util/vector.ts
DELETED
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
function isVector(a1: any, a2: any): boolean {
|
|
2
|
-
return !!(a1 instanceof Vector && a2 instanceof Vector)
|
|
3
|
-
}
|
|
4
|
-
|
|
5
|
-
class Base extends Array<number> {
|
|
6
|
-
x: number
|
|
7
|
-
y: number
|
|
8
|
-
z: number
|
|
9
|
-
|
|
10
|
-
constructor(x: number, y: number, z: number) {
|
|
11
|
-
super(3)
|
|
12
|
-
this[0] = x
|
|
13
|
-
this[1] = y
|
|
14
|
-
this[2] = z
|
|
15
|
-
this.x = x
|
|
16
|
-
this.y = y
|
|
17
|
-
this.z = z
|
|
18
|
-
Object.setPrototypeOf(this, Base.prototype)
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
add(v1: Vector | Point): Vector | Point {
|
|
22
|
-
if (isVector(this, v1)) {
|
|
23
|
-
return new Vector(this.x + v1.x, this.y + v1.y)
|
|
24
|
-
}
|
|
25
|
-
const z = this.z + v1.z
|
|
26
|
-
return new Point((this.x + v1.x) / z, (this.y + v1.y) / z)
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
subtract(v1: Vector | Point): Vector | Point {
|
|
30
|
-
if (isVector(this, v1)) {
|
|
31
|
-
return new Vector(this.x - v1.x, this.y - v1.y)
|
|
32
|
-
}
|
|
33
|
-
const z = this.z - v1.z
|
|
34
|
-
return z === 0
|
|
35
|
-
? new Vector(this.x - v1.x, this.y - v1.y)
|
|
36
|
-
: new Point((this.x - v1.x) / z, (this.y - v1.y) / z)
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
class Vector extends Base {
|
|
41
|
-
constructor(x: number, y: number, z?: number) {
|
|
42
|
-
super(x, y, z ?? 0)
|
|
43
|
-
Object.setPrototypeOf(this, Vector.prototype)
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
toString(): string {
|
|
47
|
-
return 'Vector'
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
dot(v1: Vector) {
|
|
51
|
-
return v1.reduce((prev, cur, index) => prev + cur * this[index])
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
cross(v1: Vector) {
|
|
55
|
-
return new Vector(
|
|
56
|
-
this.y * v1.z - this.z * v1.y,
|
|
57
|
-
this.z * v1.x - this.x * v1.z,
|
|
58
|
-
this.x * v1.y - this.y * v1.x,
|
|
59
|
-
)
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
getLength() {
|
|
63
|
-
return Math.hypot(this.x, this.y)
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
normalize() {
|
|
67
|
-
const len = this.getLength()
|
|
68
|
-
return new Vector(this.x / len, this.y / len)
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
crossZ(v1: Vector) {
|
|
72
|
-
return this.x * v1.y - this.y * v1.x
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
angle(v1: Vector) {
|
|
76
|
-
const negative = this.crossZ(v1)
|
|
77
|
-
const r = Math.acos(this.normalize().dot(v1.normalize()))
|
|
78
|
-
return negative >= 0 ? r : -r
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
class Point extends Base {
|
|
83
|
-
constructor(x: number, y: number) {
|
|
84
|
-
super(x, y, 1)
|
|
85
|
-
Object.setPrototypeOf(this, Point.prototype)
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
toString(): string {
|
|
89
|
-
return 'Point'
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
export { Vector, Point }
|