@logicflow/core 2.2.0-alpha.2 → 2.2.0-alpha.4
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 -2
- package/.turbo/turbo-build.log +6 -6
- package/CHANGELOG.md +16 -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 +45 -12
- 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 +10 -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 +23 -10
- 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 +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 +46 -13
- 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 +10 -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 +23 -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 +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/EditConfigModel.ts +4 -4
- package/src/model/GraphModel.ts +48 -16
- 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 +12 -5
- 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 +13 -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 +18 -3
- package/src/view/node/HtmlNode.tsx +27 -10
- package/src/view/overlay/CanvasOverlay.tsx +4 -2
- 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/lib/util/theme.d.ts
CHANGED
|
@@ -1,69 +1,6 @@
|
|
|
1
1
|
import LogicFlow from '../LogicFlow';
|
|
2
|
-
export declare const
|
|
3
|
-
export declare const radiusMode: any;
|
|
4
|
-
export declare const darkMode: any;
|
|
5
|
-
export declare const colorfulMode: any;
|
|
6
|
-
export declare const themeModeMap: {
|
|
7
|
-
colorful: any;
|
|
8
|
-
dark: any;
|
|
9
|
-
radius: any;
|
|
10
|
-
default: LogicFlow.Theme;
|
|
11
|
-
};
|
|
12
|
-
export declare const darkBackground: {
|
|
13
|
-
background: string;
|
|
14
|
-
};
|
|
15
|
-
export declare const colorfulBackground: {
|
|
16
|
-
background: string;
|
|
17
|
-
};
|
|
18
|
-
export declare const defaultBackground: {
|
|
19
|
-
background: string;
|
|
20
|
-
};
|
|
21
|
-
export declare const backgroundModeMap: {
|
|
22
|
-
colorful: {
|
|
23
|
-
background: string;
|
|
24
|
-
};
|
|
25
|
-
dark: {
|
|
26
|
-
background: string;
|
|
27
|
-
};
|
|
28
|
-
radius: {
|
|
29
|
-
background: string;
|
|
30
|
-
};
|
|
31
|
-
default: {
|
|
32
|
-
background: string;
|
|
33
|
-
};
|
|
34
|
-
};
|
|
35
|
-
export declare const darkGrid: {
|
|
36
|
-
color: string;
|
|
37
|
-
thickness: number;
|
|
38
|
-
};
|
|
39
|
-
export declare const colorfulGrid: {
|
|
40
|
-
color: string;
|
|
41
|
-
thickness: number;
|
|
42
|
-
};
|
|
43
|
-
export declare const defaultGrid: {
|
|
44
|
-
color: string;
|
|
45
|
-
thickness: number;
|
|
46
|
-
};
|
|
47
|
-
export declare const gridModeMap: {
|
|
48
|
-
colorful: {
|
|
49
|
-
color: string;
|
|
50
|
-
thickness: number;
|
|
51
|
-
};
|
|
52
|
-
dark: {
|
|
53
|
-
color: string;
|
|
54
|
-
thickness: number;
|
|
55
|
-
};
|
|
56
|
-
radius: {
|
|
57
|
-
color: string;
|
|
58
|
-
thickness: number;
|
|
59
|
-
};
|
|
60
|
-
default: {
|
|
61
|
-
color: string;
|
|
62
|
-
thickness: number;
|
|
63
|
-
};
|
|
64
|
-
};
|
|
65
|
-
export declare const setupTheme: (customTheme?: Partial<LogicFlow.Theme>, themeMode?: 'radius' | 'dark' | 'colorful' | 'default' | string) => LogicFlow.Theme;
|
|
2
|
+
export declare const setupTheme: (customTheme?: Partial<LogicFlow.Theme>, themeMode?: LogicFlow.ThemeMode | string) => LogicFlow.Theme;
|
|
66
3
|
export declare const addThemeMode: (themeMode: string, style: Partial<LogicFlow.Theme>) => void;
|
|
67
4
|
export declare const removeThemeMode: (themeMode: string) => void;
|
|
68
5
|
export declare const clearThemeMode: () => void;
|
|
69
|
-
export declare const updateTheme: (customTheme?: Partial<LogicFlow.Theme>, themeMode?:
|
|
6
|
+
export declare const updateTheme: (customTheme?: Partial<LogicFlow.Theme>, themeMode?: LogicFlow.ThemeMode | string) => LogicFlow.Theme;
|
package/lib/util/theme.js
CHANGED
|
@@ -1,289 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.updateTheme = exports.clearThemeMode = exports.removeThemeMode = exports.addThemeMode = exports.setupTheme =
|
|
3
|
+
exports.updateTheme = exports.clearThemeMode = exports.removeThemeMode = exports.addThemeMode = exports.setupTheme = void 0;
|
|
4
4
|
var lodash_es_1 = require("lodash-es");
|
|
5
|
-
|
|
6
|
-
baseNode: {
|
|
7
|
-
fill: '#fff',
|
|
8
|
-
stroke: '#000',
|
|
9
|
-
strokeWidth: 2,
|
|
10
|
-
},
|
|
11
|
-
baseEdge: {
|
|
12
|
-
stroke: '#000',
|
|
13
|
-
strokeWidth: 2,
|
|
14
|
-
},
|
|
15
|
-
rect: {},
|
|
16
|
-
circle: {},
|
|
17
|
-
diamond: {},
|
|
18
|
-
ellipse: {},
|
|
19
|
-
polygon: {},
|
|
20
|
-
text: {
|
|
21
|
-
color: '#000',
|
|
22
|
-
stroke: 'none',
|
|
23
|
-
fontSize: 12,
|
|
24
|
-
background: {
|
|
25
|
-
fill: 'transparent',
|
|
26
|
-
},
|
|
27
|
-
},
|
|
28
|
-
anchor: {
|
|
29
|
-
stroke: '#000',
|
|
30
|
-
fill: '#fff',
|
|
31
|
-
r: 4,
|
|
32
|
-
hover: {
|
|
33
|
-
r: 10,
|
|
34
|
-
fill: '#949494',
|
|
35
|
-
fillOpacity: 0.5,
|
|
36
|
-
stroke: '#949494',
|
|
37
|
-
},
|
|
38
|
-
},
|
|
39
|
-
anchorLine: {
|
|
40
|
-
stroke: '#000',
|
|
41
|
-
strokeWidth: 2,
|
|
42
|
-
strokeDasharray: '3,2',
|
|
43
|
-
},
|
|
44
|
-
nodeText: {
|
|
45
|
-
color: '#000',
|
|
46
|
-
overflowMode: 'default',
|
|
47
|
-
fontSize: 12,
|
|
48
|
-
lineHeight: 1.2,
|
|
49
|
-
},
|
|
50
|
-
edgeText: {
|
|
51
|
-
textWidth: 100,
|
|
52
|
-
overflowMode: 'default',
|
|
53
|
-
fontSize: 12,
|
|
54
|
-
background: {
|
|
55
|
-
fill: '#fff',
|
|
56
|
-
},
|
|
57
|
-
},
|
|
58
|
-
line: {},
|
|
59
|
-
polyline: {},
|
|
60
|
-
bezier: {
|
|
61
|
-
fill: 'none',
|
|
62
|
-
adjustLine: {
|
|
63
|
-
stroke: '#949494',
|
|
64
|
-
},
|
|
65
|
-
adjustAnchor: {
|
|
66
|
-
r: 4,
|
|
67
|
-
fill: '#949494',
|
|
68
|
-
fillOpacity: 1,
|
|
69
|
-
stroke: '#949494',
|
|
70
|
-
},
|
|
71
|
-
},
|
|
72
|
-
arrow: {
|
|
73
|
-
offset: 10,
|
|
74
|
-
verticalLength: 5, // 箭头垂直于边的距离
|
|
75
|
-
},
|
|
76
|
-
snapline: {
|
|
77
|
-
stroke: '#949494',
|
|
78
|
-
strokeWidth: 1,
|
|
79
|
-
},
|
|
80
|
-
edgeAdjust: {
|
|
81
|
-
r: 4,
|
|
82
|
-
fill: '#fff',
|
|
83
|
-
stroke: '#949494',
|
|
84
|
-
strokeWidth: 2,
|
|
85
|
-
},
|
|
86
|
-
outline: {
|
|
87
|
-
fill: 'transparent',
|
|
88
|
-
stroke: '#949494',
|
|
89
|
-
strokeDasharray: '3,3',
|
|
90
|
-
hover: {
|
|
91
|
-
stroke: '#949494',
|
|
92
|
-
},
|
|
93
|
-
},
|
|
94
|
-
edgeAnimation: {
|
|
95
|
-
stroke: 'red',
|
|
96
|
-
strokeDasharray: '10,10',
|
|
97
|
-
strokeDashoffset: '100%',
|
|
98
|
-
animationName: 'lf_animate_dash',
|
|
99
|
-
animationDuration: '20s',
|
|
100
|
-
animationIterationCount: 'infinite',
|
|
101
|
-
animationTimingFunction: 'linear',
|
|
102
|
-
animationDirection: 'normal',
|
|
103
|
-
},
|
|
104
|
-
rotateControl: {
|
|
105
|
-
stroke: '#000',
|
|
106
|
-
fill: '#fff',
|
|
107
|
-
strokeWidth: 1.5,
|
|
108
|
-
},
|
|
109
|
-
resizeControl: {
|
|
110
|
-
width: 7,
|
|
111
|
-
height: 7,
|
|
112
|
-
fill: '#fff',
|
|
113
|
-
stroke: '#000',
|
|
114
|
-
},
|
|
115
|
-
resizeOutline: {
|
|
116
|
-
fill: 'none',
|
|
117
|
-
stroke: 'transparent', // 矩形默认不显示调整边框
|
|
118
|
-
strokeWidth: 1,
|
|
119
|
-
strokeDasharray: '3,3',
|
|
120
|
-
},
|
|
121
|
-
};
|
|
122
|
-
exports.radiusMode = {
|
|
123
|
-
rect: { radius: 8 },
|
|
124
|
-
diamond: { radius: 8 },
|
|
125
|
-
polygon: { radius: 8 },
|
|
126
|
-
polyline: { radius: 8 },
|
|
127
|
-
arrow: {
|
|
128
|
-
strokeLinecap: 'round',
|
|
129
|
-
strokeLinejoin: 'round',
|
|
130
|
-
offset: 10,
|
|
131
|
-
verticalLength: 5, // 箭头垂直于边的距离
|
|
132
|
-
},
|
|
133
|
-
snapline: {
|
|
134
|
-
strokeLinecap: 'round',
|
|
135
|
-
strokeLinejoin: 'round',
|
|
136
|
-
stroke: '#949494',
|
|
137
|
-
strokeWidth: 1,
|
|
138
|
-
},
|
|
139
|
-
outline: {
|
|
140
|
-
radius: 8,
|
|
141
|
-
fill: 'transparent',
|
|
142
|
-
stroke: '#949494',
|
|
143
|
-
strokeDasharray: '3,3',
|
|
144
|
-
hover: {
|
|
145
|
-
stroke: '#949494',
|
|
146
|
-
},
|
|
147
|
-
},
|
|
148
|
-
resizeOutline: {
|
|
149
|
-
radius: 8,
|
|
150
|
-
fill: 'none',
|
|
151
|
-
stroke: 'transparent', // 矩形默认不显示调整边框
|
|
152
|
-
strokeWidth: 1,
|
|
153
|
-
strokeDasharray: '3,3',
|
|
154
|
-
},
|
|
155
|
-
};
|
|
156
|
-
exports.darkMode = {
|
|
157
|
-
baseNode: {
|
|
158
|
-
fill: '#23272e',
|
|
159
|
-
stroke: '#fefeff',
|
|
160
|
-
},
|
|
161
|
-
baseEdge: {
|
|
162
|
-
stroke: '#fefeff',
|
|
163
|
-
},
|
|
164
|
-
rect: { radius: 8 },
|
|
165
|
-
diamond: { radius: 8 },
|
|
166
|
-
polygon: { radius: 8 },
|
|
167
|
-
polyline: { radius: 8 },
|
|
168
|
-
nodeText: {
|
|
169
|
-
color: '#fefeff',
|
|
170
|
-
overflowMode: 'default',
|
|
171
|
-
fontSize: 12,
|
|
172
|
-
lineHeight: 1.2,
|
|
173
|
-
},
|
|
174
|
-
arrow: {
|
|
175
|
-
strokeLinecap: 'round',
|
|
176
|
-
strokeLinejoin: 'round',
|
|
177
|
-
offset: 10,
|
|
178
|
-
verticalLength: 5, // 箭头垂直于边的距离
|
|
179
|
-
},
|
|
180
|
-
snapline: {
|
|
181
|
-
strokeLinecap: 'round',
|
|
182
|
-
strokeLinejoin: 'round',
|
|
183
|
-
stroke: '#949494',
|
|
184
|
-
strokeWidth: 1,
|
|
185
|
-
},
|
|
186
|
-
outline: {
|
|
187
|
-
radius: 8,
|
|
188
|
-
fill: 'transparent',
|
|
189
|
-
stroke: '#949494',
|
|
190
|
-
strokeDasharray: '3,3',
|
|
191
|
-
hover: {
|
|
192
|
-
stroke: '#949494',
|
|
193
|
-
},
|
|
194
|
-
},
|
|
195
|
-
resizeOutline: {
|
|
196
|
-
radius: 8,
|
|
197
|
-
fill: 'none',
|
|
198
|
-
stroke: 'transparent', // 矩形默认不显示调整边框
|
|
199
|
-
strokeWidth: 1,
|
|
200
|
-
strokeDasharray: '3,3',
|
|
201
|
-
},
|
|
202
|
-
};
|
|
203
|
-
exports.colorfulMode = {
|
|
204
|
-
rect: { fill: '#72CBFF', stroke: '#3ABDF9', radius: 8 },
|
|
205
|
-
circle: { fill: '#FFE075', stroke: '#F9CE3A', radius: 8 },
|
|
206
|
-
ellipse: { fill: '#FFA8A8', stroke: '#FF6B66', radius: 8 },
|
|
207
|
-
text: { fill: '#72CBFF', radius: 8 },
|
|
208
|
-
diamond: { fill: '#96F7AF', stroke: '#40EF7E', radius: 8 },
|
|
209
|
-
polygon: { fill: '#E0A8FF', stroke: '#C271FF', radius: 8 },
|
|
210
|
-
polyline: { radius: 8 },
|
|
211
|
-
arrow: {
|
|
212
|
-
strokeLinecap: 'round',
|
|
213
|
-
strokeLinejoin: 'round',
|
|
214
|
-
offset: 10,
|
|
215
|
-
verticalLength: 5, // 箭头垂直于边的距离
|
|
216
|
-
},
|
|
217
|
-
snapline: {
|
|
218
|
-
strokeLinecap: 'round',
|
|
219
|
-
strokeLinejoin: 'round',
|
|
220
|
-
stroke: '#949494',
|
|
221
|
-
strokeWidth: 1,
|
|
222
|
-
},
|
|
223
|
-
outline: {
|
|
224
|
-
radius: 8,
|
|
225
|
-
fill: 'transparent',
|
|
226
|
-
stroke: '#949494',
|
|
227
|
-
strokeDasharray: '3,3',
|
|
228
|
-
hover: {
|
|
229
|
-
stroke: '#949494',
|
|
230
|
-
},
|
|
231
|
-
},
|
|
232
|
-
resizeOutline: {
|
|
233
|
-
radius: 8,
|
|
234
|
-
fill: 'none',
|
|
235
|
-
stroke: 'transparent', // 矩形默认不显示调整边框
|
|
236
|
-
strokeWidth: 1,
|
|
237
|
-
strokeDasharray: '3,3',
|
|
238
|
-
},
|
|
239
|
-
};
|
|
240
|
-
exports.themeModeMap = {
|
|
241
|
-
colorful: exports.colorfulMode,
|
|
242
|
-
dark: exports.darkMode,
|
|
243
|
-
radius: exports.radiusMode,
|
|
244
|
-
default: exports.defaultTheme,
|
|
245
|
-
};
|
|
246
|
-
// 不同主题的背景色
|
|
247
|
-
exports.darkBackground = {
|
|
248
|
-
background: '#23272e',
|
|
249
|
-
};
|
|
250
|
-
exports.colorfulBackground = {
|
|
251
|
-
background: '#fefeff',
|
|
252
|
-
};
|
|
253
|
-
exports.defaultBackground = {
|
|
254
|
-
background: '#ffffff',
|
|
255
|
-
};
|
|
256
|
-
exports.backgroundModeMap = {
|
|
257
|
-
colorful: exports.colorfulBackground,
|
|
258
|
-
dark: exports.darkBackground,
|
|
259
|
-
radius: exports.defaultBackground,
|
|
260
|
-
default: exports.defaultBackground,
|
|
261
|
-
};
|
|
262
|
-
// 不同主题的网格样式
|
|
263
|
-
exports.darkGrid = {
|
|
264
|
-
color: '#66676a',
|
|
265
|
-
thickness: 1,
|
|
266
|
-
};
|
|
267
|
-
exports.colorfulGrid = {
|
|
268
|
-
color: '#dadada',
|
|
269
|
-
thickness: 1,
|
|
270
|
-
};
|
|
271
|
-
exports.defaultGrid = {
|
|
272
|
-
color: '#acacac',
|
|
273
|
-
thickness: 1,
|
|
274
|
-
};
|
|
275
|
-
exports.gridModeMap = {
|
|
276
|
-
colorful: exports.colorfulGrid,
|
|
277
|
-
dark: exports.darkGrid,
|
|
278
|
-
radius: exports.defaultGrid,
|
|
279
|
-
default: exports.defaultGrid,
|
|
280
|
-
};
|
|
5
|
+
var theme_1 = require("../constant/theme");
|
|
281
6
|
/* 主题(全局样式)相关工具方法 */
|
|
282
7
|
var setupTheme = function (customTheme, themeMode) {
|
|
283
|
-
var theme = (0, lodash_es_1.cloneDeep)(
|
|
284
|
-
|
|
285
|
-
theme = (0, lodash_es_1.merge)(theme, exports.themeModeMap[themeMode]);
|
|
286
|
-
}
|
|
8
|
+
var theme = (0, lodash_es_1.cloneDeep)(theme_1.themeModeMap[themeMode || 'default']) ||
|
|
9
|
+
(0, lodash_es_1.cloneDeep)(theme_1.themeModeMap.default);
|
|
287
10
|
if (customTheme) {
|
|
288
11
|
/**
|
|
289
12
|
* 为了不让默认样式被覆盖,使用 merge 方法
|
|
@@ -318,31 +41,31 @@ var setupTheme = function (customTheme, themeMode) {
|
|
|
318
41
|
};
|
|
319
42
|
exports.setupTheme = setupTheme;
|
|
320
43
|
var addThemeMode = function (themeMode, style) {
|
|
321
|
-
if (
|
|
44
|
+
if (theme_1.themeModeMap[themeMode]) {
|
|
322
45
|
console.warn("theme mode ".concat(themeMode, " already exists"));
|
|
323
46
|
return;
|
|
324
47
|
}
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
48
|
+
theme_1.themeModeMap[themeMode] = style;
|
|
49
|
+
theme_1.backgroundModeMap[themeMode] = style.background || theme_1.defaultBackground;
|
|
50
|
+
theme_1.gridModeMap[themeMode] = style.grid || theme_1.defaultGrid;
|
|
328
51
|
};
|
|
329
52
|
exports.addThemeMode = addThemeMode;
|
|
330
53
|
var removeThemeMode = function (themeMode) {
|
|
331
|
-
delete
|
|
332
|
-
delete
|
|
333
|
-
delete
|
|
54
|
+
delete theme_1.themeModeMap[themeMode];
|
|
55
|
+
delete theme_1.backgroundModeMap[themeMode];
|
|
56
|
+
delete theme_1.gridModeMap[themeMode];
|
|
334
57
|
};
|
|
335
58
|
exports.removeThemeMode = removeThemeMode;
|
|
336
59
|
var clearThemeMode = function () {
|
|
337
60
|
var resetTheme = {
|
|
338
61
|
colorful: {},
|
|
339
62
|
dark: {},
|
|
340
|
-
|
|
63
|
+
retro: {},
|
|
341
64
|
default: {},
|
|
342
65
|
};
|
|
343
|
-
(0, lodash_es_1.assign)(
|
|
344
|
-
(0, lodash_es_1.assign)(
|
|
345
|
-
(0, lodash_es_1.assign)(
|
|
66
|
+
(0, lodash_es_1.assign)(theme_1.themeModeMap, resetTheme);
|
|
67
|
+
(0, lodash_es_1.assign)(theme_1.backgroundModeMap, resetTheme);
|
|
68
|
+
(0, lodash_es_1.assign)(theme_1.gridModeMap, resetTheme);
|
|
346
69
|
};
|
|
347
70
|
exports.clearThemeMode = clearThemeMode;
|
|
348
71
|
/* 更新 theme 方法 */
|
package/lib/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/lib/view/Control.js
CHANGED
|
@@ -246,61 +246,6 @@ var ResizeControl = /** @class */ (function (_super) {
|
|
|
246
246
|
_this.dragHandler.cancelDrag();
|
|
247
247
|
},
|
|
248
248
|
});
|
|
249
|
-
// 1. 计算当前 Control 的一些信息,
|
|
250
|
-
// const {
|
|
251
|
-
// r, // circle
|
|
252
|
-
// rx, // ellipse/diamond
|
|
253
|
-
// ry,
|
|
254
|
-
// width, // rect/html
|
|
255
|
-
// height,
|
|
256
|
-
// PCTResizeInfo,
|
|
257
|
-
//
|
|
258
|
-
// minWidth,
|
|
259
|
-
// minHeight,
|
|
260
|
-
// maxWidth,
|
|
261
|
-
// maxHeight,
|
|
262
|
-
// } = this.nodeModel
|
|
263
|
-
// const isFreezeWidth = minWidth === maxWidth
|
|
264
|
-
// const isFreezeHeight = minHeight === maxHeight
|
|
265
|
-
//
|
|
266
|
-
// const resizeInfo = {
|
|
267
|
-
// width: r || rx || width,
|
|
268
|
-
// height: r || ry || height,
|
|
269
|
-
// deltaX,
|
|
270
|
-
// deltaY,
|
|
271
|
-
// PCTResizeInfo,
|
|
272
|
-
// }
|
|
273
|
-
//
|
|
274
|
-
// const pct = r || (rx && ry) ? 1 / 2 : 1
|
|
275
|
-
// const nextSize = this.recalcResizeInfo(
|
|
276
|
-
// this.index,
|
|
277
|
-
// resizeInfo,
|
|
278
|
-
// pct,
|
|
279
|
-
// isFreezeWidth,
|
|
280
|
-
// isFreezeHeight,
|
|
281
|
-
// )
|
|
282
|
-
//
|
|
283
|
-
// // 限制放大缩小的最大最小范围
|
|
284
|
-
// if (
|
|
285
|
-
// nextSize.width < minWidth ||
|
|
286
|
-
// nextSize.width > maxWidth ||
|
|
287
|
-
// nextSize.height < minHeight ||
|
|
288
|
-
// nextSize.height > maxHeight
|
|
289
|
-
// ) {
|
|
290
|
-
// this.dragHandler.cancelDrag()
|
|
291
|
-
// return
|
|
292
|
-
// }
|
|
293
|
-
// // 如果限制了宽高不变,对应的 x/y 不产生位移
|
|
294
|
-
// nextSize.deltaX = isFreezeWidth ? 0 : nextSize.deltaX
|
|
295
|
-
// nextSize.deltaY = isFreezeWidth ? 0 : nextSize.deltaY
|
|
296
|
-
//
|
|
297
|
-
// const preNodeData = this.nodeModel.getData()
|
|
298
|
-
// const curNodeData = this.nodeModel.resize(nextSize)
|
|
299
|
-
//
|
|
300
|
-
// // 更新边
|
|
301
|
-
// this.updateEdgePointByAnchors()
|
|
302
|
-
// // 触发 resize 事件
|
|
303
|
-
// this.triggerResizeEvent(preNodeData, curNodeData, deltaX, deltaY, this.index, this.nodeModel)
|
|
304
249
|
};
|
|
305
250
|
_this.onDragStart = function () {
|
|
306
251
|
_this.graphModel.selectNodeById(_this.nodeModel.id);
|
|
@@ -328,6 +273,10 @@ var ResizeControl = /** @class */ (function (_super) {
|
|
|
328
273
|
// 此时拿到的 anchors 是最新的
|
|
329
274
|
_this.updateEdgePointByAnchors();
|
|
330
275
|
};
|
|
276
|
+
_this.onPointerDown = function (e) {
|
|
277
|
+
e.stopPropagation();
|
|
278
|
+
_this.dragHandler.handleMouseDown(e);
|
|
279
|
+
};
|
|
331
280
|
var index = props.index, model = props.model, graphModel = props.graphModel;
|
|
332
281
|
_this.index = index;
|
|
333
282
|
_this.nodeModel = model;
|
|
@@ -346,10 +295,46 @@ var ResizeControl = /** @class */ (function (_super) {
|
|
|
346
295
|
document.removeEventListener('keydown', this.handleKeyDown);
|
|
347
296
|
document.removeEventListener('keyup', this.handleKeyUp);
|
|
348
297
|
};
|
|
298
|
+
ResizeControl.prototype.getViewPosition = function (direction, x, y) {
|
|
299
|
+
var _a = this.props.model.getResizeControlStyle(), _b = _a.width, width = _b === void 0 ? 8 : _b, _c = _a.height, height = _c === void 0 ? 8 : _c;
|
|
300
|
+
switch (direction) {
|
|
301
|
+
case 'nw':
|
|
302
|
+
return {
|
|
303
|
+
x: x - width / 2,
|
|
304
|
+
y: y - height / 2,
|
|
305
|
+
};
|
|
306
|
+
case 'ne': {
|
|
307
|
+
return {
|
|
308
|
+
x: x + width / 2,
|
|
309
|
+
y: y - height / 2,
|
|
310
|
+
};
|
|
311
|
+
}
|
|
312
|
+
case 'se': {
|
|
313
|
+
return {
|
|
314
|
+
x: x + width / 2,
|
|
315
|
+
y: y + height / 2,
|
|
316
|
+
};
|
|
317
|
+
}
|
|
318
|
+
case 'sw': {
|
|
319
|
+
return {
|
|
320
|
+
x: x - width / 2,
|
|
321
|
+
y: y + height / 2,
|
|
322
|
+
};
|
|
323
|
+
}
|
|
324
|
+
default: {
|
|
325
|
+
return {
|
|
326
|
+
x: x,
|
|
327
|
+
y: y,
|
|
328
|
+
};
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
};
|
|
349
332
|
ResizeControl.prototype.render = function () {
|
|
350
333
|
var _a = this.props, x = _a.x, y = _a.y, direction = _a.direction, model = _a.model;
|
|
351
334
|
var _b = model.getResizeControlStyle(), width = _b.width, height = _b.height, restStyle = __rest(_b, ["width", "height"]);
|
|
352
|
-
|
|
335
|
+
// 为了让调整点在视觉上在调整外框的中间,因此在渲染时转换一下
|
|
336
|
+
var _c = this.getViewPosition(direction, x, y), viewX = _c.x, viewY = _c.y;
|
|
337
|
+
return ((0, jsx_runtime_1.jsxs)("g", { className: "lf-resize-control lf-resize-control-".concat(direction), children: [(0, jsx_runtime_1.jsx)(shape_1.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)), (0, jsx_runtime_1.jsx)(shape_1.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 })] }));
|
|
353
338
|
};
|
|
354
339
|
return ResizeControl;
|
|
355
340
|
}(compat_1.Component));
|
|
@@ -394,7 +379,9 @@ var ResizeControlGroup = /** @class */ (function (_super) {
|
|
|
394
379
|
var model = this.props.model;
|
|
395
380
|
var x = model.x, y = model.y, width = model.width, height = model.height;
|
|
396
381
|
var style = model.getResizeOutlineStyle();
|
|
397
|
-
return (0, jsx_runtime_1.jsx)(shape_1.Rect, __assign({}, style, { x: x, y: y,
|
|
382
|
+
return ((0, jsx_runtime_1.jsx)(shape_1.Rect, __assign({}, style, { "pointer-events": "none", x: x, y: y,
|
|
383
|
+
// TODO:宽高padding后续改成配置化的
|
|
384
|
+
width: width + 10, height: height + 10 })));
|
|
398
385
|
};
|
|
399
386
|
ResizeControlGroup.prototype.render = function () {
|
|
400
387
|
return ((0, jsx_runtime_1.jsxs)("g", { className: "lf-resize-control-group", children: [this.getResizeOutline(), this.getResizeControl()] }));
|
|
@@ -51,6 +51,7 @@ var BaseEdge_1 = __importDefault(require("./BaseEdge"));
|
|
|
51
51
|
var shape_1 = require("../shape");
|
|
52
52
|
var constant_1 = require("../../constant");
|
|
53
53
|
var util_1 = require("../../util");
|
|
54
|
+
var geometry_1 = require("../../util/geometry");
|
|
54
55
|
var algorithm_1 = require("../../algorithm");
|
|
55
56
|
var PolylineEdge = /** @class */ (function (_super) {
|
|
56
57
|
__extends(PolylineEdge, _super);
|
|
@@ -131,12 +132,22 @@ var PolylineEdge = /** @class */ (function (_super) {
|
|
|
131
132
|
* @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
|
|
132
133
|
*/
|
|
133
134
|
PolylineEdge.prototype.getEdge = function () {
|
|
135
|
+
var _a, _b;
|
|
134
136
|
var model = this.props.model;
|
|
135
|
-
var points = model.points, isAnimation = model.isAnimation, arrowConfig = model.arrowConfig;
|
|
137
|
+
var points = model.points, isAnimation = model.isAnimation, arrowConfig = model.arrowConfig, properties = model.properties;
|
|
136
138
|
var style = model.getEdgeStyle();
|
|
137
139
|
var animationStyle = model.getEdgeAnimationStyle();
|
|
138
140
|
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;
|
|
139
|
-
|
|
141
|
+
// 应用通用圆角:当存在样式半径时,为折线拐点生成圆角
|
|
142
|
+
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);
|
|
143
|
+
var roundedPointsStr = (function () {
|
|
144
|
+
if (!radius || radius <= 0)
|
|
145
|
+
return points;
|
|
146
|
+
var list = (0, util_1.points2PointsList)(points);
|
|
147
|
+
var rounded = (0, geometry_1.generateRoundedCorners)(list, radius, false);
|
|
148
|
+
return rounded.map(function (p) { return "".concat(p.x, ",").concat(p.y); }).join(' ');
|
|
149
|
+
})();
|
|
150
|
+
return ((0, jsx_runtime_1.jsx)(shape_1.Polyline, __assign({ points: roundedPointsStr }, style, arrowConfig, (isAnimation
|
|
140
151
|
? {
|
|
141
152
|
strokeDasharray: strokeDasharray,
|
|
142
153
|
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;
|
|
@@ -90,13 +90,16 @@ var BaseNode = /** @class */ (function (_super) {
|
|
|
90
90
|
var event = _a.event;
|
|
91
91
|
var _f = _this.props, model = _f.model, graphModel = _f.graphModel;
|
|
92
92
|
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;
|
|
93
|
-
model.isDragging = true;
|
|
94
93
|
var _h = event, clientX = _h.clientX, clientY = _h.clientY;
|
|
95
|
-
var _j =
|
|
94
|
+
var _j = _this.mouseDownPosition, mouseDownX = _j.x, mouseDownY = _j.y;
|
|
95
|
+
if (clientX - mouseDownX > gridSize || clientY - mouseDownY > gridSize) {
|
|
96
|
+
model.isDragging = true;
|
|
97
|
+
}
|
|
98
|
+
var _k = graphModel.getPointByClient({
|
|
96
99
|
x: clientX,
|
|
97
100
|
y: clientY,
|
|
98
|
-
}).canvasOverlayPosition, x =
|
|
99
|
-
var
|
|
101
|
+
}).canvasOverlayPosition, x = _k.x, y = _k.y;
|
|
102
|
+
var _l = __read(transformModel.CanvasPointToHtmlPoint([x, y]), 2), x1 = _l[0], y1 = _l[1];
|
|
100
103
|
// 1. 考虑画布被缩放
|
|
101
104
|
// 2. 考虑鼠标位置不再节点中心
|
|
102
105
|
x = x + ((_c = (_b = _this.moveOffset) === null || _b === void 0 ? void 0 : _b.dx) !== null && _c !== void 0 ? _c : 0);
|
|
@@ -114,14 +117,14 @@ var BaseNode = /** @class */ (function (_super) {
|
|
|
114
117
|
return;
|
|
115
118
|
}
|
|
116
119
|
// 取节点左上角和右下角,计算节点移动是否超出范围
|
|
117
|
-
var
|
|
120
|
+
var _m = __read(transformModel.CanvasPointToHtmlPoint([
|
|
118
121
|
x - model.width / 2,
|
|
119
122
|
y - model.height / 2,
|
|
120
|
-
]), 2), leftTopX =
|
|
121
|
-
var
|
|
123
|
+
]), 2), leftTopX = _m[0], leftTopY = _m[1];
|
|
124
|
+
var _o = __read(transformModel.CanvasPointToHtmlPoint([
|
|
122
125
|
x + model.width / 2,
|
|
123
126
|
y + model.height / 2,
|
|
124
|
-
]), 2), rightBottomX =
|
|
127
|
+
]), 2), rightBottomX = _o[0], rightBottomY = _o[1];
|
|
125
128
|
var size = Math.max(gridSize, 20);
|
|
126
129
|
var nearBoundary = [];
|
|
127
130
|
if (leftTopX < 0) {
|
|
@@ -188,7 +191,7 @@ var BaseNode = /** @class */ (function (_super) {
|
|
|
188
191
|
var _a = _this.props, model = _a.model, graphModel = _a.graphModel;
|
|
189
192
|
// 这里会有一种极端情况:当网格大小是1或者关闭网格吸附时,用触摸板点击节点会触发拖拽事件导致节点无法选中
|
|
190
193
|
// 当触摸板点击节点时,为了防止误触发拖拽导致节点无法选中,允许在非拖拽状态且时间间隔小于100ms时触发点击事件
|
|
191
|
-
if (!isDragging && timeInterval >
|
|
194
|
+
if (!isDragging && timeInterval > 300)
|
|
192
195
|
return;
|
|
193
196
|
if (!isDragging) {
|
|
194
197
|
_this.onDragEnd();
|
|
@@ -243,6 +246,15 @@ var BaseNode = /** @class */ (function (_super) {
|
|
|
243
246
|
else {
|
|
244
247
|
graphModel.eventCenter.emit(constant_1.EventType.ELEMENT_CLICK, eventOptions);
|
|
245
248
|
graphModel.eventCenter.emit(constant_1.EventType.NODE_CLICK, eventOptions);
|
|
249
|
+
// 复制粘贴后会出现点击节点时,节点会失去焦点的问题,这里手动让节点获焦以解决这个问题
|
|
250
|
+
var el_1 = e.currentTarget;
|
|
251
|
+
var rAF = typeof window !== 'undefined' &&
|
|
252
|
+
typeof window.requestAnimationFrame === 'function'
|
|
253
|
+
? window.requestAnimationFrame.bind(window)
|
|
254
|
+
: function (fn) { return setTimeout(fn, 0); };
|
|
255
|
+
rAF(function () {
|
|
256
|
+
el_1.focus();
|
|
257
|
+
});
|
|
246
258
|
}
|
|
247
259
|
};
|
|
248
260
|
_this.handleContextMenu = function (ev) {
|
|
@@ -271,6 +283,7 @@ var BaseNode = /** @class */ (function (_super) {
|
|
|
271
283
|
};
|
|
272
284
|
_this.handleMouseDown = function (ev) {
|
|
273
285
|
var _a = _this.props, model = _a.model, graphModel = _a.graphModel;
|
|
286
|
+
_this.mouseDownPosition = { x: ev.clientX, y: ev.clientY };
|
|
274
287
|
_this.startTime = new Date().getTime();
|
|
275
288
|
var editConfigModel = graphModel.editConfigModel;
|
|
276
289
|
if (editConfigModel.adjustNodePosition && model.draggable) {
|
|
@@ -458,7 +471,7 @@ var BaseNode = /** @class */ (function (_super) {
|
|
|
458
471
|
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;
|
|
459
472
|
var isHitable = model.isHitable, draggable = model.draggable, transform = model.transform;
|
|
460
473
|
var _c = model.getOuterGAttributes(), _d = _c.className, className = _d === void 0 ? '' : _d, restAttributes = __rest(_c, ["className"]);
|
|
461
|
-
var nodeShapeInner = ((0, jsx_runtime_1.jsxs)("g", { className: "lf-node-content", children: [(0, jsx_runtime_1.jsxs)("g", { transform: transform, children: [this.getShape(), this.getText(),
|
|
474
|
+
var nodeShapeInner = ((0, jsx_runtime_1.jsxs)("g", { className: "lf-node-content", children: [(0, jsx_runtime_1.jsxs)("g", { transform: transform, children: [this.getShape(), this.getText(), allowResize && this.getResizeControl(), allowRotate && this.getRotateControl()] }), !hideAnchors && this.getAnchors()] }));
|
|
462
475
|
var nodeShape;
|
|
463
476
|
if (!isHitable) {
|
|
464
477
|
nodeShape = ((0, jsx_runtime_1.jsx)("g", __assign({ className: "".concat(this.getStateClassName(), " ").concat(className) }, restAttributes, { children: nodeShapeInner })));
|