@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/es/util/theme.js
CHANGED
|
@@ -1,286 +1,9 @@
|
|
|
1
1
|
import { cloneDeep, merge, assign } from 'lodash-es';
|
|
2
|
-
|
|
3
|
-
baseNode: {
|
|
4
|
-
fill: '#fff',
|
|
5
|
-
stroke: '#000',
|
|
6
|
-
strokeWidth: 2,
|
|
7
|
-
},
|
|
8
|
-
baseEdge: {
|
|
9
|
-
stroke: '#000',
|
|
10
|
-
strokeWidth: 2,
|
|
11
|
-
},
|
|
12
|
-
rect: {},
|
|
13
|
-
circle: {},
|
|
14
|
-
diamond: {},
|
|
15
|
-
ellipse: {},
|
|
16
|
-
polygon: {},
|
|
17
|
-
text: {
|
|
18
|
-
color: '#000',
|
|
19
|
-
stroke: 'none',
|
|
20
|
-
fontSize: 12,
|
|
21
|
-
background: {
|
|
22
|
-
fill: 'transparent',
|
|
23
|
-
},
|
|
24
|
-
},
|
|
25
|
-
anchor: {
|
|
26
|
-
stroke: '#000',
|
|
27
|
-
fill: '#fff',
|
|
28
|
-
r: 4,
|
|
29
|
-
hover: {
|
|
30
|
-
r: 10,
|
|
31
|
-
fill: '#949494',
|
|
32
|
-
fillOpacity: 0.5,
|
|
33
|
-
stroke: '#949494',
|
|
34
|
-
},
|
|
35
|
-
},
|
|
36
|
-
anchorLine: {
|
|
37
|
-
stroke: '#000',
|
|
38
|
-
strokeWidth: 2,
|
|
39
|
-
strokeDasharray: '3,2',
|
|
40
|
-
},
|
|
41
|
-
nodeText: {
|
|
42
|
-
color: '#000',
|
|
43
|
-
overflowMode: 'default',
|
|
44
|
-
fontSize: 12,
|
|
45
|
-
lineHeight: 1.2,
|
|
46
|
-
},
|
|
47
|
-
edgeText: {
|
|
48
|
-
textWidth: 100,
|
|
49
|
-
overflowMode: 'default',
|
|
50
|
-
fontSize: 12,
|
|
51
|
-
background: {
|
|
52
|
-
fill: '#fff',
|
|
53
|
-
},
|
|
54
|
-
},
|
|
55
|
-
line: {},
|
|
56
|
-
polyline: {},
|
|
57
|
-
bezier: {
|
|
58
|
-
fill: 'none',
|
|
59
|
-
adjustLine: {
|
|
60
|
-
stroke: '#949494',
|
|
61
|
-
},
|
|
62
|
-
adjustAnchor: {
|
|
63
|
-
r: 4,
|
|
64
|
-
fill: '#949494',
|
|
65
|
-
fillOpacity: 1,
|
|
66
|
-
stroke: '#949494',
|
|
67
|
-
},
|
|
68
|
-
},
|
|
69
|
-
arrow: {
|
|
70
|
-
offset: 10,
|
|
71
|
-
verticalLength: 5, // 箭头垂直于边的距离
|
|
72
|
-
},
|
|
73
|
-
snapline: {
|
|
74
|
-
stroke: '#949494',
|
|
75
|
-
strokeWidth: 1,
|
|
76
|
-
},
|
|
77
|
-
edgeAdjust: {
|
|
78
|
-
r: 4,
|
|
79
|
-
fill: '#fff',
|
|
80
|
-
stroke: '#949494',
|
|
81
|
-
strokeWidth: 2,
|
|
82
|
-
},
|
|
83
|
-
outline: {
|
|
84
|
-
fill: 'transparent',
|
|
85
|
-
stroke: '#949494',
|
|
86
|
-
strokeDasharray: '3,3',
|
|
87
|
-
hover: {
|
|
88
|
-
stroke: '#949494',
|
|
89
|
-
},
|
|
90
|
-
},
|
|
91
|
-
edgeAnimation: {
|
|
92
|
-
stroke: 'red',
|
|
93
|
-
strokeDasharray: '10,10',
|
|
94
|
-
strokeDashoffset: '100%',
|
|
95
|
-
animationName: 'lf_animate_dash',
|
|
96
|
-
animationDuration: '20s',
|
|
97
|
-
animationIterationCount: 'infinite',
|
|
98
|
-
animationTimingFunction: 'linear',
|
|
99
|
-
animationDirection: 'normal',
|
|
100
|
-
},
|
|
101
|
-
rotateControl: {
|
|
102
|
-
stroke: '#000',
|
|
103
|
-
fill: '#fff',
|
|
104
|
-
strokeWidth: 1.5,
|
|
105
|
-
},
|
|
106
|
-
resizeControl: {
|
|
107
|
-
width: 7,
|
|
108
|
-
height: 7,
|
|
109
|
-
fill: '#fff',
|
|
110
|
-
stroke: '#000',
|
|
111
|
-
},
|
|
112
|
-
resizeOutline: {
|
|
113
|
-
fill: 'none',
|
|
114
|
-
stroke: 'transparent', // 矩形默认不显示调整边框
|
|
115
|
-
strokeWidth: 1,
|
|
116
|
-
strokeDasharray: '3,3',
|
|
117
|
-
},
|
|
118
|
-
};
|
|
119
|
-
export var radiusMode = {
|
|
120
|
-
rect: { radius: 8 },
|
|
121
|
-
diamond: { radius: 8 },
|
|
122
|
-
polygon: { radius: 8 },
|
|
123
|
-
polyline: { radius: 8 },
|
|
124
|
-
arrow: {
|
|
125
|
-
strokeLinecap: 'round',
|
|
126
|
-
strokeLinejoin: 'round',
|
|
127
|
-
offset: 10,
|
|
128
|
-
verticalLength: 5, // 箭头垂直于边的距离
|
|
129
|
-
},
|
|
130
|
-
snapline: {
|
|
131
|
-
strokeLinecap: 'round',
|
|
132
|
-
strokeLinejoin: 'round',
|
|
133
|
-
stroke: '#949494',
|
|
134
|
-
strokeWidth: 1,
|
|
135
|
-
},
|
|
136
|
-
outline: {
|
|
137
|
-
radius: 8,
|
|
138
|
-
fill: 'transparent',
|
|
139
|
-
stroke: '#949494',
|
|
140
|
-
strokeDasharray: '3,3',
|
|
141
|
-
hover: {
|
|
142
|
-
stroke: '#949494',
|
|
143
|
-
},
|
|
144
|
-
},
|
|
145
|
-
resizeOutline: {
|
|
146
|
-
radius: 8,
|
|
147
|
-
fill: 'none',
|
|
148
|
-
stroke: 'transparent', // 矩形默认不显示调整边框
|
|
149
|
-
strokeWidth: 1,
|
|
150
|
-
strokeDasharray: '3,3',
|
|
151
|
-
},
|
|
152
|
-
};
|
|
153
|
-
export var darkMode = {
|
|
154
|
-
baseNode: {
|
|
155
|
-
fill: '#23272e',
|
|
156
|
-
stroke: '#fefeff',
|
|
157
|
-
},
|
|
158
|
-
baseEdge: {
|
|
159
|
-
stroke: '#fefeff',
|
|
160
|
-
},
|
|
161
|
-
rect: { radius: 8 },
|
|
162
|
-
diamond: { radius: 8 },
|
|
163
|
-
polygon: { radius: 8 },
|
|
164
|
-
polyline: { radius: 8 },
|
|
165
|
-
nodeText: {
|
|
166
|
-
color: '#fefeff',
|
|
167
|
-
overflowMode: 'default',
|
|
168
|
-
fontSize: 12,
|
|
169
|
-
lineHeight: 1.2,
|
|
170
|
-
},
|
|
171
|
-
arrow: {
|
|
172
|
-
strokeLinecap: 'round',
|
|
173
|
-
strokeLinejoin: 'round',
|
|
174
|
-
offset: 10,
|
|
175
|
-
verticalLength: 5, // 箭头垂直于边的距离
|
|
176
|
-
},
|
|
177
|
-
snapline: {
|
|
178
|
-
strokeLinecap: 'round',
|
|
179
|
-
strokeLinejoin: 'round',
|
|
180
|
-
stroke: '#949494',
|
|
181
|
-
strokeWidth: 1,
|
|
182
|
-
},
|
|
183
|
-
outline: {
|
|
184
|
-
radius: 8,
|
|
185
|
-
fill: 'transparent',
|
|
186
|
-
stroke: '#949494',
|
|
187
|
-
strokeDasharray: '3,3',
|
|
188
|
-
hover: {
|
|
189
|
-
stroke: '#949494',
|
|
190
|
-
},
|
|
191
|
-
},
|
|
192
|
-
resizeOutline: {
|
|
193
|
-
radius: 8,
|
|
194
|
-
fill: 'none',
|
|
195
|
-
stroke: 'transparent', // 矩形默认不显示调整边框
|
|
196
|
-
strokeWidth: 1,
|
|
197
|
-
strokeDasharray: '3,3',
|
|
198
|
-
},
|
|
199
|
-
};
|
|
200
|
-
export var colorfulMode = {
|
|
201
|
-
rect: { fill: '#72CBFF', stroke: '#3ABDF9', radius: 8 },
|
|
202
|
-
circle: { fill: '#FFE075', stroke: '#F9CE3A', radius: 8 },
|
|
203
|
-
ellipse: { fill: '#FFA8A8', stroke: '#FF6B66', radius: 8 },
|
|
204
|
-
text: { fill: '#72CBFF', radius: 8 },
|
|
205
|
-
diamond: { fill: '#96F7AF', stroke: '#40EF7E', radius: 8 },
|
|
206
|
-
polygon: { fill: '#E0A8FF', stroke: '#C271FF', radius: 8 },
|
|
207
|
-
polyline: { radius: 8 },
|
|
208
|
-
arrow: {
|
|
209
|
-
strokeLinecap: 'round',
|
|
210
|
-
strokeLinejoin: 'round',
|
|
211
|
-
offset: 10,
|
|
212
|
-
verticalLength: 5, // 箭头垂直于边的距离
|
|
213
|
-
},
|
|
214
|
-
snapline: {
|
|
215
|
-
strokeLinecap: 'round',
|
|
216
|
-
strokeLinejoin: 'round',
|
|
217
|
-
stroke: '#949494',
|
|
218
|
-
strokeWidth: 1,
|
|
219
|
-
},
|
|
220
|
-
outline: {
|
|
221
|
-
radius: 8,
|
|
222
|
-
fill: 'transparent',
|
|
223
|
-
stroke: '#949494',
|
|
224
|
-
strokeDasharray: '3,3',
|
|
225
|
-
hover: {
|
|
226
|
-
stroke: '#949494',
|
|
227
|
-
},
|
|
228
|
-
},
|
|
229
|
-
resizeOutline: {
|
|
230
|
-
radius: 8,
|
|
231
|
-
fill: 'none',
|
|
232
|
-
stroke: 'transparent', // 矩形默认不显示调整边框
|
|
233
|
-
strokeWidth: 1,
|
|
234
|
-
strokeDasharray: '3,3',
|
|
235
|
-
},
|
|
236
|
-
};
|
|
237
|
-
export var themeModeMap = {
|
|
238
|
-
colorful: colorfulMode,
|
|
239
|
-
dark: darkMode,
|
|
240
|
-
radius: radiusMode,
|
|
241
|
-
default: defaultTheme,
|
|
242
|
-
};
|
|
243
|
-
// 不同主题的背景色
|
|
244
|
-
export var darkBackground = {
|
|
245
|
-
background: '#23272e',
|
|
246
|
-
};
|
|
247
|
-
export var colorfulBackground = {
|
|
248
|
-
background: '#fefeff',
|
|
249
|
-
};
|
|
250
|
-
export var defaultBackground = {
|
|
251
|
-
background: '#ffffff',
|
|
252
|
-
};
|
|
253
|
-
export var backgroundModeMap = {
|
|
254
|
-
colorful: colorfulBackground,
|
|
255
|
-
dark: darkBackground,
|
|
256
|
-
radius: defaultBackground,
|
|
257
|
-
default: defaultBackground,
|
|
258
|
-
};
|
|
259
|
-
// 不同主题的网格样式
|
|
260
|
-
export var darkGrid = {
|
|
261
|
-
color: '#66676a',
|
|
262
|
-
thickness: 1,
|
|
263
|
-
};
|
|
264
|
-
export var colorfulGrid = {
|
|
265
|
-
color: '#dadada',
|
|
266
|
-
thickness: 1,
|
|
267
|
-
};
|
|
268
|
-
export var defaultGrid = {
|
|
269
|
-
color: '#acacac',
|
|
270
|
-
thickness: 1,
|
|
271
|
-
};
|
|
272
|
-
export var gridModeMap = {
|
|
273
|
-
colorful: colorfulGrid,
|
|
274
|
-
dark: darkGrid,
|
|
275
|
-
radius: defaultGrid,
|
|
276
|
-
default: defaultGrid,
|
|
277
|
-
};
|
|
2
|
+
import { themeModeMap, backgroundModeMap, defaultBackground, gridModeMap, defaultGrid, } from '../constant/theme';
|
|
278
3
|
/* 主题(全局样式)相关工具方法 */
|
|
279
4
|
export var setupTheme = function (customTheme, themeMode) {
|
|
280
|
-
var theme = cloneDeep(
|
|
281
|
-
|
|
282
|
-
theme = merge(theme, themeModeMap[themeMode]);
|
|
283
|
-
}
|
|
5
|
+
var theme = cloneDeep(themeModeMap[themeMode || 'default']) ||
|
|
6
|
+
cloneDeep(themeModeMap.default);
|
|
284
7
|
if (customTheme) {
|
|
285
8
|
/**
|
|
286
9
|
* 为了不让默认样式被覆盖,使用 merge 方法
|
|
@@ -331,7 +54,7 @@ export var clearThemeMode = function () {
|
|
|
331
54
|
var resetTheme = {
|
|
332
55
|
colorful: {},
|
|
333
56
|
dark: {},
|
|
334
|
-
|
|
57
|
+
retro: {},
|
|
335
58
|
default: {},
|
|
336
59
|
};
|
|
337
60
|
assign(themeModeMap, resetTheme);
|
package/es/view/Anchor.d.ts
CHANGED
|
@@ -40,6 +40,7 @@ declare class Anchor extends Component<IProps, IState> {
|
|
|
40
40
|
};
|
|
41
41
|
checkEnd: (event: PointerEvent | null | undefined) => import("../model").BaseEdgeModel<LogicFlow.PropertiesType> | null | undefined;
|
|
42
42
|
moveAnchorEnd(endX: number, endY: number, event?: PointerEvent): void;
|
|
43
|
+
validateAndSetState(targetNode: BaseNodeModel, anchorId: string | undefined, targetAnchor: AnchorConfig, nodeModel: BaseNodeModel, anchorData: AnchorConfig): void;
|
|
43
44
|
isShowLine(): boolean;
|
|
44
45
|
render(): import("preact/compat").JSX.Element;
|
|
45
46
|
}
|
package/es/view/Anchor.js
CHANGED
|
@@ -248,8 +248,7 @@ var Anchor = /** @class */ (function (_super) {
|
|
|
248
248
|
configurable: true
|
|
249
249
|
});
|
|
250
250
|
Anchor.prototype.moveAnchorEnd = function (endX, endY, event) {
|
|
251
|
-
var _a,
|
|
252
|
-
var _c = this.props, graphModel = _c.graphModel, nodeModel = _c.nodeModel, anchorData = _c.anchorData;
|
|
251
|
+
var _a = this.props, graphModel = _a.graphModel, nodeModel = _a.nodeModel, anchorData = _a.anchorData;
|
|
253
252
|
var info = targetNodeInfo({
|
|
254
253
|
x: endX,
|
|
255
254
|
y: endY,
|
|
@@ -265,25 +264,7 @@ var Anchor = /** @class */ (function (_super) {
|
|
|
265
264
|
return;
|
|
266
265
|
}
|
|
267
266
|
this.preTargetNode = targetNode;
|
|
268
|
-
|
|
269
|
-
var targetInfoId = "".concat(nodeModel.id, "_").concat(targetNode.id, "_").concat(anchorId, "_").concat(anchorData.id);
|
|
270
|
-
// 查看鼠标是否进入过target,若有检验结果,表示进入过, 就不重复计算了。
|
|
271
|
-
if (!this.targetRuleResults.has(targetInfoId)) {
|
|
272
|
-
var targetAnchor = info.anchor;
|
|
273
|
-
var sourceRuleResult = nodeModel.isAllowConnectedAsSource(targetNode, anchorData, targetAnchor);
|
|
274
|
-
var targetRuleResult = targetNode.isAllowConnectedAsTarget(nodeModel, anchorData, targetAnchor);
|
|
275
|
-
this.sourceRuleResults.set(targetInfoId, formatAnchorConnectValidateData(sourceRuleResult));
|
|
276
|
-
this.targetRuleResults.set(targetInfoId, formatAnchorConnectValidateData(targetRuleResult));
|
|
277
|
-
}
|
|
278
|
-
var isSourcePass = ((_a = this.sourceRuleResults.get(targetInfoId)) !== null && _a !== void 0 ? _a : {}).isAllPass;
|
|
279
|
-
var isTargetPass = ((_b = this.targetRuleResults.get(targetInfoId)) !== null && _b !== void 0 ? _b : {}).isAllPass;
|
|
280
|
-
// 实时提示出即将链接的锚点
|
|
281
|
-
if (isSourcePass && isTargetPass) {
|
|
282
|
-
targetNode.setElementState(ElementState.ALLOW_CONNECT);
|
|
283
|
-
}
|
|
284
|
-
else {
|
|
285
|
-
targetNode.setElementState(ElementState.NOT_ALLOW_CONNECT);
|
|
286
|
-
}
|
|
267
|
+
this.validateAndSetState(targetNode, anchorId, info.anchor, nodeModel, anchorData);
|
|
287
268
|
// 人工触发进入目标节点事件,同步设置 hovered 以驱动锚点显隐和样式
|
|
288
269
|
if (!targetNode.isHovered) {
|
|
289
270
|
var nodeData = targetNode.getData();
|
|
@@ -312,6 +293,28 @@ var Anchor = /** @class */ (function (_super) {
|
|
|
312
293
|
this.preTargetNode = undefined;
|
|
313
294
|
}
|
|
314
295
|
};
|
|
296
|
+
// 校验 source/target 连接规则并设置目标节点状态
|
|
297
|
+
Anchor.prototype.validateAndSetState = function (targetNode, anchorId, targetAnchor, nodeModel, anchorData) {
|
|
298
|
+
var _a, _b;
|
|
299
|
+
var targetInfoId = "".concat(nodeModel.id, "_").concat(targetNode.id, "_").concat(anchorId, "_").concat(anchorData.id);
|
|
300
|
+
if (!this.targetRuleResults.has(targetInfoId)) {
|
|
301
|
+
// 首次计算并缓存源/目标两侧的规则校验结果
|
|
302
|
+
var sourceRuleResult = nodeModel.isAllowConnectedAsSource(targetNode, anchorData, targetAnchor);
|
|
303
|
+
var targetRuleResult = targetNode.isAllowConnectedAsTarget(nodeModel, anchorData, targetAnchor);
|
|
304
|
+
this.sourceRuleResults.set(targetInfoId, formatAnchorConnectValidateData(sourceRuleResult));
|
|
305
|
+
this.targetRuleResults.set(targetInfoId, formatAnchorConnectValidateData(targetRuleResult));
|
|
306
|
+
}
|
|
307
|
+
// 读取缓存的校验结果
|
|
308
|
+
var isSourcePass = ((_a = this.sourceRuleResults.get(targetInfoId)) !== null && _a !== void 0 ? _a : {}).isAllPass;
|
|
309
|
+
var isTargetPass = ((_b = this.targetRuleResults.get(targetInfoId)) !== null && _b !== void 0 ? _b : {}).isAllPass;
|
|
310
|
+
// 两侧都通过则允许连接,否则标记为不允许连接
|
|
311
|
+
if (isSourcePass && isTargetPass) {
|
|
312
|
+
targetNode.setElementState(ElementState.ALLOW_CONNECT);
|
|
313
|
+
}
|
|
314
|
+
else {
|
|
315
|
+
targetNode.setElementState(ElementState.NOT_ALLOW_CONNECT);
|
|
316
|
+
}
|
|
317
|
+
};
|
|
315
318
|
Anchor.prototype.isShowLine = function () {
|
|
316
319
|
var _a = this.state, startX = _a.startX, startY = _a.startY, endX = _a.endX, endY = _a.endY;
|
|
317
320
|
var v = distance(startX, startY, endX, endY);
|
package/es/view/Control.d.ts
CHANGED
|
@@ -50,6 +50,11 @@ export declare class ResizeControl extends Component<IResizeControlProps, IResiz
|
|
|
50
50
|
onDragStart: () => void;
|
|
51
51
|
onDragging: ({ deltaX, deltaY }: IDragParams) => void;
|
|
52
52
|
onDragEnd: () => void;
|
|
53
|
+
onPointerDown: (e: PointerEvent) => void;
|
|
54
|
+
getViewPosition(direction: any, x: any, y: any): {
|
|
55
|
+
x: any;
|
|
56
|
+
y: any;
|
|
57
|
+
};
|
|
53
58
|
render(): h.JSX.Element;
|
|
54
59
|
}
|
|
55
60
|
interface IResizeControlGroupProps {
|
package/es/view/Control.js
CHANGED
|
@@ -243,61 +243,6 @@ var ResizeControl = /** @class */ (function (_super) {
|
|
|
243
243
|
_this.dragHandler.cancelDrag();
|
|
244
244
|
},
|
|
245
245
|
});
|
|
246
|
-
// 1. 计算当前 Control 的一些信息,
|
|
247
|
-
// const {
|
|
248
|
-
// r, // circle
|
|
249
|
-
// rx, // ellipse/diamond
|
|
250
|
-
// ry,
|
|
251
|
-
// width, // rect/html
|
|
252
|
-
// height,
|
|
253
|
-
// PCTResizeInfo,
|
|
254
|
-
//
|
|
255
|
-
// minWidth,
|
|
256
|
-
// minHeight,
|
|
257
|
-
// maxWidth,
|
|
258
|
-
// maxHeight,
|
|
259
|
-
// } = this.nodeModel
|
|
260
|
-
// const isFreezeWidth = minWidth === maxWidth
|
|
261
|
-
// const isFreezeHeight = minHeight === maxHeight
|
|
262
|
-
//
|
|
263
|
-
// const resizeInfo = {
|
|
264
|
-
// width: r || rx || width,
|
|
265
|
-
// height: r || ry || height,
|
|
266
|
-
// deltaX,
|
|
267
|
-
// deltaY,
|
|
268
|
-
// PCTResizeInfo,
|
|
269
|
-
// }
|
|
270
|
-
//
|
|
271
|
-
// const pct = r || (rx && ry) ? 1 / 2 : 1
|
|
272
|
-
// const nextSize = this.recalcResizeInfo(
|
|
273
|
-
// this.index,
|
|
274
|
-
// resizeInfo,
|
|
275
|
-
// pct,
|
|
276
|
-
// isFreezeWidth,
|
|
277
|
-
// isFreezeHeight,
|
|
278
|
-
// )
|
|
279
|
-
//
|
|
280
|
-
// // 限制放大缩小的最大最小范围
|
|
281
|
-
// if (
|
|
282
|
-
// nextSize.width < minWidth ||
|
|
283
|
-
// nextSize.width > maxWidth ||
|
|
284
|
-
// nextSize.height < minHeight ||
|
|
285
|
-
// nextSize.height > maxHeight
|
|
286
|
-
// ) {
|
|
287
|
-
// this.dragHandler.cancelDrag()
|
|
288
|
-
// return
|
|
289
|
-
// }
|
|
290
|
-
// // 如果限制了宽高不变,对应的 x/y 不产生位移
|
|
291
|
-
// nextSize.deltaX = isFreezeWidth ? 0 : nextSize.deltaX
|
|
292
|
-
// nextSize.deltaY = isFreezeWidth ? 0 : nextSize.deltaY
|
|
293
|
-
//
|
|
294
|
-
// const preNodeData = this.nodeModel.getData()
|
|
295
|
-
// const curNodeData = this.nodeModel.resize(nextSize)
|
|
296
|
-
//
|
|
297
|
-
// // 更新边
|
|
298
|
-
// this.updateEdgePointByAnchors()
|
|
299
|
-
// // 触发 resize 事件
|
|
300
|
-
// this.triggerResizeEvent(preNodeData, curNodeData, deltaX, deltaY, this.index, this.nodeModel)
|
|
301
246
|
};
|
|
302
247
|
_this.onDragStart = function () {
|
|
303
248
|
_this.graphModel.selectNodeById(_this.nodeModel.id);
|
|
@@ -325,6 +270,10 @@ var ResizeControl = /** @class */ (function (_super) {
|
|
|
325
270
|
// 此时拿到的 anchors 是最新的
|
|
326
271
|
_this.updateEdgePointByAnchors();
|
|
327
272
|
};
|
|
273
|
+
_this.onPointerDown = function (e) {
|
|
274
|
+
e.stopPropagation();
|
|
275
|
+
_this.dragHandler.handleMouseDown(e);
|
|
276
|
+
};
|
|
328
277
|
var index = props.index, model = props.model, graphModel = props.graphModel;
|
|
329
278
|
_this.index = index;
|
|
330
279
|
_this.nodeModel = model;
|
|
@@ -343,10 +292,46 @@ var ResizeControl = /** @class */ (function (_super) {
|
|
|
343
292
|
document.removeEventListener('keydown', this.handleKeyDown);
|
|
344
293
|
document.removeEventListener('keyup', this.handleKeyUp);
|
|
345
294
|
};
|
|
295
|
+
ResizeControl.prototype.getViewPosition = function (direction, x, y) {
|
|
296
|
+
var _a = this.props.model.getResizeControlStyle(), _b = _a.width, width = _b === void 0 ? 8 : _b, _c = _a.height, height = _c === void 0 ? 8 : _c;
|
|
297
|
+
switch (direction) {
|
|
298
|
+
case 'nw':
|
|
299
|
+
return {
|
|
300
|
+
x: x - width / 2,
|
|
301
|
+
y: y - height / 2,
|
|
302
|
+
};
|
|
303
|
+
case 'ne': {
|
|
304
|
+
return {
|
|
305
|
+
x: x + width / 2,
|
|
306
|
+
y: y - height / 2,
|
|
307
|
+
};
|
|
308
|
+
}
|
|
309
|
+
case 'se': {
|
|
310
|
+
return {
|
|
311
|
+
x: x + width / 2,
|
|
312
|
+
y: y + height / 2,
|
|
313
|
+
};
|
|
314
|
+
}
|
|
315
|
+
case 'sw': {
|
|
316
|
+
return {
|
|
317
|
+
x: x - width / 2,
|
|
318
|
+
y: y + height / 2,
|
|
319
|
+
};
|
|
320
|
+
}
|
|
321
|
+
default: {
|
|
322
|
+
return {
|
|
323
|
+
x: x,
|
|
324
|
+
y: y,
|
|
325
|
+
};
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
};
|
|
346
329
|
ResizeControl.prototype.render = function () {
|
|
347
330
|
var _a = this.props, x = _a.x, y = _a.y, direction = _a.direction, model = _a.model;
|
|
348
331
|
var _b = model.getResizeControlStyle(), width = _b.width, height = _b.height, restStyle = __rest(_b, ["width", "height"]);
|
|
349
|
-
|
|
332
|
+
// 为了让调整点在视觉上在调整外框的中间,因此在渲染时转换一下
|
|
333
|
+
var _c = this.getViewPosition(direction, x, y), viewX = _c.x, viewY = _c.y;
|
|
334
|
+
return (_jsxs("g", { className: "lf-resize-control lf-resize-control-".concat(direction), children: [_jsx(Rect, __assign({ className: "lf-resize-control-content", x: viewX, y: viewY, width: width !== null && width !== void 0 ? width : 7, height: height !== null && height !== void 0 ? height : 7 }, restStyle)), _jsx(Rect, { className: "lf-resize-control-content", x: viewX, y: viewY, width: width ? width + 5 : 25, height: width ? width + 5 : 25, fill: "transparent", stroke: "transparent", onPointerDown: this.onPointerDown })] }));
|
|
350
335
|
};
|
|
351
336
|
return ResizeControl;
|
|
352
337
|
}(Component));
|
|
@@ -391,7 +376,9 @@ var ResizeControlGroup = /** @class */ (function (_super) {
|
|
|
391
376
|
var model = this.props.model;
|
|
392
377
|
var x = model.x, y = model.y, width = model.width, height = model.height;
|
|
393
378
|
var style = model.getResizeOutlineStyle();
|
|
394
|
-
return _jsx(Rect, __assign({}, style, { x: x, y: y,
|
|
379
|
+
return (_jsx(Rect, __assign({}, style, { "pointer-events": "none", x: x, y: y,
|
|
380
|
+
// TODO:宽高padding后续改成配置化的
|
|
381
|
+
width: width + 10, height: height + 10 })));
|
|
395
382
|
};
|
|
396
383
|
ResizeControlGroup.prototype.render = function () {
|
|
397
384
|
return (_jsxs("g", { className: "lf-resize-control-group", children: [this.getResizeOutline(), this.getResizeControl()] }));
|
package/es/view/edge/BaseEdge.js
CHANGED
|
@@ -42,6 +42,7 @@ var __read = (this && this.__read) || function (o, n) {
|
|
|
42
42
|
};
|
|
43
43
|
import { jsx as _jsx, jsxs as _jsxs } from "preact/jsx-runtime";
|
|
44
44
|
import { Component, createRef } from 'preact/compat';
|
|
45
|
+
import { isFunction, isNil } from 'lodash-es';
|
|
45
46
|
import { Circle } from '../shape';
|
|
46
47
|
import { LineText } from '../text';
|
|
47
48
|
import { ElementState, EventType, ModelType, TextMode } from '../../constant';
|
|
@@ -207,6 +208,14 @@ var BaseEdge = /** @class */ (function (_super) {
|
|
|
207
208
|
e: e,
|
|
208
209
|
position: position,
|
|
209
210
|
});
|
|
211
|
+
// 复制粘贴后会出现点击边时,边会失去焦点的问题,这里手动让边获焦以解决这个问题
|
|
212
|
+
var el_1 = e.currentTarget;
|
|
213
|
+
var rAF = !isNil(window) && isFunction(window.requestAnimationFrame)
|
|
214
|
+
? window.requestAnimationFrame.bind(window)
|
|
215
|
+
: function (fn) { return setTimeout(fn, 0); };
|
|
216
|
+
rAF(function () {
|
|
217
|
+
el_1.focus();
|
|
218
|
+
});
|
|
210
219
|
}
|
|
211
220
|
var editConfigModel = graphModel.editConfigModel;
|
|
212
221
|
graphModel.selectEdgeById(model.id, isMultipleSelect(e, editConfigModel));
|
|
@@ -45,6 +45,7 @@ import BaseEdge from './BaseEdge';
|
|
|
45
45
|
import { Polyline, Path } from '../shape';
|
|
46
46
|
import { EventType, SegmentDirection } from '../../constant';
|
|
47
47
|
import { StepDrag, points2PointsList } from '../../util';
|
|
48
|
+
import { generateRoundedCorners } from '../../util/geometry';
|
|
48
49
|
import { getVerticalPointOfLine } from '../../algorithm';
|
|
49
50
|
var PolylineEdge = /** @class */ (function (_super) {
|
|
50
51
|
__extends(PolylineEdge, _super);
|
|
@@ -125,12 +126,22 @@ var PolylineEdge = /** @class */ (function (_super) {
|
|
|
125
126
|
* @example https://docs.logic-flow.cn/docs/#/zh/guide/basic/edge?id=%e5%9f%ba%e4%ba%8e-react-%e7%bb%84%e4%bb%b6%e8%87%aa%e5%ae%9a%e4%b9%89%e8%be%b9
|
|
126
127
|
*/
|
|
127
128
|
PolylineEdge.prototype.getEdge = function () {
|
|
129
|
+
var _a, _b;
|
|
128
130
|
var model = this.props.model;
|
|
129
|
-
var points = model.points, isAnimation = model.isAnimation, arrowConfig = model.arrowConfig;
|
|
131
|
+
var points = model.points, isAnimation = model.isAnimation, arrowConfig = model.arrowConfig, properties = model.properties;
|
|
130
132
|
var style = model.getEdgeStyle();
|
|
131
133
|
var animationStyle = model.getEdgeAnimationStyle();
|
|
132
134
|
var strokeDasharray = animationStyle.strokeDasharray, stroke = animationStyle.stroke, strokeDashoffset = animationStyle.strokeDashoffset, animationName = animationStyle.animationName, animationDuration = animationStyle.animationDuration, animationIterationCount = animationStyle.animationIterationCount, animationTimingFunction = animationStyle.animationTimingFunction, animationDirection = animationStyle.animationDirection;
|
|
133
|
-
|
|
135
|
+
// 应用通用圆角:当存在样式半径时,为折线拐点生成圆角
|
|
136
|
+
var radius = ((_b = (_a = properties === null || properties === void 0 ? void 0 : properties.radius) !== null && _a !== void 0 ? _a : style === null || style === void 0 ? void 0 : style.radius) !== null && _b !== void 0 ? _b : 0);
|
|
137
|
+
var roundedPointsStr = (function () {
|
|
138
|
+
if (!radius || radius <= 0)
|
|
139
|
+
return points;
|
|
140
|
+
var list = points2PointsList(points);
|
|
141
|
+
var rounded = generateRoundedCorners(list, radius, false);
|
|
142
|
+
return rounded.map(function (p) { return "".concat(p.x, ",").concat(p.y); }).join(' ');
|
|
143
|
+
})();
|
|
144
|
+
return (_jsx(Polyline, __assign({ points: roundedPointsStr }, style, arrowConfig, (isAnimation
|
|
134
145
|
? {
|
|
135
146
|
strokeDasharray: strokeDasharray,
|
|
136
147
|
stroke: stroke,
|
|
@@ -20,6 +20,7 @@ export declare abstract class BaseNode<P extends IProps = IProps> extends Compon
|
|
|
20
20
|
startTime?: number;
|
|
21
21
|
modelDisposer: IReactionDisposer;
|
|
22
22
|
longPressTimer?: number;
|
|
23
|
+
mouseDownPosition?: LogicFlow.Position;
|
|
23
24
|
constructor(props: IProps);
|
|
24
25
|
componentWillUnmount(): void;
|
|
25
26
|
componentDidMount(): void;
|
package/es/view/node/BaseNode.js
CHANGED
|
@@ -54,7 +54,7 @@ var __read = (this && this.__read) || function (o, n) {
|
|
|
54
54
|
import { jsx as _jsx, jsxs as _jsxs } from "preact/jsx-runtime";
|
|
55
55
|
import { Component } from 'preact/compat';
|
|
56
56
|
import { reaction } from 'mobx';
|
|
57
|
-
import { map } from 'lodash-es';
|
|
57
|
+
import { map, isFunction, isNil } from 'lodash-es';
|
|
58
58
|
import Anchor from '../Anchor';
|
|
59
59
|
import { BaseText } from '../text';
|
|
60
60
|
import { ElementState, EventType, TextMode } from '../../constant';
|
|
@@ -86,13 +86,16 @@ var BaseNode = /** @class */ (function (_super) {
|
|
|
86
86
|
var event = _a.event;
|
|
87
87
|
var _f = _this.props, model = _f.model, graphModel = _f.graphModel;
|
|
88
88
|
var _g = graphModel.editConfigModel, stopMoveGraph = _g.stopMoveGraph, autoExpand = _g.autoExpand, snapGrid = _g.snapGrid, transformModel = graphModel.transformModel, selectNodes = graphModel.selectNodes, width = graphModel.width, height = graphModel.height, gridSize = graphModel.gridSize;
|
|
89
|
-
model.isDragging = true;
|
|
90
89
|
var _h = event, clientX = _h.clientX, clientY = _h.clientY;
|
|
91
|
-
var _j =
|
|
90
|
+
var _j = _this.mouseDownPosition, mouseDownX = _j.x, mouseDownY = _j.y;
|
|
91
|
+
if (clientX - mouseDownX > gridSize || clientY - mouseDownY > gridSize) {
|
|
92
|
+
model.isDragging = true;
|
|
93
|
+
}
|
|
94
|
+
var _k = graphModel.getPointByClient({
|
|
92
95
|
x: clientX,
|
|
93
96
|
y: clientY,
|
|
94
|
-
}).canvasOverlayPosition, x =
|
|
95
|
-
var
|
|
97
|
+
}).canvasOverlayPosition, x = _k.x, y = _k.y;
|
|
98
|
+
var _l = __read(transformModel.CanvasPointToHtmlPoint([x, y]), 2), x1 = _l[0], y1 = _l[1];
|
|
96
99
|
// 1. 考虑画布被缩放
|
|
97
100
|
// 2. 考虑鼠标位置不再节点中心
|
|
98
101
|
x = x + ((_c = (_b = _this.moveOffset) === null || _b === void 0 ? void 0 : _b.dx) !== null && _c !== void 0 ? _c : 0);
|
|
@@ -110,14 +113,14 @@ var BaseNode = /** @class */ (function (_super) {
|
|
|
110
113
|
return;
|
|
111
114
|
}
|
|
112
115
|
// 取节点左上角和右下角,计算节点移动是否超出范围
|
|
113
|
-
var
|
|
116
|
+
var _m = __read(transformModel.CanvasPointToHtmlPoint([
|
|
114
117
|
x - model.width / 2,
|
|
115
118
|
y - model.height / 2,
|
|
116
|
-
]), 2), leftTopX =
|
|
117
|
-
var
|
|
119
|
+
]), 2), leftTopX = _m[0], leftTopY = _m[1];
|
|
120
|
+
var _o = __read(transformModel.CanvasPointToHtmlPoint([
|
|
118
121
|
x + model.width / 2,
|
|
119
122
|
y + model.height / 2,
|
|
120
|
-
]), 2), rightBottomX =
|
|
123
|
+
]), 2), rightBottomX = _o[0], rightBottomY = _o[1];
|
|
121
124
|
var size = Math.max(gridSize, 20);
|
|
122
125
|
var nearBoundary = [];
|
|
123
126
|
if (leftTopX < 0) {
|
|
@@ -184,7 +187,7 @@ var BaseNode = /** @class */ (function (_super) {
|
|
|
184
187
|
var _a = _this.props, model = _a.model, graphModel = _a.graphModel;
|
|
185
188
|
// 这里会有一种极端情况:当网格大小是1或者关闭网格吸附时,用触摸板点击节点会触发拖拽事件导致节点无法选中
|
|
186
189
|
// 当触摸板点击节点时,为了防止误触发拖拽导致节点无法选中,允许在非拖拽状态且时间间隔小于100ms时触发点击事件
|
|
187
|
-
if (!isDragging && timeInterval >
|
|
190
|
+
if (!isDragging && timeInterval > 300)
|
|
188
191
|
return;
|
|
189
192
|
if (!isDragging) {
|
|
190
193
|
_this.onDragEnd();
|
|
@@ -239,6 +242,14 @@ var BaseNode = /** @class */ (function (_super) {
|
|
|
239
242
|
else {
|
|
240
243
|
graphModel.eventCenter.emit(EventType.ELEMENT_CLICK, eventOptions);
|
|
241
244
|
graphModel.eventCenter.emit(EventType.NODE_CLICK, eventOptions);
|
|
245
|
+
// 复制粘贴后会出现点击节点时,节点会失去焦点的问题,这里手动让节点获焦以解决这个问题
|
|
246
|
+
var el_1 = e.currentTarget;
|
|
247
|
+
var rAF = !isNil(window) && isFunction(window.requestAnimationFrame)
|
|
248
|
+
? window.requestAnimationFrame.bind(window)
|
|
249
|
+
: function (fn) { return setTimeout(fn, 0); };
|
|
250
|
+
rAF(function () {
|
|
251
|
+
el_1.focus();
|
|
252
|
+
});
|
|
242
253
|
}
|
|
243
254
|
};
|
|
244
255
|
_this.handleContextMenu = function (ev) {
|
|
@@ -267,6 +278,7 @@ var BaseNode = /** @class */ (function (_super) {
|
|
|
267
278
|
};
|
|
268
279
|
_this.handleMouseDown = function (ev) {
|
|
269
280
|
var _a = _this.props, model = _a.model, graphModel = _a.graphModel;
|
|
281
|
+
_this.mouseDownPosition = { x: ev.clientX, y: ev.clientY };
|
|
270
282
|
_this.startTime = new Date().getTime();
|
|
271
283
|
var editConfigModel = graphModel.editConfigModel;
|
|
272
284
|
if (editConfigModel.adjustNodePosition && model.draggable) {
|
|
@@ -454,7 +466,7 @@ var BaseNode = /** @class */ (function (_super) {
|
|
|
454
466
|
var _b = graphModel.editConfigModel, hideAnchors = _b.hideAnchors, adjustNodePosition = _b.adjustNodePosition, allowRotate = _b.allowRotate, allowResize = _b.allowResize, gridSize = graphModel.gridSize, SCALE_X = graphModel.transformModel.SCALE_X;
|
|
455
467
|
var isHitable = model.isHitable, draggable = model.draggable, transform = model.transform;
|
|
456
468
|
var _c = model.getOuterGAttributes(), _d = _c.className, className = _d === void 0 ? '' : _d, restAttributes = __rest(_c, ["className"]);
|
|
457
|
-
var nodeShapeInner = (_jsxs("g", { className: "lf-node-content", children: [_jsxs("g", { transform: transform, children: [this.getShape(), this.getText(),
|
|
469
|
+
var nodeShapeInner = (_jsxs("g", { className: "lf-node-content", children: [_jsxs("g", { transform: transform, children: [this.getShape(), this.getText(), allowResize && this.getResizeControl(), allowRotate && this.getRotateControl()] }), !hideAnchors && this.getAnchors()] }));
|
|
458
470
|
var nodeShape;
|
|
459
471
|
if (!isHitable) {
|
|
460
472
|
nodeShape = (_jsx("g", __assign({ className: "".concat(this.getStateClassName(), " ").concat(className) }, restAttributes, { children: nodeShapeInner })));
|