@logicflow/extension 2.3.0-alpha.0 → 2.3.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.css +1 -0
- package/dist/index.min.js +2 -0
- package/dist/index.min.js.map +1 -0
- package/es/dynamic-group/index.d.ts +2 -1
- package/es/dynamic-group/index.js +65 -49
- package/es/dynamic-group/titleText.js +2 -2
- package/es/pool/index.d.ts +5 -1
- package/es/pool/index.js +59 -18
- package/lib/dynamic-group/index.d.ts +2 -1
- package/lib/dynamic-group/index.js +65 -49
- package/lib/dynamic-group/titleText.js +2 -2
- 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
|
-
|
|
39
|
+
private activeGroups;
|
|
40
40
|
nodeGroupMap: Map<string, string>;
|
|
41
41
|
/** 折叠态虚拟边 id → 所属分组与真实边 id */
|
|
42
42
|
collapsedVirtualEdges: Map<string, {
|
|
@@ -98,6 +98,7 @@ export declare class DynamicGroup {
|
|
|
98
98
|
removeNodeFromGroup: ({ data: node, model, }: CallbackArgs<'node:delete'>) => void;
|
|
99
99
|
onSelectionDrag: () => void;
|
|
100
100
|
onNodeDrag: ({ data: node }: CallbackArgs<'node:drag'>) => void;
|
|
101
|
+
private getTargetGroupForNode;
|
|
101
102
|
setActiveGroup: (node: LogicFlow.NodeData) => void;
|
|
102
103
|
/**
|
|
103
104
|
* 1. 分组节点默认在普通节点下面
|
|
@@ -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;
|
|
@@ -75,6 +64,8 @@ var DynamicGroup = /** @class */ (function () {
|
|
|
75
64
|
*/
|
|
76
65
|
this.cascadeDeleteChildren = true;
|
|
77
66
|
this.topGroupZIndex = DEFAULT_BOTTOM_Z_INDEX;
|
|
67
|
+
// 激活态的 group 节点(支持多组同时高亮)
|
|
68
|
+
this.activeGroups = new Set();
|
|
78
69
|
// 存储节点与 group 的映射关系
|
|
79
70
|
this.nodeGroupMap = new Map();
|
|
80
71
|
/** 折叠态虚拟边 id → 所属分组与真实边 id */
|
|
@@ -86,7 +77,6 @@ var DynamicGroup = /** @class */ (function () {
|
|
|
86
77
|
* Gateway 双分支等场景下,每条虚拟边只映射一条真实边。
|
|
87
78
|
*/
|
|
88
79
|
this.onEdgeDelete = function (_a) {
|
|
89
|
-
var e_1, _b;
|
|
90
80
|
var edge = _a.data;
|
|
91
81
|
var virtualMapping = _this.collapsedVirtualEdges.get(edge.id);
|
|
92
82
|
if (virtualMapping) {
|
|
@@ -98,26 +88,25 @@ var DynamicGroup = /** @class */ (function () {
|
|
|
98
88
|
}
|
|
99
89
|
return;
|
|
100
90
|
}
|
|
101
|
-
//
|
|
91
|
+
// 真实边被其它路径删除时,同步清理登记并删除对应虚拟边
|
|
102
92
|
var groupId = _this.collapsedRealEdgeToGroup.get(edge.id);
|
|
103
93
|
if (groupId) {
|
|
104
94
|
_this.collapsedRealEdgeToGroup.delete(edge.id);
|
|
105
95
|
}
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
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);
|
|
112
102
|
}
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
103
|
+
});
|
|
104
|
+
virtualIdsToDelete.forEach(function (virtualId) {
|
|
105
|
+
_this.collapsedVirtualEdges.delete(virtualId);
|
|
106
|
+
if (_this.lf.getEdgeModelById(virtualId)) {
|
|
107
|
+
_this.lf.deleteEdge(virtualId);
|
|
118
108
|
}
|
|
119
|
-
|
|
120
|
-
}
|
|
109
|
+
});
|
|
121
110
|
};
|
|
122
111
|
this.onSelectionDrop = function () {
|
|
123
112
|
_this.clearDragTargetHighlight();
|
|
@@ -264,7 +253,9 @@ var DynamicGroup = /** @class */ (function () {
|
|
|
264
253
|
});
|
|
265
254
|
}
|
|
266
255
|
else {
|
|
267
|
-
|
|
256
|
+
if (groupModel.children.size > 0) {
|
|
257
|
+
_this.releaseGroupMembers(groupModel);
|
|
258
|
+
}
|
|
268
259
|
}
|
|
269
260
|
}
|
|
270
261
|
var groupId = _this.nodeGroupMap.get(node.id);
|
|
@@ -276,31 +267,42 @@ var DynamicGroup = /** @class */ (function () {
|
|
|
276
267
|
};
|
|
277
268
|
this.onSelectionDrag = function () {
|
|
278
269
|
var selectedNodes = _this.lf.graphModel.getSelectElements().nodes;
|
|
270
|
+
// 每个节点独立找目标组,合并为 Set,消除迭代顺序的影响
|
|
271
|
+
var next = new Set();
|
|
279
272
|
selectedNodes.forEach(function (node) {
|
|
280
|
-
_this.
|
|
273
|
+
var targetGroup = _this.getTargetGroupForNode(node);
|
|
274
|
+
if (targetGroup)
|
|
275
|
+
next.add(targetGroup);
|
|
281
276
|
});
|
|
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
|
+
});
|
|
286
|
+
_this.activeGroups = next;
|
|
282
287
|
};
|
|
283
288
|
this.onNodeDrag = function (_a) {
|
|
284
289
|
var node = _a.data;
|
|
285
290
|
_this.setActiveGroup(node);
|
|
286
291
|
};
|
|
287
292
|
this.setActiveGroup = function (node) {
|
|
288
|
-
var
|
|
289
|
-
var
|
|
290
|
-
if (
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
_this.activeGroup = targetGroup;
|
|
302
|
-
_this.activeGroup.setAllowAppendChild(true);
|
|
303
|
-
}
|
|
293
|
+
var targetGroup = _this.getTargetGroupForNode(node);
|
|
294
|
+
var next = new Set();
|
|
295
|
+
if (targetGroup)
|
|
296
|
+
next.add(targetGroup);
|
|
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
|
+
});
|
|
305
|
+
_this.activeGroups = next;
|
|
304
306
|
};
|
|
305
307
|
/**
|
|
306
308
|
* 1. 分组节点默认在普通节点下面
|
|
@@ -417,7 +419,7 @@ var DynamicGroup = /** @class */ (function () {
|
|
|
417
419
|
_this.nodeGroupMap.clear();
|
|
418
420
|
_this.collapsedVirtualEdges.clear();
|
|
419
421
|
_this.collapsedRealEdgeToGroup.clear();
|
|
420
|
-
_this.
|
|
422
|
+
_this.activeGroups.clear();
|
|
421
423
|
_this.topGroupZIndex = DEFAULT_BOTTOM_Z_INDEX;
|
|
422
424
|
forEach(data.nodes, function (node) {
|
|
423
425
|
if (node.children) {
|
|
@@ -569,10 +571,24 @@ var DynamicGroup = /** @class */ (function () {
|
|
|
569
571
|
this.topGroupZIndex = max;
|
|
570
572
|
};
|
|
571
573
|
DynamicGroup.prototype.clearDragTargetHighlight = function () {
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
574
|
+
this.activeGroups.forEach(function (group) {
|
|
575
|
+
group.setAllowAppendChild(false);
|
|
576
|
+
});
|
|
577
|
+
this.activeGroups.clear();
|
|
578
|
+
};
|
|
579
|
+
DynamicGroup.prototype.getTargetGroupForNode = function (node) {
|
|
580
|
+
var nodeModel = this.lf.getNodeModelById(node.id);
|
|
581
|
+
var bounds = nodeModel === null || nodeModel === void 0 ? void 0 : nodeModel.getBounds();
|
|
582
|
+
if (!nodeModel || !bounds)
|
|
583
|
+
return undefined;
|
|
584
|
+
var targetGroup = this.getGroupByBounds(bounds, node);
|
|
585
|
+
if (!targetGroup)
|
|
586
|
+
return undefined;
|
|
587
|
+
if (nodeModel.isGroup && targetGroup.id === node.id)
|
|
588
|
+
return undefined;
|
|
589
|
+
if (!targetGroup.isAllowAppendIn(node))
|
|
590
|
+
return undefined;
|
|
591
|
+
return targetGroup;
|
|
576
592
|
};
|
|
577
593
|
DynamicGroup.prototype.removeChildrenInGroupNodeData = function (nodeData) {
|
|
578
594
|
var _a;
|
|
@@ -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));
|
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
|
-
|
|
39
|
+
private activeGroups;
|
|
40
40
|
nodeGroupMap: Map<string, string>;
|
|
41
41
|
/** 折叠态虚拟边 id → 所属分组与真实边 id */
|
|
42
42
|
collapsedVirtualEdges: Map<string, {
|
|
@@ -98,6 +98,7 @@ export declare class DynamicGroup {
|
|
|
98
98
|
removeNodeFromGroup: ({ data: node, model, }: CallbackArgs<'node:delete'>) => void;
|
|
99
99
|
onSelectionDrag: () => void;
|
|
100
100
|
onNodeDrag: ({ data: node }: CallbackArgs<'node:drag'>) => void;
|
|
101
|
+
private getTargetGroupForNode;
|
|
101
102
|
setActiveGroup: (node: LogicFlow.NodeData) => void;
|
|
102
103
|
/**
|
|
103
104
|
* 1. 分组节点默认在普通节点下面
|
|
@@ -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;
|
|
@@ -92,6 +81,8 @@ var DynamicGroup = /** @class */ (function () {
|
|
|
92
81
|
*/
|
|
93
82
|
this.cascadeDeleteChildren = true;
|
|
94
83
|
this.topGroupZIndex = DEFAULT_BOTTOM_Z_INDEX;
|
|
84
|
+
// 激活态的 group 节点(支持多组同时高亮)
|
|
85
|
+
this.activeGroups = new Set();
|
|
95
86
|
// 存储节点与 group 的映射关系
|
|
96
87
|
this.nodeGroupMap = new Map();
|
|
97
88
|
/** 折叠态虚拟边 id → 所属分组与真实边 id */
|
|
@@ -103,7 +94,6 @@ var DynamicGroup = /** @class */ (function () {
|
|
|
103
94
|
* Gateway 双分支等场景下,每条虚拟边只映射一条真实边。
|
|
104
95
|
*/
|
|
105
96
|
this.onEdgeDelete = function (_a) {
|
|
106
|
-
var e_1, _b;
|
|
107
97
|
var edge = _a.data;
|
|
108
98
|
var virtualMapping = _this.collapsedVirtualEdges.get(edge.id);
|
|
109
99
|
if (virtualMapping) {
|
|
@@ -115,26 +105,25 @@ var DynamicGroup = /** @class */ (function () {
|
|
|
115
105
|
}
|
|
116
106
|
return;
|
|
117
107
|
}
|
|
118
|
-
//
|
|
108
|
+
// 真实边被其它路径删除时,同步清理登记并删除对应虚拟边
|
|
119
109
|
var groupId = _this.collapsedRealEdgeToGroup.get(edge.id);
|
|
120
110
|
if (groupId) {
|
|
121
111
|
_this.collapsedRealEdgeToGroup.delete(edge.id);
|
|
122
112
|
}
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
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);
|
|
129
119
|
}
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
120
|
+
});
|
|
121
|
+
virtualIdsToDelete.forEach(function (virtualId) {
|
|
122
|
+
_this.collapsedVirtualEdges.delete(virtualId);
|
|
123
|
+
if (_this.lf.getEdgeModelById(virtualId)) {
|
|
124
|
+
_this.lf.deleteEdge(virtualId);
|
|
135
125
|
}
|
|
136
|
-
|
|
137
|
-
}
|
|
126
|
+
});
|
|
138
127
|
};
|
|
139
128
|
this.onSelectionDrop = function () {
|
|
140
129
|
_this.clearDragTargetHighlight();
|
|
@@ -281,7 +270,9 @@ var DynamicGroup = /** @class */ (function () {
|
|
|
281
270
|
});
|
|
282
271
|
}
|
|
283
272
|
else {
|
|
284
|
-
|
|
273
|
+
if (groupModel.children.size > 0) {
|
|
274
|
+
_this.releaseGroupMembers(groupModel);
|
|
275
|
+
}
|
|
285
276
|
}
|
|
286
277
|
}
|
|
287
278
|
var groupId = _this.nodeGroupMap.get(node.id);
|
|
@@ -293,31 +284,42 @@ var DynamicGroup = /** @class */ (function () {
|
|
|
293
284
|
};
|
|
294
285
|
this.onSelectionDrag = function () {
|
|
295
286
|
var selectedNodes = _this.lf.graphModel.getSelectElements().nodes;
|
|
287
|
+
// 每个节点独立找目标组,合并为 Set,消除迭代顺序的影响
|
|
288
|
+
var next = new Set();
|
|
296
289
|
selectedNodes.forEach(function (node) {
|
|
297
|
-
_this.
|
|
290
|
+
var targetGroup = _this.getTargetGroupForNode(node);
|
|
291
|
+
if (targetGroup)
|
|
292
|
+
next.add(targetGroup);
|
|
298
293
|
});
|
|
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
|
+
});
|
|
303
|
+
_this.activeGroups = next;
|
|
299
304
|
};
|
|
300
305
|
this.onNodeDrag = function (_a) {
|
|
301
306
|
var node = _a.data;
|
|
302
307
|
_this.setActiveGroup(node);
|
|
303
308
|
};
|
|
304
309
|
this.setActiveGroup = function (node) {
|
|
305
|
-
var
|
|
306
|
-
var
|
|
307
|
-
if (
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
_this.activeGroup = targetGroup;
|
|
319
|
-
_this.activeGroup.setAllowAppendChild(true);
|
|
320
|
-
}
|
|
310
|
+
var targetGroup = _this.getTargetGroupForNode(node);
|
|
311
|
+
var next = new Set();
|
|
312
|
+
if (targetGroup)
|
|
313
|
+
next.add(targetGroup);
|
|
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
|
+
});
|
|
322
|
+
_this.activeGroups = next;
|
|
321
323
|
};
|
|
322
324
|
/**
|
|
323
325
|
* 1. 分组节点默认在普通节点下面
|
|
@@ -434,7 +436,7 @@ var DynamicGroup = /** @class */ (function () {
|
|
|
434
436
|
_this.nodeGroupMap.clear();
|
|
435
437
|
_this.collapsedVirtualEdges.clear();
|
|
436
438
|
_this.collapsedRealEdgeToGroup.clear();
|
|
437
|
-
_this.
|
|
439
|
+
_this.activeGroups.clear();
|
|
438
440
|
_this.topGroupZIndex = DEFAULT_BOTTOM_Z_INDEX;
|
|
439
441
|
(0, lodash_es_1.forEach)(data.nodes, function (node) {
|
|
440
442
|
if (node.children) {
|
|
@@ -586,10 +588,24 @@ var DynamicGroup = /** @class */ (function () {
|
|
|
586
588
|
this.topGroupZIndex = max;
|
|
587
589
|
};
|
|
588
590
|
DynamicGroup.prototype.clearDragTargetHighlight = function () {
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
591
|
+
this.activeGroups.forEach(function (group) {
|
|
592
|
+
group.setAllowAppendChild(false);
|
|
593
|
+
});
|
|
594
|
+
this.activeGroups.clear();
|
|
595
|
+
};
|
|
596
|
+
DynamicGroup.prototype.getTargetGroupForNode = function (node) {
|
|
597
|
+
var nodeModel = this.lf.getNodeModelById(node.id);
|
|
598
|
+
var bounds = nodeModel === null || nodeModel === void 0 ? void 0 : nodeModel.getBounds();
|
|
599
|
+
if (!nodeModel || !bounds)
|
|
600
|
+
return undefined;
|
|
601
|
+
var targetGroup = this.getGroupByBounds(bounds, node);
|
|
602
|
+
if (!targetGroup)
|
|
603
|
+
return undefined;
|
|
604
|
+
if (nodeModel.isGroup && targetGroup.id === node.id)
|
|
605
|
+
return undefined;
|
|
606
|
+
if (!targetGroup.isAllowAppendIn(node))
|
|
607
|
+
return undefined;
|
|
608
|
+
return targetGroup;
|
|
593
609
|
};
|
|
594
610
|
DynamicGroup.prototype.removeChildrenInGroupNodeData = function (nodeData) {
|
|
595
611
|
var _a;
|
|
@@ -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));
|
package/lib/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
|