@logicflow/core 2.2.0-alpha.1 → 2.2.0-alpha.3
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/.turbo/turbo-build$colon$dev.log +2 -57
- package/.turbo/turbo-build.log +6 -6
- package/CHANGELOG.md +12 -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/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 +9 -2
- package/es/model/GraphModel.js +17 -6
- package/es/model/TransformModel.js +9 -9
- package/es/model/edge/BaseEdgeModel.js +7 -2
- package/es/model/edge/PolylineEdgeModel.d.ts +6 -0
- package/es/model/edge/PolylineEdgeModel.js +23 -1
- package/es/model/node/BaseNodeModel.d.ts +12 -1
- package/es/model/node/BaseNodeModel.js +6 -1
- 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 +1 -1
- 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 +6 -5
- package/es/util/edge.d.ts +1 -1
- package/es/util/edge.js +2 -2
- 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/Control.d.ts +5 -0
- package/es/view/Control.js +44 -57
- package/es/view/edge/PolylineEdge.js +13 -2
- package/es/view/node/BaseNode.d.ts +1 -0
- package/es/view/node/BaseNode.js +14 -10
- package/es/view/node/HtmlNode.js +2 -4
- 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 +17 -16
- 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/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 +9 -2
- package/lib/model/GraphModel.js +18 -7
- package/lib/model/TransformModel.js +9 -9
- package/lib/model/edge/BaseEdgeModel.js +7 -2
- package/lib/model/edge/PolylineEdgeModel.d.ts +6 -0
- package/lib/model/edge/PolylineEdgeModel.js +23 -1
- package/lib/model/node/BaseNodeModel.d.ts +12 -1
- package/lib/model/node/BaseNodeModel.js +6 -1
- 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 +1 -1
- 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 +6 -5
- package/lib/util/edge.d.ts +1 -1
- package/lib/util/edge.js +2 -2
- 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/Control.d.ts +5 -0
- package/lib/view/Control.js +44 -57
- package/lib/view/edge/PolylineEdge.js +13 -2
- package/lib/view/node/BaseNode.d.ts +1 -0
- package/lib/view/node/BaseNode.js +14 -10
- package/lib/view/node/HtmlNode.js +1 -3
- 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 +17 -16
- 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 +1 -1
- package/src/LogicFlow.tsx +10 -0
- package/src/constant/index.ts +2 -2
- package/src/constant/theme.ts +708 -0
- package/src/model/GraphModel.ts +19 -7
- package/src/model/TransformModel.ts +9 -9
- package/src/model/edge/BaseEdgeModel.ts +10 -2
- package/src/model/edge/PolylineEdgeModel.ts +26 -1
- package/src/model/node/BaseNodeModel.ts +9 -1
- package/src/model/node/HtmlNodeModel.ts +14 -0
- package/src/model/node/PolygonNodeModel.ts +2 -0
- package/src/options.ts +1 -1
- package/src/style/index.less +3 -2
- package/src/style/raw.ts +3 -2
- package/src/tool/MultipleSelectTool.tsx +6 -5
- package/src/util/edge.ts +2 -1
- package/src/util/geometry.ts +99 -0
- package/src/util/theme.ts +12 -303
- package/src/view/Control.tsx +61 -63
- package/src/view/edge/PolylineEdge.tsx +14 -2
- package/src/view/node/BaseNode.tsx +8 -3
- package/src/view/node/HtmlNode.tsx +27 -10
- package/src/view/overlay/Grid.tsx +187 -30
- package/src/view/overlay/OutlineOverlay.tsx +35 -47
- package/src/view/overlay/gridConfig.ts +103 -0
- package/src/view/shape/Polygon.tsx +12 -49
- package/stats.html +1 -1
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/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()] }));
|
|
@@ -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
|
@@ -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();
|
|
@@ -267,6 +270,7 @@ var BaseNode = /** @class */ (function (_super) {
|
|
|
267
270
|
};
|
|
268
271
|
_this.handleMouseDown = function (ev) {
|
|
269
272
|
var _a = _this.props, model = _a.model, graphModel = _a.graphModel;
|
|
273
|
+
_this.mouseDownPosition = { x: ev.clientX, y: ev.clientY };
|
|
270
274
|
_this.startTime = new Date().getTime();
|
|
271
275
|
var editConfigModel = graphModel.editConfigModel;
|
|
272
276
|
if (editConfigModel.adjustNodePosition && model.draggable) {
|
|
@@ -454,7 +458,7 @@ var BaseNode = /** @class */ (function (_super) {
|
|
|
454
458
|
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
459
|
var isHitable = model.isHitable, draggable = model.draggable, transform = model.transform;
|
|
456
460
|
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(),
|
|
461
|
+
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
462
|
var nodeShape;
|
|
459
463
|
if (!isHitable) {
|
|
460
464
|
nodeShape = (_jsx("g", __assign({ className: "".concat(this.getStateClassName(), " ").concat(className) }, restAttributes, { children: nodeShapeInner })));
|
package/es/view/node/HtmlNode.js
CHANGED
|
@@ -49,7 +49,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
49
49
|
}
|
|
50
50
|
return to.concat(ar || Array.prototype.slice.call(from));
|
|
51
51
|
};
|
|
52
|
-
import { jsx as _jsx } from "preact/jsx-runtime";
|
|
52
|
+
import { jsx as _jsx, jsxs as _jsxs } from "preact/jsx-runtime";
|
|
53
53
|
import { createRef } from 'preact/compat';
|
|
54
54
|
import BaseNode from './BaseNode';
|
|
55
55
|
var HtmlNode = /** @class */ (function (_super) {
|
|
@@ -99,13 +99,11 @@ var HtmlNode = /** @class */ (function (_super) {
|
|
|
99
99
|
return true;
|
|
100
100
|
};
|
|
101
101
|
HtmlNode.prototype.componentDidMount = function () {
|
|
102
|
-
// console.log('HtmlNode --->>> componentDidMount - 初始化内容')
|
|
103
102
|
if (this.shouldUpdate() && this.rootEl) {
|
|
104
103
|
this.setHtml(this.rootEl);
|
|
105
104
|
}
|
|
106
105
|
};
|
|
107
106
|
HtmlNode.prototype.componentDidUpdate = function () {
|
|
108
|
-
// console.log('HtmlNode --->>> componentDidUpdate - 更新节点内容')
|
|
109
107
|
// DONE: 将 componentDidMount 和 componentDidUpdate 区分开,如果写在一次,渲染 React 组件会重复初始化,消耗过多资源
|
|
110
108
|
// 为了保证历史兼容性,先将默认 HTML 节点的 setHtml 和 confirmUpdate 保持一直,用户可通过自定义的方式重新定义
|
|
111
109
|
if (this.shouldUpdate() && this.rootEl) {
|
|
@@ -121,7 +119,7 @@ var HtmlNode = /** @class */ (function (_super) {
|
|
|
121
119
|
var x = model.x, y = model.y, height = model.height, width = model.width;
|
|
122
120
|
var style = model.getNodeStyle();
|
|
123
121
|
this.currentProperties = JSON.stringify(model.properties);
|
|
124
|
-
return (_jsx("foreignObject", __assign({}, style, { x: x - width / 2, y: y - height / 2, width: width, height: height, ref: this.ref })));
|
|
122
|
+
return (_jsxs("g", { children: [style.shadow && (_jsx("defs", { children: _jsx("filter", { id: "shadow", x: "-50%", y: "-50%", width: "200%", height: "200%", children: _jsx("feDropShadow", __assign({}, style.shadow)) }) })), _jsx("rect", __assign({ x: x - width / 2, y: y - height / 2, width: width, height: height, rx: style.radius, ry: style.radius }, style, { filter: "url(#shadow)" })), _jsx("foreignObject", __assign({}, style, { x: x - width / 2, y: y - height / 2, width: width, height: height, ref: this.ref }))] }));
|
|
125
123
|
};
|
|
126
124
|
return HtmlNode;
|
|
127
125
|
}(BaseNode));
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Component } from 'preact/compat';
|
|
2
|
+
import { MajorBoldConfig } from './gridConfig';
|
|
2
3
|
import { GraphModel } from '../../model';
|
|
3
4
|
type IProps = {
|
|
4
5
|
graphModel: GraphModel;
|
|
@@ -8,6 +9,10 @@ export declare class Grid extends Component<IProps> {
|
|
|
8
9
|
readonly id: string;
|
|
9
10
|
constructor(props: IProps);
|
|
10
11
|
renderDot(): import("preact/compat").JSX.Element;
|
|
12
|
+
private getDashArrayForSize;
|
|
13
|
+
private getPeriod;
|
|
14
|
+
private getBoldStrokeWidth;
|
|
15
|
+
private renderMeshEdgeLines;
|
|
11
16
|
renderMesh(): import("preact/compat").JSX.Element;
|
|
12
17
|
render(): import("preact/compat").JSX.Element;
|
|
13
18
|
}
|
|
@@ -39,8 +44,14 @@ export declare namespace Grid {
|
|
|
39
44
|
*/
|
|
40
45
|
thickness?: number;
|
|
41
46
|
};
|
|
47
|
+
/**
|
|
48
|
+
* 行为配置:支持 boolean 或高级对象
|
|
49
|
+
* - false: 禁用特殊样式,opacity=1,无加粗,无虚线
|
|
50
|
+
* - true: 启用默认样式,opacity=0.75,每第5个加粗/实线,虚线动态计算
|
|
51
|
+
* - object: 高级配置,详见 MajorBoldConfig
|
|
52
|
+
*/
|
|
53
|
+
majorBold?: boolean | MajorBoldConfig;
|
|
42
54
|
};
|
|
43
|
-
const defaultProps: GridOptions;
|
|
44
55
|
function getGridOptions(options: number | boolean | GridOptions): GridOptions;
|
|
45
56
|
}
|
|
46
57
|
export {};
|