@logicflow/extension 2.3.0-alpha.1 → 2.3.1-alpha.0
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.min.js +1 -1
- package/dist/index.min.js.map +1 -1
- package/es/dynamic-group/index.d.ts +1 -1
- package/es/dynamic-group/index.js +37 -101
- package/es/dynamic-group/titleText.js +2 -2
- package/es/materials/curved-edge/index.js +18 -3
- package/es/pool/index.d.ts +5 -1
- package/es/pool/index.js +59 -18
- package/lib/dynamic-group/index.d.ts +1 -1
- package/lib/dynamic-group/index.js +37 -101
- package/lib/dynamic-group/titleText.js +2 -2
- package/lib/materials/curved-edge/index.js +18 -3
- package/lib/pool/index.d.ts +5 -1
- package/lib/pool/index.js +59 -18
- package/package.json +3 -3
|
@@ -36,7 +36,7 @@ export declare class DynamicGroup {
|
|
|
36
36
|
/** 拖拽节点进入分组时的感应外框样式 */
|
|
37
37
|
sensorOutline?: SensorOutlineOptions;
|
|
38
38
|
topGroupZIndex: number;
|
|
39
|
-
activeGroups
|
|
39
|
+
private activeGroups;
|
|
40
40
|
nodeGroupMap: Map<string, string>;
|
|
41
41
|
/** 折叠态虚拟边 id → 所属分组与真实边 id */
|
|
42
42
|
collapsedVirtualEdges: Map<string, {
|
|
@@ -9,17 +9,6 @@ var __assign = (this && this.__assign) || function () {
|
|
|
9
9
|
};
|
|
10
10
|
return __assign.apply(this, arguments);
|
|
11
11
|
};
|
|
12
|
-
var __values = (this && this.__values) || function(o) {
|
|
13
|
-
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
14
|
-
if (m) return m.call(o);
|
|
15
|
-
if (o && typeof o.length === "number") return {
|
|
16
|
-
next: function () {
|
|
17
|
-
if (o && i >= o.length) o = void 0;
|
|
18
|
-
return { value: o && o[i++], done: !o };
|
|
19
|
-
}
|
|
20
|
-
};
|
|
21
|
-
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
22
|
-
};
|
|
23
12
|
var __read = (this && this.__read) || function (o, n) {
|
|
24
13
|
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
25
14
|
if (!m) return o;
|
|
@@ -88,7 +77,6 @@ var DynamicGroup = /** @class */ (function () {
|
|
|
88
77
|
* Gateway 双分支等场景下,每条虚拟边只映射一条真实边。
|
|
89
78
|
*/
|
|
90
79
|
this.onEdgeDelete = function (_a) {
|
|
91
|
-
var e_1, _b;
|
|
92
80
|
var edge = _a.data;
|
|
93
81
|
var virtualMapping = _this.collapsedVirtualEdges.get(edge.id);
|
|
94
82
|
if (virtualMapping) {
|
|
@@ -100,26 +88,25 @@ var DynamicGroup = /** @class */ (function () {
|
|
|
100
88
|
}
|
|
101
89
|
return;
|
|
102
90
|
}
|
|
103
|
-
//
|
|
91
|
+
// 真实边被其它路径删除时,同步清理登记并删除对应虚拟边
|
|
104
92
|
var groupId = _this.collapsedRealEdgeToGroup.get(edge.id);
|
|
105
93
|
if (groupId) {
|
|
106
94
|
_this.collapsedRealEdgeToGroup.delete(edge.id);
|
|
107
95
|
}
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
96
|
+
// 先收集需要删除的虚拟边 id,再统一删除,避免遍历中修改 Map
|
|
97
|
+
// 使用 forEach 代替 for...of entries(),确保在 ES5 编译目标下(无 downlevelIteration)也能正确迭代
|
|
98
|
+
var virtualIdsToDelete = [];
|
|
99
|
+
_this.collapsedVirtualEdges.forEach(function (info, virtualId) {
|
|
100
|
+
if (info.realEdgeId === edge.id) {
|
|
101
|
+
virtualIdsToDelete.push(virtualId);
|
|
114
102
|
}
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
103
|
+
});
|
|
104
|
+
virtualIdsToDelete.forEach(function (virtualId) {
|
|
105
|
+
_this.collapsedVirtualEdges.delete(virtualId);
|
|
106
|
+
if (_this.lf.getEdgeModelById(virtualId)) {
|
|
107
|
+
_this.lf.deleteEdge(virtualId);
|
|
120
108
|
}
|
|
121
|
-
|
|
122
|
-
}
|
|
109
|
+
});
|
|
123
110
|
};
|
|
124
111
|
this.onSelectionDrop = function () {
|
|
125
112
|
_this.clearDragTargetHighlight();
|
|
@@ -266,7 +253,9 @@ var DynamicGroup = /** @class */ (function () {
|
|
|
266
253
|
});
|
|
267
254
|
}
|
|
268
255
|
else {
|
|
269
|
-
|
|
256
|
+
if (groupModel.children.size > 0) {
|
|
257
|
+
_this.releaseGroupMembers(groupModel);
|
|
258
|
+
}
|
|
270
259
|
}
|
|
271
260
|
}
|
|
272
261
|
var groupId = _this.nodeGroupMap.get(node.id);
|
|
@@ -277,7 +266,6 @@ var DynamicGroup = /** @class */ (function () {
|
|
|
277
266
|
}
|
|
278
267
|
};
|
|
279
268
|
this.onSelectionDrag = function () {
|
|
280
|
-
var e_2, _a, e_3, _b;
|
|
281
269
|
var selectedNodes = _this.lf.graphModel.getSelectElements().nodes;
|
|
282
270
|
// 每个节点独立找目标组,合并为 Set,消除迭代顺序的影响
|
|
283
271
|
var next = new Set();
|
|
@@ -286,35 +274,15 @@ var DynamicGroup = /** @class */ (function () {
|
|
|
286
274
|
if (targetGroup)
|
|
287
275
|
next.add(targetGroup);
|
|
288
276
|
});
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
finally {
|
|
299
|
-
try {
|
|
300
|
-
if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
|
|
301
|
-
}
|
|
302
|
-
finally { if (e_2) throw e_2.error; }
|
|
303
|
-
}
|
|
304
|
-
try {
|
|
305
|
-
for (var next_1 = __values(next), next_1_1 = next_1.next(); !next_1_1.done; next_1_1 = next_1.next()) {
|
|
306
|
-
var group = next_1_1.value;
|
|
307
|
-
if (!_this.activeGroups.has(group))
|
|
308
|
-
group.setAllowAppendChild(true);
|
|
309
|
-
}
|
|
310
|
-
}
|
|
311
|
-
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
312
|
-
finally {
|
|
313
|
-
try {
|
|
314
|
-
if (next_1_1 && !next_1_1.done && (_b = next_1.return)) _b.call(next_1);
|
|
315
|
-
}
|
|
316
|
-
finally { if (e_3) throw e_3.error; }
|
|
317
|
-
}
|
|
277
|
+
// diff 更新:只操作有变化的组,避免无谓的视觉抖动
|
|
278
|
+
_this.activeGroups.forEach(function (group) {
|
|
279
|
+
if (!next.has(group))
|
|
280
|
+
group.setAllowAppendChild(false);
|
|
281
|
+
});
|
|
282
|
+
next.forEach(function (group) {
|
|
283
|
+
if (!_this.activeGroups.has(group))
|
|
284
|
+
group.setAllowAppendChild(true);
|
|
285
|
+
});
|
|
318
286
|
_this.activeGroups = next;
|
|
319
287
|
};
|
|
320
288
|
this.onNodeDrag = function (_a) {
|
|
@@ -322,39 +290,18 @@ var DynamicGroup = /** @class */ (function () {
|
|
|
322
290
|
_this.setActiveGroup(node);
|
|
323
291
|
};
|
|
324
292
|
this.setActiveGroup = function (node) {
|
|
325
|
-
var e_4, _a, e_5, _b;
|
|
326
293
|
var targetGroup = _this.getTargetGroupForNode(node);
|
|
327
294
|
var next = new Set();
|
|
328
295
|
if (targetGroup)
|
|
329
296
|
next.add(targetGroup);
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
finally {
|
|
339
|
-
try {
|
|
340
|
-
if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
|
|
341
|
-
}
|
|
342
|
-
finally { if (e_4) throw e_4.error; }
|
|
343
|
-
}
|
|
344
|
-
try {
|
|
345
|
-
for (var next_2 = __values(next), next_2_1 = next_2.next(); !next_2_1.done; next_2_1 = next_2.next()) {
|
|
346
|
-
var group = next_2_1.value;
|
|
347
|
-
if (!_this.activeGroups.has(group))
|
|
348
|
-
group.setAllowAppendChild(true);
|
|
349
|
-
}
|
|
350
|
-
}
|
|
351
|
-
catch (e_5_1) { e_5 = { error: e_5_1 }; }
|
|
352
|
-
finally {
|
|
353
|
-
try {
|
|
354
|
-
if (next_2_1 && !next_2_1.done && (_b = next_2.return)) _b.call(next_2);
|
|
355
|
-
}
|
|
356
|
-
finally { if (e_5) throw e_5.error; }
|
|
357
|
-
}
|
|
297
|
+
_this.activeGroups.forEach(function (group) {
|
|
298
|
+
if (!next.has(group))
|
|
299
|
+
group.setAllowAppendChild(false);
|
|
300
|
+
});
|
|
301
|
+
next.forEach(function (group) {
|
|
302
|
+
if (!_this.activeGroups.has(group))
|
|
303
|
+
group.setAllowAppendChild(true);
|
|
304
|
+
});
|
|
358
305
|
_this.activeGroups = next;
|
|
359
306
|
};
|
|
360
307
|
/**
|
|
@@ -624,20 +571,9 @@ var DynamicGroup = /** @class */ (function () {
|
|
|
624
571
|
this.topGroupZIndex = max;
|
|
625
572
|
};
|
|
626
573
|
DynamicGroup.prototype.clearDragTargetHighlight = function () {
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
var group = _c.value;
|
|
631
|
-
group.setAllowAppendChild(false);
|
|
632
|
-
}
|
|
633
|
-
}
|
|
634
|
-
catch (e_6_1) { e_6 = { error: e_6_1 }; }
|
|
635
|
-
finally {
|
|
636
|
-
try {
|
|
637
|
-
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
638
|
-
}
|
|
639
|
-
finally { if (e_6) throw e_6.error; }
|
|
640
|
-
}
|
|
574
|
+
this.activeGroups.forEach(function (group) {
|
|
575
|
+
group.setAllowAppendChild(false);
|
|
576
|
+
});
|
|
641
577
|
this.activeGroups.clear();
|
|
642
578
|
};
|
|
643
579
|
DynamicGroup.prototype.getTargetGroupForNode = function (node) {
|
|
@@ -839,7 +775,7 @@ var DynamicGroup = /** @class */ (function () {
|
|
|
839
775
|
// 使用场景:addElements api 项目内部目前只在快捷键粘贴时使用(此处解决的也应该是粘贴场景的问题)
|
|
840
776
|
lf.addElements = function (_a, distance) {
|
|
841
777
|
var selectedNodes = _a.nodes, selectedEdges = _a.edges;
|
|
842
|
-
if (distance === void 0) { distance =
|
|
778
|
+
if (distance === void 0) { distance = 0; }
|
|
843
779
|
// oldNodeId -> newNodeId 映射 Map
|
|
844
780
|
var nodeIdMap = {};
|
|
845
781
|
// 本次添加的所有节点和边
|
|
@@ -53,7 +53,7 @@ var DynamicGroupText = /** @class */ (function (_super) {
|
|
|
53
53
|
pad: pad,
|
|
54
54
|
}), foX = _d.foX, foY = _d.foY, foWidth = _d.foWidth, foHeight = _d.foHeight;
|
|
55
55
|
var isEllipsis = overflowMode === 'ellipsis';
|
|
56
|
-
var rows = String(value).split(
|
|
56
|
+
var rows = String(value).split(/\r\n|\r|\n/g);
|
|
57
57
|
var isDraggable = editConfigModel.nodeTextDraggable || draggable;
|
|
58
58
|
return (_jsx("g", { className: classNames({
|
|
59
59
|
'lf-element-text': editable,
|
|
@@ -76,7 +76,7 @@ var DynamicGroupText = /** @class */ (function (_super) {
|
|
|
76
76
|
fontFamily: style.fontFamily,
|
|
77
77
|
color: style.fill,
|
|
78
78
|
width: '100%',
|
|
79
|
-
}, children: rows.map(function (row) { return (_jsx("div", { className: "lf-node-text--auto-wrap-inner", children: row })); }) }) }) }) }));
|
|
79
|
+
}, children: rows.map(function (row, i) { return (_jsx("div", { className: "lf-node-text--auto-wrap-inner", children: row }, i)); }) }) }) }) }));
|
|
80
80
|
};
|
|
81
81
|
return DynamicGroupText;
|
|
82
82
|
}(BaseText));
|
|
@@ -41,6 +41,13 @@ var __read = (this && this.__read) || function (o, n) {
|
|
|
41
41
|
return ar;
|
|
42
42
|
};
|
|
43
43
|
import { PolylineEdge, PolylineEdgeModel, h } from '@logicflow/core';
|
|
44
|
+
// SVG 路径点只能是严格的 [x, y];多余坐标也视为格式错误,不能静默忽略。
|
|
45
|
+
var isFinitePointTuple = function (point) {
|
|
46
|
+
return Array.isArray(point) &&
|
|
47
|
+
point.length === 2 &&
|
|
48
|
+
Number.isFinite(point[0]) &&
|
|
49
|
+
Number.isFinite(point[1]);
|
|
50
|
+
};
|
|
44
51
|
// 方向组合到圆弧象限的映射。
|
|
45
52
|
// key 由进入方向(dir1)和离开方向(dir2)拼接,例如 'tr' 表示从上(t)到右(r)的拐角。
|
|
46
53
|
// 通过该映射确定在拐点处应该绘制的圆弧象限,用于计算中间控制点。
|
|
@@ -180,13 +187,21 @@ function getPartialPath(prevPoint, cornerPoint, nextPoint, cornerRadius) {
|
|
|
180
187
|
return path;
|
|
181
188
|
}
|
|
182
189
|
function getCurvedEdgePath(points, radius) {
|
|
190
|
+
// 这是可独立调用的导出函数,不能依赖 View 一定提前完成校验。
|
|
191
|
+
if (points.length === 0 || !points.every(isFinitePointTuple)) {
|
|
192
|
+
return '';
|
|
193
|
+
}
|
|
194
|
+
// i 始终指向下一个尚未写入路径的点:首点只生成 M,单点路径到此结束;
|
|
195
|
+
// 两点生成直线,三个及以上的点才为中间拐点计算圆角。
|
|
183
196
|
var i = 0;
|
|
184
|
-
var d =
|
|
197
|
+
var d = "M".concat(points[i][0], " ").concat(points[i++][1]);
|
|
198
|
+
if (points.length === 1) {
|
|
199
|
+
return d;
|
|
200
|
+
}
|
|
185
201
|
if (points.length === 2) {
|
|
186
|
-
d += "
|
|
202
|
+
d += " L ".concat(points[i][0], " ").concat(points[i][1]);
|
|
187
203
|
}
|
|
188
204
|
else {
|
|
189
|
-
d += "M".concat(points[i][0], " ").concat(points[i++][1]);
|
|
190
205
|
for (; i + 1 < points.length;) {
|
|
191
206
|
var prev = points[i - 1];
|
|
192
207
|
var cur = points[i];
|
package/es/pool/index.d.ts
CHANGED
|
@@ -25,7 +25,7 @@ export declare const LaneNode: {
|
|
|
25
25
|
export declare class PoolElements {
|
|
26
26
|
static pluginName: string;
|
|
27
27
|
private lf;
|
|
28
|
-
|
|
28
|
+
private activeGroups;
|
|
29
29
|
nodeLaneMap: Map<string, string>;
|
|
30
30
|
constructor({ lf, options }: LogicFlow.IExtensionProps);
|
|
31
31
|
/**
|
|
@@ -51,7 +51,11 @@ export declare class PoolElements {
|
|
|
51
51
|
removeNodeFromGroup: ({ data: node, model, }: CallbackArgs<'node:delete'>) => void;
|
|
52
52
|
onSelectionDrag: () => void;
|
|
53
53
|
onNodeDrag: ({ data: node }: CallbackArgs<'node:drag'>) => void;
|
|
54
|
+
private getTargetLaneForNode;
|
|
54
55
|
setActiveGroup: (node: LogicFlow.NodeData) => void;
|
|
56
|
+
clearDragTargetHighlight(): void;
|
|
57
|
+
onNodeDrop: () => void;
|
|
58
|
+
onNodeMouseUp: () => void;
|
|
55
59
|
/**
|
|
56
60
|
* @param node
|
|
57
61
|
* @param isMultiple
|
package/es/pool/index.js
CHANGED
|
@@ -57,6 +57,8 @@ var PoolElements = /** @class */ (function () {
|
|
|
57
57
|
function PoolElements(_a) {
|
|
58
58
|
var lf = _a.lf, options = _a.options;
|
|
59
59
|
var _this = this;
|
|
60
|
+
// 激活态的泳道节点(支持多泳道同时高亮)
|
|
61
|
+
this.activeGroups = new Set();
|
|
60
62
|
// 存储节点与 group 的映射关系
|
|
61
63
|
this.nodeLaneMap = new Map();
|
|
62
64
|
/**
|
|
@@ -147,32 +149,46 @@ var PoolElements = /** @class */ (function () {
|
|
|
147
149
|
};
|
|
148
150
|
this.onSelectionDrag = function () {
|
|
149
151
|
var selectedNodes = _this.lf.graphModel.getSelectElements().nodes;
|
|
152
|
+
var next = new Set();
|
|
150
153
|
selectedNodes.forEach(function (node) {
|
|
151
|
-
_this.
|
|
154
|
+
var targetLane = _this.getTargetLaneForNode(node);
|
|
155
|
+
if (targetLane)
|
|
156
|
+
next.add(targetLane);
|
|
152
157
|
});
|
|
158
|
+
_this.activeGroups.forEach(function (lane) {
|
|
159
|
+
if (!next.has(lane))
|
|
160
|
+
lane.setAllowAppendChild(false);
|
|
161
|
+
});
|
|
162
|
+
next.forEach(function (lane) {
|
|
163
|
+
if (!_this.activeGroups.has(lane))
|
|
164
|
+
lane.setAllowAppendChild(true);
|
|
165
|
+
});
|
|
166
|
+
_this.activeGroups = next;
|
|
153
167
|
};
|
|
154
168
|
this.onNodeDrag = function (_a) {
|
|
155
169
|
var node = _a.data;
|
|
156
170
|
_this.setActiveGroup(node);
|
|
157
171
|
};
|
|
158
172
|
this.setActiveGroup = function (node) {
|
|
159
|
-
var
|
|
160
|
-
var
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
if (
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
173
|
+
var targetLane = _this.getTargetLaneForNode(node);
|
|
174
|
+
var next = new Set();
|
|
175
|
+
if (targetLane)
|
|
176
|
+
next.add(targetLane);
|
|
177
|
+
_this.activeGroups.forEach(function (lane) {
|
|
178
|
+
if (!next.has(lane))
|
|
179
|
+
lane.setAllowAppendChild(false);
|
|
180
|
+
});
|
|
181
|
+
next.forEach(function (lane) {
|
|
182
|
+
if (!_this.activeGroups.has(lane))
|
|
183
|
+
lane.setAllowAppendChild(true);
|
|
184
|
+
});
|
|
185
|
+
_this.activeGroups = next;
|
|
186
|
+
};
|
|
187
|
+
this.onNodeDrop = function () {
|
|
188
|
+
_this.clearDragTargetHighlight();
|
|
189
|
+
};
|
|
190
|
+
this.onNodeMouseUp = function () {
|
|
191
|
+
_this.clearDragTargetHighlight();
|
|
176
192
|
};
|
|
177
193
|
/**
|
|
178
194
|
* @param node
|
|
@@ -253,6 +269,7 @@ var PoolElements = /** @class */ (function () {
|
|
|
253
269
|
groupModel.width = newGroupWidth;
|
|
254
270
|
groupModel.height = newGroupHeight;
|
|
255
271
|
groupModel.updateExpandedSize(newGroupWidth, newGroupHeight);
|
|
272
|
+
groupModel.setTextPosition();
|
|
256
273
|
};
|
|
257
274
|
this.onGraphRendered = function (_a) {
|
|
258
275
|
var data = _a.data;
|
|
@@ -308,6 +325,26 @@ var PoolElements = /** @class */ (function () {
|
|
|
308
325
|
return topZIndexLane;
|
|
309
326
|
}
|
|
310
327
|
};
|
|
328
|
+
PoolElements.prototype.getTargetLaneForNode = function (node) {
|
|
329
|
+
var nodeModel = this.lf.getNodeModelById(node.id);
|
|
330
|
+
var bounds = nodeModel === null || nodeModel === void 0 ? void 0 : nodeModel.getBounds();
|
|
331
|
+
if (!nodeModel || !bounds)
|
|
332
|
+
return undefined;
|
|
333
|
+
var targetLane = this.getLaneByBounds(bounds, node);
|
|
334
|
+
if (!targetLane)
|
|
335
|
+
return undefined;
|
|
336
|
+
if (nodeModel.isGroup && targetLane.id === node.id)
|
|
337
|
+
return undefined;
|
|
338
|
+
if (!targetLane.isAllowAppendIn(node))
|
|
339
|
+
return undefined;
|
|
340
|
+
return targetLane;
|
|
341
|
+
};
|
|
342
|
+
PoolElements.prototype.clearDragTargetHighlight = function () {
|
|
343
|
+
this.activeGroups.forEach(function (lane) {
|
|
344
|
+
lane.setAllowAppendChild(false);
|
|
345
|
+
});
|
|
346
|
+
this.activeGroups.clear();
|
|
347
|
+
};
|
|
311
348
|
PoolElements.prototype.removeChildrenInGroupNodeData = function (nodeData) {
|
|
312
349
|
var _a;
|
|
313
350
|
var newNodeData = cloneDeep(nodeData);
|
|
@@ -447,6 +484,8 @@ var PoolElements = /** @class */ (function () {
|
|
|
447
484
|
lf.on(EventType.NODE_DELETE, this.removeNodeFromGroup);
|
|
448
485
|
lf.on(NODE_DRAG_EVENTS, this.onNodeDrag);
|
|
449
486
|
lf.on(EventType.SELECTION_DRAG, this.onSelectionDrag);
|
|
487
|
+
lf.on(EventType.NODE_DROP, this.onNodeDrop);
|
|
488
|
+
lf.on(EventType.NODE_MOUSEUP, this.onNodeMouseUp);
|
|
450
489
|
lf.on(EventType.NODE_CLICK, this.onNodeSelect);
|
|
451
490
|
lf.on(EventType.NODE_MOUSEMOVE, this.onNodeMove);
|
|
452
491
|
lf.on(EventType.GRAPH_RENDERED, this.onGraphRendered);
|
|
@@ -496,6 +535,8 @@ var PoolElements = /** @class */ (function () {
|
|
|
496
535
|
this.lf.off(EventType.NODE_DELETE, this.removeNodeFromGroup);
|
|
497
536
|
this.lf.off(NODE_DRAG_EVENTS, this.onNodeDrag);
|
|
498
537
|
this.lf.off(EventType.SELECTION_DRAG, this.onSelectionDrag);
|
|
538
|
+
this.lf.off(EventType.NODE_DROP, this.onNodeDrop);
|
|
539
|
+
this.lf.off(EventType.NODE_MOUSEUP, this.onNodeMouseUp);
|
|
499
540
|
this.lf.off(EventType.NODE_CLICK, this.onNodeSelect);
|
|
500
541
|
this.lf.off(EventType.NODE_MOUSEMOVE, this.onNodeMove);
|
|
501
542
|
this.lf.off(EventType.GRAPH_RENDERED, this.onGraphRendered);
|
|
@@ -36,7 +36,7 @@ export declare class DynamicGroup {
|
|
|
36
36
|
/** 拖拽节点进入分组时的感应外框样式 */
|
|
37
37
|
sensorOutline?: SensorOutlineOptions;
|
|
38
38
|
topGroupZIndex: number;
|
|
39
|
-
activeGroups
|
|
39
|
+
private activeGroups;
|
|
40
40
|
nodeGroupMap: Map<string, string>;
|
|
41
41
|
/** 折叠态虚拟边 id → 所属分组与真实边 id */
|
|
42
42
|
collapsedVirtualEdges: Map<string, {
|
|
@@ -24,17 +24,6 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
|
|
|
24
24
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
25
25
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
26
26
|
};
|
|
27
|
-
var __values = (this && this.__values) || function(o) {
|
|
28
|
-
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
29
|
-
if (m) return m.call(o);
|
|
30
|
-
if (o && typeof o.length === "number") return {
|
|
31
|
-
next: function () {
|
|
32
|
-
if (o && i >= o.length) o = void 0;
|
|
33
|
-
return { value: o && o[i++], done: !o };
|
|
34
|
-
}
|
|
35
|
-
};
|
|
36
|
-
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
37
|
-
};
|
|
38
27
|
var __read = (this && this.__read) || function (o, n) {
|
|
39
28
|
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
40
29
|
if (!m) return o;
|
|
@@ -105,7 +94,6 @@ var DynamicGroup = /** @class */ (function () {
|
|
|
105
94
|
* Gateway 双分支等场景下,每条虚拟边只映射一条真实边。
|
|
106
95
|
*/
|
|
107
96
|
this.onEdgeDelete = function (_a) {
|
|
108
|
-
var e_1, _b;
|
|
109
97
|
var edge = _a.data;
|
|
110
98
|
var virtualMapping = _this.collapsedVirtualEdges.get(edge.id);
|
|
111
99
|
if (virtualMapping) {
|
|
@@ -117,26 +105,25 @@ var DynamicGroup = /** @class */ (function () {
|
|
|
117
105
|
}
|
|
118
106
|
return;
|
|
119
107
|
}
|
|
120
|
-
//
|
|
108
|
+
// 真实边被其它路径删除时,同步清理登记并删除对应虚拟边
|
|
121
109
|
var groupId = _this.collapsedRealEdgeToGroup.get(edge.id);
|
|
122
110
|
if (groupId) {
|
|
123
111
|
_this.collapsedRealEdgeToGroup.delete(edge.id);
|
|
124
112
|
}
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
113
|
+
// 先收集需要删除的虚拟边 id,再统一删除,避免遍历中修改 Map
|
|
114
|
+
// 使用 forEach 代替 for...of entries(),确保在 ES5 编译目标下(无 downlevelIteration)也能正确迭代
|
|
115
|
+
var virtualIdsToDelete = [];
|
|
116
|
+
_this.collapsedVirtualEdges.forEach(function (info, virtualId) {
|
|
117
|
+
if (info.realEdgeId === edge.id) {
|
|
118
|
+
virtualIdsToDelete.push(virtualId);
|
|
131
119
|
}
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
120
|
+
});
|
|
121
|
+
virtualIdsToDelete.forEach(function (virtualId) {
|
|
122
|
+
_this.collapsedVirtualEdges.delete(virtualId);
|
|
123
|
+
if (_this.lf.getEdgeModelById(virtualId)) {
|
|
124
|
+
_this.lf.deleteEdge(virtualId);
|
|
137
125
|
}
|
|
138
|
-
|
|
139
|
-
}
|
|
126
|
+
});
|
|
140
127
|
};
|
|
141
128
|
this.onSelectionDrop = function () {
|
|
142
129
|
_this.clearDragTargetHighlight();
|
|
@@ -283,7 +270,9 @@ var DynamicGroup = /** @class */ (function () {
|
|
|
283
270
|
});
|
|
284
271
|
}
|
|
285
272
|
else {
|
|
286
|
-
|
|
273
|
+
if (groupModel.children.size > 0) {
|
|
274
|
+
_this.releaseGroupMembers(groupModel);
|
|
275
|
+
}
|
|
287
276
|
}
|
|
288
277
|
}
|
|
289
278
|
var groupId = _this.nodeGroupMap.get(node.id);
|
|
@@ -294,7 +283,6 @@ var DynamicGroup = /** @class */ (function () {
|
|
|
294
283
|
}
|
|
295
284
|
};
|
|
296
285
|
this.onSelectionDrag = function () {
|
|
297
|
-
var e_2, _a, e_3, _b;
|
|
298
286
|
var selectedNodes = _this.lf.graphModel.getSelectElements().nodes;
|
|
299
287
|
// 每个节点独立找目标组,合并为 Set,消除迭代顺序的影响
|
|
300
288
|
var next = new Set();
|
|
@@ -303,35 +291,15 @@ var DynamicGroup = /** @class */ (function () {
|
|
|
303
291
|
if (targetGroup)
|
|
304
292
|
next.add(targetGroup);
|
|
305
293
|
});
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
finally {
|
|
316
|
-
try {
|
|
317
|
-
if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
|
|
318
|
-
}
|
|
319
|
-
finally { if (e_2) throw e_2.error; }
|
|
320
|
-
}
|
|
321
|
-
try {
|
|
322
|
-
for (var next_1 = __values(next), next_1_1 = next_1.next(); !next_1_1.done; next_1_1 = next_1.next()) {
|
|
323
|
-
var group = next_1_1.value;
|
|
324
|
-
if (!_this.activeGroups.has(group))
|
|
325
|
-
group.setAllowAppendChild(true);
|
|
326
|
-
}
|
|
327
|
-
}
|
|
328
|
-
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
329
|
-
finally {
|
|
330
|
-
try {
|
|
331
|
-
if (next_1_1 && !next_1_1.done && (_b = next_1.return)) _b.call(next_1);
|
|
332
|
-
}
|
|
333
|
-
finally { if (e_3) throw e_3.error; }
|
|
334
|
-
}
|
|
294
|
+
// diff 更新:只操作有变化的组,避免无谓的视觉抖动
|
|
295
|
+
_this.activeGroups.forEach(function (group) {
|
|
296
|
+
if (!next.has(group))
|
|
297
|
+
group.setAllowAppendChild(false);
|
|
298
|
+
});
|
|
299
|
+
next.forEach(function (group) {
|
|
300
|
+
if (!_this.activeGroups.has(group))
|
|
301
|
+
group.setAllowAppendChild(true);
|
|
302
|
+
});
|
|
335
303
|
_this.activeGroups = next;
|
|
336
304
|
};
|
|
337
305
|
this.onNodeDrag = function (_a) {
|
|
@@ -339,39 +307,18 @@ var DynamicGroup = /** @class */ (function () {
|
|
|
339
307
|
_this.setActiveGroup(node);
|
|
340
308
|
};
|
|
341
309
|
this.setActiveGroup = function (node) {
|
|
342
|
-
var e_4, _a, e_5, _b;
|
|
343
310
|
var targetGroup = _this.getTargetGroupForNode(node);
|
|
344
311
|
var next = new Set();
|
|
345
312
|
if (targetGroup)
|
|
346
313
|
next.add(targetGroup);
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
finally {
|
|
356
|
-
try {
|
|
357
|
-
if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
|
|
358
|
-
}
|
|
359
|
-
finally { if (e_4) throw e_4.error; }
|
|
360
|
-
}
|
|
361
|
-
try {
|
|
362
|
-
for (var next_2 = __values(next), next_2_1 = next_2.next(); !next_2_1.done; next_2_1 = next_2.next()) {
|
|
363
|
-
var group = next_2_1.value;
|
|
364
|
-
if (!_this.activeGroups.has(group))
|
|
365
|
-
group.setAllowAppendChild(true);
|
|
366
|
-
}
|
|
367
|
-
}
|
|
368
|
-
catch (e_5_1) { e_5 = { error: e_5_1 }; }
|
|
369
|
-
finally {
|
|
370
|
-
try {
|
|
371
|
-
if (next_2_1 && !next_2_1.done && (_b = next_2.return)) _b.call(next_2);
|
|
372
|
-
}
|
|
373
|
-
finally { if (e_5) throw e_5.error; }
|
|
374
|
-
}
|
|
314
|
+
_this.activeGroups.forEach(function (group) {
|
|
315
|
+
if (!next.has(group))
|
|
316
|
+
group.setAllowAppendChild(false);
|
|
317
|
+
});
|
|
318
|
+
next.forEach(function (group) {
|
|
319
|
+
if (!_this.activeGroups.has(group))
|
|
320
|
+
group.setAllowAppendChild(true);
|
|
321
|
+
});
|
|
375
322
|
_this.activeGroups = next;
|
|
376
323
|
};
|
|
377
324
|
/**
|
|
@@ -641,20 +588,9 @@ var DynamicGroup = /** @class */ (function () {
|
|
|
641
588
|
this.topGroupZIndex = max;
|
|
642
589
|
};
|
|
643
590
|
DynamicGroup.prototype.clearDragTargetHighlight = function () {
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
var group = _c.value;
|
|
648
|
-
group.setAllowAppendChild(false);
|
|
649
|
-
}
|
|
650
|
-
}
|
|
651
|
-
catch (e_6_1) { e_6 = { error: e_6_1 }; }
|
|
652
|
-
finally {
|
|
653
|
-
try {
|
|
654
|
-
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
655
|
-
}
|
|
656
|
-
finally { if (e_6) throw e_6.error; }
|
|
657
|
-
}
|
|
591
|
+
this.activeGroups.forEach(function (group) {
|
|
592
|
+
group.setAllowAppendChild(false);
|
|
593
|
+
});
|
|
658
594
|
this.activeGroups.clear();
|
|
659
595
|
};
|
|
660
596
|
DynamicGroup.prototype.getTargetGroupForNode = function (node) {
|
|
@@ -856,7 +792,7 @@ var DynamicGroup = /** @class */ (function () {
|
|
|
856
792
|
// 使用场景:addElements api 项目内部目前只在快捷键粘贴时使用(此处解决的也应该是粘贴场景的问题)
|
|
857
793
|
lf.addElements = function (_a, distance) {
|
|
858
794
|
var selectedNodes = _a.nodes, selectedEdges = _a.edges;
|
|
859
|
-
if (distance === void 0) { distance =
|
|
795
|
+
if (distance === void 0) { distance = 0; }
|
|
860
796
|
// oldNodeId -> newNodeId 映射 Map
|
|
861
797
|
var nodeIdMap = {};
|
|
862
798
|
// 本次添加的所有节点和边
|
|
@@ -59,7 +59,7 @@ var DynamicGroupText = /** @class */ (function (_super) {
|
|
|
59
59
|
pad: pad,
|
|
60
60
|
}), foX = _d.foX, foY = _d.foY, foWidth = _d.foWidth, foHeight = _d.foHeight;
|
|
61
61
|
var isEllipsis = overflowMode === 'ellipsis';
|
|
62
|
-
var rows = String(value).split(
|
|
62
|
+
var rows = String(value).split(/\r\n|\r|\n/g);
|
|
63
63
|
var isDraggable = editConfigModel.nodeTextDraggable || draggable;
|
|
64
64
|
return ((0, jsx_runtime_1.jsx)("g", { className: (0, classnames_1.default)({
|
|
65
65
|
'lf-element-text': editable,
|
|
@@ -82,7 +82,7 @@ var DynamicGroupText = /** @class */ (function (_super) {
|
|
|
82
82
|
fontFamily: style.fontFamily,
|
|
83
83
|
color: style.fill,
|
|
84
84
|
width: '100%',
|
|
85
|
-
}, children: rows.map(function (row) { return ((0, jsx_runtime_1.jsx)("div", { className: "lf-node-text--auto-wrap-inner", children: row })); }) }) }) }) }));
|
|
85
|
+
}, children: rows.map(function (row, i) { return ((0, jsx_runtime_1.jsx)("div", { className: "lf-node-text--auto-wrap-inner", children: row }, i)); }) }) }) }) }));
|
|
86
86
|
};
|
|
87
87
|
return DynamicGroupText;
|
|
88
88
|
}(core_1.BaseText));
|