@logicflow/extension 2.2.2 → 2.2.4-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/es/constant/events.d.ts +9 -0
- package/es/constant/events.js +11 -0
- package/es/dynamic-group/index.d.ts +41 -3
- package/es/dynamic-group/index.js +281 -117
- package/es/dynamic-group/model.d.ts +48 -1
- package/es/dynamic-group/model.js +138 -23
- package/es/dynamic-group/node.d.ts +1 -0
- package/es/dynamic-group/node.js +52 -19
- package/es/dynamic-group/titleText.d.ts +8 -0
- package/es/dynamic-group/titleText.js +84 -0
- package/es/dynamic-group/utils.d.ts +69 -0
- package/es/dynamic-group/utils.js +162 -0
- package/es/index.css +321 -1
- package/es/index.d.ts +1 -0
- package/es/index.js +1 -0
- package/es/index.less +1 -0
- package/es/materials/group/GroupNode.js +5 -2
- package/es/materials/group/index.js +7 -6
- package/es/pool/LaneModel.d.ts +1 -1
- package/es/pool/PoolModel.d.ts +1 -1
- package/es/pool/index.d.ts +3 -2
- package/es/pool/index.js +44 -60
- package/es/style/index.css +321 -1
- package/es/style/index.less +381 -0
- package/lib/constant/events.d.ts +9 -0
- package/lib/constant/events.js +14 -0
- package/lib/dynamic-group/index.d.ts +41 -3
- package/lib/dynamic-group/index.js +280 -116
- package/lib/dynamic-group/model.d.ts +48 -1
- package/lib/dynamic-group/model.js +137 -22
- package/lib/dynamic-group/node.d.ts +1 -0
- package/lib/dynamic-group/node.js +53 -20
- package/lib/dynamic-group/titleText.d.ts +8 -0
- package/lib/dynamic-group/titleText.js +90 -0
- package/lib/dynamic-group/utils.d.ts +69 -0
- package/lib/dynamic-group/utils.js +172 -1
- package/lib/index.css +321 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.js +1 -0
- package/lib/index.less +1 -0
- package/lib/materials/group/GroupNode.js +5 -2
- package/lib/materials/group/index.js +7 -6
- package/lib/pool/LaneModel.d.ts +1 -1
- package/lib/pool/PoolModel.d.ts +1 -1
- package/lib/pool/index.d.ts +3 -2
- package/lib/pool/index.js +44 -60
- package/lib/style/index.css +321 -1
- package/lib/style/index.less +381 -0
- package/package.json +6 -6
- package/dist/index.css +0 -1
- package/dist/index.min.js +0 -2
- package/dist/index.min.js.map +0 -1
|
@@ -24,6 +24,17 @@ 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
|
+
};
|
|
27
38
|
var __read = (this && this.__read) || function (o, n) {
|
|
28
39
|
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
29
40
|
if (!m) return o;
|
|
@@ -55,6 +66,7 @@ var core_1 = require("@logicflow/core");
|
|
|
55
66
|
var lodash_es_1 = require("lodash-es");
|
|
56
67
|
var node_1 = require("./node");
|
|
57
68
|
var model_1 = require("./model");
|
|
69
|
+
var events_1 = require("../constant/events");
|
|
58
70
|
var utils_1 = require("./utils");
|
|
59
71
|
__exportStar(require("./node"), exports);
|
|
60
72
|
__exportStar(require("./model"), exports);
|
|
@@ -69,85 +81,204 @@ var DynamicGroup = /** @class */ (function () {
|
|
|
69
81
|
function DynamicGroup(_a) {
|
|
70
82
|
var lf = _a.lf, options = _a.options;
|
|
71
83
|
var _this = this;
|
|
84
|
+
/**
|
|
85
|
+
* 为 true 时禁止手动将边连到/从 dynamic-group 节点本身。
|
|
86
|
+
* 默认 false,与历史行为一致;折叠虚拟边不受影响。
|
|
87
|
+
*/
|
|
88
|
+
this.disallowEdgeConnectToGroup = false;
|
|
89
|
+
/**
|
|
90
|
+
* 删除 dynamic-group 时是否级联删除其成员。
|
|
91
|
+
* 默认 true,与 v1.1 以来行为一致;为 false 时仅删除分组,成员保留并解除归属。
|
|
92
|
+
*/
|
|
93
|
+
this.cascadeDeleteChildren = true;
|
|
72
94
|
this.topGroupZIndex = DEFAULT_BOTTOM_Z_INDEX;
|
|
73
95
|
// 存储节点与 group 的映射关系
|
|
74
96
|
this.nodeGroupMap = new Map();
|
|
97
|
+
/** 折叠态虚拟边 id → 所属分组与真实边 id */
|
|
98
|
+
this.collapsedVirtualEdges = new Map();
|
|
99
|
+
/** 折叠隐藏的真实边 id → 分组 id */
|
|
100
|
+
this.collapsedRealEdgeToGroup = new Map();
|
|
101
|
+
/**
|
|
102
|
+
* 折叠态删边:删虚拟边时连带删对应真实边,防止展开后「边复活」(#2395)。
|
|
103
|
+
* Gateway 双分支等场景下,每条虚拟边只映射一条真实边。
|
|
104
|
+
*/
|
|
105
|
+
this.onEdgeDelete = function (_a) {
|
|
106
|
+
var e_1, _b;
|
|
107
|
+
var edge = _a.data;
|
|
108
|
+
var virtualMapping = _this.collapsedVirtualEdges.get(edge.id);
|
|
109
|
+
if (virtualMapping) {
|
|
110
|
+
_this.collapsedVirtualEdges.delete(edge.id);
|
|
111
|
+
_this.collapsedRealEdgeToGroup.delete(virtualMapping.realEdgeId);
|
|
112
|
+
// 仅删除本条映射的真实边,不影响同组其它分支
|
|
113
|
+
if (_this.lf.getEdgeModelById(virtualMapping.realEdgeId)) {
|
|
114
|
+
_this.lf.deleteEdge(virtualMapping.realEdgeId);
|
|
115
|
+
}
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
// 真实边被其它路径删除时,同步清理登记与分组内快照
|
|
119
|
+
var groupId = _this.collapsedRealEdgeToGroup.get(edge.id);
|
|
120
|
+
if (groupId) {
|
|
121
|
+
_this.collapsedRealEdgeToGroup.delete(edge.id);
|
|
122
|
+
}
|
|
123
|
+
try {
|
|
124
|
+
for (var _c = __values(_this.collapsedVirtualEdges.entries()), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
125
|
+
var _e = __read(_d.value, 2), virtualId = _e[0], info = _e[1];
|
|
126
|
+
if (info.realEdgeId === edge.id) {
|
|
127
|
+
_this.collapsedVirtualEdges.delete(virtualId);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
132
|
+
finally {
|
|
133
|
+
try {
|
|
134
|
+
if (_d && !_d.done && (_b = _c.return)) _b.call(_c);
|
|
135
|
+
}
|
|
136
|
+
finally { if (e_1) throw e_1.error; }
|
|
137
|
+
}
|
|
138
|
+
};
|
|
75
139
|
this.onSelectionDrop = function () {
|
|
76
140
|
var selectedNodes = _this.lf.graphModel.getSelectElements().nodes;
|
|
77
141
|
selectedNodes.forEach(function (node) {
|
|
78
142
|
_this.addNodeToGroup(node);
|
|
79
143
|
});
|
|
80
144
|
};
|
|
81
|
-
this.
|
|
145
|
+
this.onNodeAdd = function (_a) {
|
|
146
|
+
var node = _a.data;
|
|
147
|
+
_this.syncGroupChildren(node);
|
|
148
|
+
};
|
|
149
|
+
this.onNodeDndAdd = function (_a) {
|
|
82
150
|
var node = _a.data;
|
|
151
|
+
_this.syncGroupChildren(node);
|
|
83
152
|
_this.addNodeToGroup(node);
|
|
84
153
|
};
|
|
154
|
+
this.onNodeDrop = function (_a) {
|
|
155
|
+
var node = _a.data;
|
|
156
|
+
_this.addNodeToGroup(node);
|
|
157
|
+
};
|
|
158
|
+
this.detachNodeFromGroup = function (groupId, nodeId) {
|
|
159
|
+
var group = _this.lf.getNodeModelById(groupId);
|
|
160
|
+
if (!group)
|
|
161
|
+
return;
|
|
162
|
+
group.removeChild(nodeId);
|
|
163
|
+
_this.nodeGroupMap.delete(nodeId);
|
|
164
|
+
group.setAllowAppendChild(false);
|
|
165
|
+
};
|
|
166
|
+
this.releaseGroupMembers = function (groupModel) {
|
|
167
|
+
if (groupModel.isCollapsed) {
|
|
168
|
+
// 复用展开路径恢复真实边与成员可见性,避免删虚拟边时误删真实边
|
|
169
|
+
groupModel.toggleCollapse(false);
|
|
170
|
+
}
|
|
171
|
+
(0, lodash_es_1.forEach)(Array.from(groupModel.children), function (childId) {
|
|
172
|
+
_this.detachNodeFromGroup(groupModel.id, childId);
|
|
173
|
+
});
|
|
174
|
+
};
|
|
175
|
+
this.removeChildFromOtherGroups = function (childId, ownerGroupId) {
|
|
176
|
+
var preGroupId = _this.nodeGroupMap.get(childId);
|
|
177
|
+
if (preGroupId && preGroupId !== ownerGroupId) {
|
|
178
|
+
var preGroup = _this.lf.getNodeModelById(preGroupId);
|
|
179
|
+
preGroup === null || preGroup === void 0 ? void 0 : preGroup.removeChild(childId);
|
|
180
|
+
}
|
|
181
|
+
(0, lodash_es_1.forEach)(_this.lf.graphModel.nodes, function (node) {
|
|
182
|
+
var _a;
|
|
183
|
+
if (!node.isGroup || node.id === ownerGroupId)
|
|
184
|
+
return;
|
|
185
|
+
var group = node;
|
|
186
|
+
if ((_a = group.children) === null || _a === void 0 ? void 0 : _a.has(childId)) {
|
|
187
|
+
group.removeChild(childId);
|
|
188
|
+
}
|
|
189
|
+
});
|
|
190
|
+
};
|
|
191
|
+
this.setNodeGroup = function (groupId, childId) {
|
|
192
|
+
_this.removeChildFromOtherGroups(childId, groupId);
|
|
193
|
+
_this.nodeGroupMap.set(childId, groupId);
|
|
194
|
+
};
|
|
195
|
+
this.syncGroupChildren = function (node) {
|
|
196
|
+
var nodeModel = _this.lf.getNodeModelById(node.id);
|
|
197
|
+
if (!(nodeModel === null || nodeModel === void 0 ? void 0 : nodeModel.isGroup))
|
|
198
|
+
return;
|
|
199
|
+
var group = nodeModel;
|
|
200
|
+
(0, lodash_es_1.forEach)(Array.from(group.children), function (childId) {
|
|
201
|
+
_this.setNodeGroup(node.id, childId);
|
|
202
|
+
});
|
|
203
|
+
// 新增 group 时进行 this.topGroupZIndex 的校准更新
|
|
204
|
+
_this.calibrateTopGroupZIndex([node]);
|
|
205
|
+
_this.onNodeSelect({
|
|
206
|
+
data: node,
|
|
207
|
+
isSelected: false,
|
|
208
|
+
isMultiple: false,
|
|
209
|
+
});
|
|
210
|
+
};
|
|
85
211
|
this.addNodeToGroup = function (node) {
|
|
212
|
+
var nodeModel = _this.lf.getNodeModelById(node.id);
|
|
213
|
+
var bounds = nodeModel === null || nodeModel === void 0 ? void 0 : nodeModel.getBounds();
|
|
214
|
+
if (!nodeModel || !bounds)
|
|
215
|
+
return;
|
|
86
216
|
// 1. 如果该节点之前已经在 group 中了,则将其从之前的 group 移除
|
|
87
217
|
var preGroupId = _this.nodeGroupMap.get(node.id);
|
|
88
|
-
if (preGroupId) {
|
|
89
|
-
var group = _this.lf.getNodeModelById(preGroupId);
|
|
90
|
-
group.removeChild(node.id);
|
|
91
|
-
_this.nodeGroupMap.delete(node.id);
|
|
92
|
-
group.setAllowAppendChild(false);
|
|
93
|
-
}
|
|
94
218
|
// 2. 然后再判断这个节点是否在某个 group 范围内,如果是,则将其添加到对应的 group 中
|
|
95
|
-
|
|
96
|
-
var
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
if (
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
_this.
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
isMultiple: false,
|
|
219
|
+
// TODO: 找到这个范围内的 groupModel, 并加 node 添加到该 group
|
|
220
|
+
var targetGroup = _this.getGroupByBounds(bounds, node);
|
|
221
|
+
// 同组内移动,成员关系不变(#2412)
|
|
222
|
+
if (preGroupId && (targetGroup === null || targetGroup === void 0 ? void 0 : targetGroup.id) === preGroupId) {
|
|
223
|
+
return;
|
|
224
|
+
}
|
|
225
|
+
if (!targetGroup) {
|
|
226
|
+
if (preGroupId) {
|
|
227
|
+
_this.detachNodeFromGroup(preGroupId, node.id);
|
|
228
|
+
}
|
|
229
|
+
return;
|
|
230
|
+
}
|
|
231
|
+
if (!preGroupId) {
|
|
232
|
+
if (targetGroup.isAllowAppendIn(node)) {
|
|
233
|
+
targetGroup.addChild(node.id);
|
|
234
|
+
// 建立节点与 group 的映射关系放在了 group.addChild 触发的事件中,与直接调用 addChild 的行为保持一致
|
|
235
|
+
targetGroup.setAllowAppendChild(false);
|
|
236
|
+
}
|
|
237
|
+
else {
|
|
238
|
+
// 抛出不允许插入的事件
|
|
239
|
+
_this.lf.emit(events_1.ExtensionEventType.GROUP_NOT_ALLOWED, {
|
|
240
|
+
group: targetGroup.getData(),
|
|
241
|
+
node: node,
|
|
119
242
|
});
|
|
120
243
|
}
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
group: group.getData(),
|
|
134
|
-
node: node,
|
|
135
|
-
});
|
|
136
|
-
}
|
|
244
|
+
return;
|
|
245
|
+
}
|
|
246
|
+
if (targetGroup.isAllowAppendIn(node)) {
|
|
247
|
+
_this.detachNodeFromGroup(preGroupId, node.id);
|
|
248
|
+
targetGroup.addChild(node.id);
|
|
249
|
+
// 建立节点与 group 的映射关系放在了 group.addChild 触发的事件中,与直接调用 addChild 的行为保持一致
|
|
250
|
+
targetGroup.setAllowAppendChild(false);
|
|
251
|
+
}
|
|
252
|
+
else {
|
|
253
|
+
var preGroup = _this.lf.getNodeModelById(preGroupId);
|
|
254
|
+
if (preGroup && (0, utils_1.isBoundsInGroup)(bounds, preGroup)) {
|
|
255
|
+
return;
|
|
137
256
|
}
|
|
257
|
+
_this.detachNodeFromGroup(preGroupId, node.id);
|
|
258
|
+
// 抛出不允许插入的事件
|
|
259
|
+
_this.lf.emit(events_1.ExtensionEventType.GROUP_NOT_ALLOWED, {
|
|
260
|
+
group: targetGroup.getData(),
|
|
261
|
+
node: node,
|
|
262
|
+
});
|
|
138
263
|
}
|
|
139
264
|
};
|
|
140
265
|
this.onGroupAddNode = function (_a) {
|
|
141
266
|
var groupData = _a.data, childId = _a.childId;
|
|
142
|
-
_this.
|
|
267
|
+
_this.setNodeGroup(groupData.id, childId);
|
|
143
268
|
};
|
|
144
269
|
this.removeNodeFromGroup = function (_a) {
|
|
145
270
|
var node = _a.data, model = _a.model;
|
|
146
271
|
if (model.isGroup && node.children) {
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
272
|
+
var groupModel = model;
|
|
273
|
+
if (_this.cascadeDeleteChildren) {
|
|
274
|
+
(0, lodash_es_1.forEach)(Array.from(groupModel.children), function (childId) {
|
|
275
|
+
_this.nodeGroupMap.delete(childId);
|
|
276
|
+
_this.lf.deleteNode(childId);
|
|
277
|
+
});
|
|
278
|
+
}
|
|
279
|
+
else {
|
|
280
|
+
_this.releaseGroupMembers(groupModel);
|
|
281
|
+
}
|
|
151
282
|
}
|
|
152
283
|
var groupId = _this.nodeGroupMap.get(node.id);
|
|
153
284
|
if (groupId) {
|
|
@@ -233,12 +364,8 @@ var DynamicGroup = /** @class */ (function () {
|
|
|
233
364
|
}
|
|
234
365
|
};
|
|
235
366
|
this.onNodeMove = function (_a) {
|
|
236
|
-
var
|
|
237
|
-
var id = data.id
|
|
238
|
-
if (!properties) {
|
|
239
|
-
return;
|
|
240
|
-
}
|
|
241
|
-
var width = properties.width, height = properties.height;
|
|
367
|
+
var data = _a.data;
|
|
368
|
+
var id = data.id;
|
|
242
369
|
var groupId = _this.nodeGroupMap.get(id);
|
|
243
370
|
if (!groupId) {
|
|
244
371
|
return;
|
|
@@ -249,13 +376,13 @@ var DynamicGroup = /** @class */ (function () {
|
|
|
249
376
|
}
|
|
250
377
|
// 当父节点isRestrict=true & autoResize=true
|
|
251
378
|
// 子节点在父节点中移动时,父节点会自动调整大小
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
var
|
|
379
|
+
var childModel = _this.lf.getNodeModelById(id);
|
|
380
|
+
if (!childModel) {
|
|
381
|
+
return;
|
|
382
|
+
}
|
|
383
|
+
// node:mousemove 的 data 在 onDragging 之前采集,坐标滞后;
|
|
384
|
+
// 此时子节点 model 已更新,直接读取 getBounds()。
|
|
385
|
+
var _b = childModel.getBounds(), minX = _b.minX, minY = _b.minY, maxX = _b.maxX, maxY = _b.maxY;
|
|
259
386
|
// step2:比较当前child.bounds与parent.bounds的差异,比如child.minX<parent.minX,那么parent.minX=child.minX
|
|
260
387
|
var hasChange = false;
|
|
261
388
|
var groupBounds = groupModel.getBounds();
|
|
@@ -287,9 +414,24 @@ var DynamicGroup = /** @class */ (function () {
|
|
|
287
414
|
groupModel.moveTo(newGroupX, newGroupY);
|
|
288
415
|
groupModel.width = newGroupWidth;
|
|
289
416
|
groupModel.height = newGroupHeight;
|
|
417
|
+
groupModel.updateExpandedSize(newGroupWidth, newGroupHeight);
|
|
418
|
+
groupModel.setTextPosition();
|
|
419
|
+
};
|
|
420
|
+
this.onNodeResize = function (_a) {
|
|
421
|
+
var model = _a.model;
|
|
422
|
+
if ((model === null || model === void 0 ? void 0 : model.isGroup) && !model.isCollapsed) {
|
|
423
|
+
;
|
|
424
|
+
model.setTextPosition();
|
|
425
|
+
}
|
|
290
426
|
};
|
|
291
427
|
this.onGraphRendered = function (_a) {
|
|
292
428
|
var data = _a.data;
|
|
429
|
+
// lf.render / graphDataToModel 不会逐节点触发 node:delete,需在整图重建时重置插件侧状态
|
|
430
|
+
_this.nodeGroupMap.clear();
|
|
431
|
+
_this.collapsedVirtualEdges.clear();
|
|
432
|
+
_this.collapsedRealEdgeToGroup.clear();
|
|
433
|
+
_this.activeGroup = undefined;
|
|
434
|
+
_this.topGroupZIndex = DEFAULT_BOTTOM_Z_INDEX;
|
|
293
435
|
(0, lodash_es_1.forEach)(data.nodes, function (node) {
|
|
294
436
|
if (node.children) {
|
|
295
437
|
(0, lodash_es_1.forEach)(node.children, function (childId) {
|
|
@@ -317,6 +459,20 @@ var DynamicGroup = /** @class */ (function () {
|
|
|
317
459
|
return this.lf.getNodeModelById(groupId);
|
|
318
460
|
}
|
|
319
461
|
};
|
|
462
|
+
DynamicGroup.prototype.registerCollapsedVirtualEdge = function (virtualId, groupId, realEdgeId) {
|
|
463
|
+
// 双向索引:删虚拟边时能找到真实边;删真实边时能清理虚拟边登记
|
|
464
|
+
this.collapsedVirtualEdges.set(virtualId, { groupId: groupId, realEdgeId: realEdgeId });
|
|
465
|
+
this.collapsedRealEdgeToGroup.set(realEdgeId, groupId);
|
|
466
|
+
};
|
|
467
|
+
DynamicGroup.prototype.unregisterCollapsedVirtualEdge = function (virtualId) {
|
|
468
|
+
var info = this.collapsedVirtualEdges.get(virtualId);
|
|
469
|
+
if (info) {
|
|
470
|
+
this.collapsedVirtualEdges.delete(virtualId);
|
|
471
|
+
if (this.collapsedRealEdgeToGroup.get(info.realEdgeId) === info.groupId) {
|
|
472
|
+
this.collapsedRealEdgeToGroup.delete(info.realEdgeId);
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
};
|
|
320
476
|
/**
|
|
321
477
|
* 获取自定位置及其所属分组
|
|
322
478
|
* 当分组重合时,优先返回最上层的分组
|
|
@@ -507,35 +663,22 @@ var DynamicGroup = /** @class */ (function () {
|
|
|
507
663
|
* @param newHeight
|
|
508
664
|
*/
|
|
509
665
|
DynamicGroup.prototype.checkGroupBoundsWithChildren = function (groupModel, deltaX, deltaY, newWidth, newHeight) {
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
var groupMinY = newY - newHeight / 2;
|
|
517
|
-
var groupMaxX = newX + newWidth / 2;
|
|
518
|
-
var groupMaxY = newY + newHeight / 2;
|
|
519
|
-
var childrenArray = Array.from(children);
|
|
520
|
-
for (var i = 0; i < childrenArray.length; i++) {
|
|
521
|
-
var childId = childrenArray[i];
|
|
522
|
-
var child = this.lf.getNodeModelById(childId);
|
|
523
|
-
if (!child) {
|
|
524
|
-
continue;
|
|
525
|
-
}
|
|
526
|
-
var childBounds = child.getBounds();
|
|
527
|
-
var minX = childBounds.minX, minY = childBounds.minY, maxX = childBounds.maxX, maxY = childBounds.maxY;
|
|
528
|
-
// parent:resize后的bounds不能小于child:bounds,否则阻止其resize
|
|
529
|
-
var canResize = groupMinX <= minX &&
|
|
530
|
-
groupMinY <= minY &&
|
|
531
|
-
groupMaxX >= maxX &&
|
|
532
|
-
groupMaxY >= maxY;
|
|
533
|
-
if (!canResize) {
|
|
534
|
-
return false;
|
|
535
|
-
}
|
|
536
|
-
}
|
|
666
|
+
var _this = this;
|
|
667
|
+
var childrenBounds = (0, utils_1.getChildrenBounds)(groupModel, function (id) {
|
|
668
|
+
return _this.lf.getNodeModelById(id);
|
|
669
|
+
});
|
|
670
|
+
if (!childrenBounds) {
|
|
671
|
+
return true;
|
|
537
672
|
}
|
|
538
|
-
|
|
673
|
+
var newX = groupModel.x + deltaX / 2;
|
|
674
|
+
var newY = groupModel.y + deltaY / 2;
|
|
675
|
+
var groupBounds = {
|
|
676
|
+
minX: newX - newWidth / 2,
|
|
677
|
+
minY: newY - newHeight / 2,
|
|
678
|
+
maxX: newX + newWidth / 2,
|
|
679
|
+
maxY: newY + newHeight / 2,
|
|
680
|
+
};
|
|
681
|
+
return (0, utils_1.isGroupBoundsContainsChildren)(groupBounds, childrenBounds);
|
|
539
682
|
};
|
|
540
683
|
/**
|
|
541
684
|
* Group 插件的初始化方法
|
|
@@ -582,27 +725,41 @@ var DynamicGroup = /** @class */ (function () {
|
|
|
582
725
|
}
|
|
583
726
|
return true;
|
|
584
727
|
});
|
|
585
|
-
// https://github.com/didi/LogicFlow/issues/1442
|
|
586
|
-
// https://github.com/didi/LogicFlow/issues/937
|
|
587
728
|
// 添加分组节点resize规则
|
|
588
|
-
//
|
|
589
|
-
// 并且在isRestrict限制模式下,transformWidthContainer即使设置为true,也无效
|
|
729
|
+
// 所有分组默认不可缩小到直接子节点占地面积以下
|
|
590
730
|
graphModel.addNodeResizeRules(function (model, deltaX, deltaY, width, height) {
|
|
591
|
-
if (model.isGroup
|
|
731
|
+
if (model.isGroup) {
|
|
592
732
|
return _this.checkGroupBoundsWithChildren(model, deltaX, deltaY, width, height);
|
|
593
733
|
}
|
|
594
734
|
return true;
|
|
595
735
|
});
|
|
596
736
|
graphModel.dynamicGroup = this;
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
lf.
|
|
600
|
-
lf.
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
737
|
+
// cascadeDeleteChildren=false 时须在 core 删除「指向分组的边」之前释放成员,
|
|
738
|
+
// 否则折叠虚拟边被删会连带删掉真实边(graphModel.deleteNode 先删边再 emit node:delete)
|
|
739
|
+
this.originDeleteNode = lf.deleteNode.bind(lf);
|
|
740
|
+
lf.deleteNode = function (nodeId) {
|
|
741
|
+
var nodeModel = lf.getNodeModelById(nodeId);
|
|
742
|
+
if (!_this.cascadeDeleteChildren && (nodeModel === null || nodeModel === void 0 ? void 0 : nodeModel.isGroup)) {
|
|
743
|
+
var groupModel = nodeModel;
|
|
744
|
+
if (groupModel.children.size > 0) {
|
|
745
|
+
_this.releaseGroupMembers(groupModel);
|
|
746
|
+
}
|
|
747
|
+
}
|
|
748
|
+
return _this.originDeleteNode(nodeId);
|
|
749
|
+
};
|
|
750
|
+
lf.on(core_1.EventType.NODE_ADD, this.onNodeAdd);
|
|
751
|
+
lf.on(core_1.EventType.NODE_DND_ADD, this.onNodeDndAdd);
|
|
752
|
+
lf.on(core_1.EventType.NODE_DROP, this.onNodeDrop);
|
|
753
|
+
lf.on(core_1.EventType.SELECTION_DROP, this.onSelectionDrop);
|
|
754
|
+
lf.on(core_1.EventType.NODE_DELETE, this.removeNodeFromGroup);
|
|
755
|
+
lf.on(core_1.EventType.EDGE_DELETE, this.onEdgeDelete);
|
|
756
|
+
lf.on(events_1.NODE_DRAG_EVENTS, this.onNodeDrag);
|
|
757
|
+
lf.on(core_1.EventType.SELECTION_DRAG, this.onSelectionDrag);
|
|
758
|
+
lf.on(core_1.EventType.NODE_CLICK, this.onNodeSelect);
|
|
759
|
+
lf.on(core_1.EventType.NODE_MOUSEMOVE, this.onNodeMove);
|
|
760
|
+
lf.on(core_1.EventType.NODE_RESIZE, this.onNodeResize);
|
|
761
|
+
lf.on(core_1.EventType.GRAPH_RENDERED, this.onGraphRendered);
|
|
762
|
+
lf.on(events_1.ExtensionEventType.GROUP_ADD_NODE, this.onGroupAddNode);
|
|
606
763
|
// https://github.com/didi/LogicFlow/issues/1346
|
|
607
764
|
// 重写 addElements() 方法,在 addElements() 原有基础上增加对 group 内部所有 nodes 和 edges 的复制功能
|
|
608
765
|
// 使用场景:addElements api 项目内部目前只在快捷键粘贴时使用(此处解决的也应该是粘贴场景的问题)
|
|
@@ -647,16 +804,23 @@ var DynamicGroup = /** @class */ (function () {
|
|
|
647
804
|
DynamicGroup.prototype.render = function () { };
|
|
648
805
|
DynamicGroup.prototype.destroy = function () {
|
|
649
806
|
// 销毁监听的事件,并移除渲染的 dom 内容
|
|
650
|
-
this.lf.off(
|
|
651
|
-
this.lf.off(
|
|
652
|
-
this.lf.off(
|
|
653
|
-
this.lf.off(
|
|
654
|
-
this.lf.off(
|
|
655
|
-
this.lf.off(
|
|
656
|
-
this.lf.off(
|
|
657
|
-
this.lf.off(
|
|
658
|
-
this.lf.off(
|
|
807
|
+
this.lf.off(core_1.EventType.NODE_ADD, this.onNodeAdd);
|
|
808
|
+
this.lf.off(core_1.EventType.NODE_DND_ADD, this.onNodeDndAdd);
|
|
809
|
+
this.lf.off(core_1.EventType.NODE_DROP, this.onNodeDrop);
|
|
810
|
+
this.lf.off(core_1.EventType.SELECTION_DROP, this.onSelectionDrop);
|
|
811
|
+
this.lf.off(core_1.EventType.NODE_DELETE, this.removeNodeFromGroup);
|
|
812
|
+
this.lf.off(core_1.EventType.EDGE_DELETE, this.onEdgeDelete);
|
|
813
|
+
this.lf.off(events_1.NODE_DRAG_EVENTS, this.onNodeDrag);
|
|
814
|
+
this.lf.off(core_1.EventType.SELECTION_DRAG, this.onSelectionDrag);
|
|
815
|
+
this.lf.off(core_1.EventType.NODE_CLICK, this.onNodeSelect);
|
|
816
|
+
this.lf.off(core_1.EventType.NODE_MOUSEMOVE, this.onNodeMove);
|
|
817
|
+
this.lf.off(core_1.EventType.NODE_RESIZE, this.onNodeResize);
|
|
818
|
+
this.lf.off(core_1.EventType.GRAPH_RENDERED, this.onGraphRendered);
|
|
819
|
+
this.lf.off(events_1.ExtensionEventType.GROUP_ADD_NODE, this.onGroupAddNode);
|
|
659
820
|
// 还原 lf.addElements 方法?
|
|
821
|
+
if (this.originDeleteNode) {
|
|
822
|
+
this.lf.deleteNode = this.originDeleteNode;
|
|
823
|
+
}
|
|
660
824
|
// 移除 graphModel 上重写的 addNodeMoveRules 方法?
|
|
661
825
|
// TODO: 讨论一下插件该具体做些什么
|
|
662
826
|
};
|
|
@@ -43,6 +43,11 @@ export type IGroupNodeProperties = {
|
|
|
43
43
|
* 分组节点是否自动置顶
|
|
44
44
|
*/
|
|
45
45
|
autoToFront?: boolean;
|
|
46
|
+
/**
|
|
47
|
+
* 是否允许手动将边连到/从本分组节点。
|
|
48
|
+
* 显式设置时优先于插件选项 disallowEdgeConnectToGroup。
|
|
49
|
+
*/
|
|
50
|
+
allowEdgeConnect?: boolean;
|
|
46
51
|
isAllowAppendIn?: (_nodeData: any) => boolean;
|
|
47
52
|
} & IRectNodeProperties;
|
|
48
53
|
export declare class DynamicGroupNodeModel extends RectNodeModel<IGroupNodeProperties> {
|
|
@@ -63,6 +68,28 @@ export declare class DynamicGroupNodeModel extends RectNodeModel<IGroupNodePrope
|
|
|
63
68
|
constructor(data: NodeConfig<IGroupNodeProperties>, graphModel: GraphModel);
|
|
64
69
|
initNodeData(data: LogicFlow.NodeConfig<IGroupNodeProperties>): void;
|
|
65
70
|
setAttributes(): void;
|
|
71
|
+
getTextStyle(): Record<string, unknown> & {
|
|
72
|
+
[x: string]: unknown;
|
|
73
|
+
fill?: string | undefined;
|
|
74
|
+
stroke?: string | undefined;
|
|
75
|
+
strokeWidth?: number | undefined;
|
|
76
|
+
radius?: number | undefined;
|
|
77
|
+
rx?: number | undefined;
|
|
78
|
+
ry?: number | undefined;
|
|
79
|
+
width?: number | undefined;
|
|
80
|
+
height?: number | undefined;
|
|
81
|
+
path?: string | undefined;
|
|
82
|
+
overflowMode?: "default" | "autoWrap" | "ellipsis" | undefined;
|
|
83
|
+
textWidth?: number | undefined;
|
|
84
|
+
background?: LogicFlow.CommonTheme | undefined;
|
|
85
|
+
wrapPadding?: string | undefined;
|
|
86
|
+
color?: string | undefined;
|
|
87
|
+
fontSize: number;
|
|
88
|
+
lineHeight?: number | undefined;
|
|
89
|
+
textAnchor?: "middle" | "start" | "end" | undefined;
|
|
90
|
+
dominantBaseline?: "middle" | "central" | "auto" | "text-bottom" | "alphabetic" | "ideographic" | "mathematical" | "hanging" | "text-top" | undefined;
|
|
91
|
+
};
|
|
92
|
+
setProperties(properties: Partial<IGroupNodeProperties>): void;
|
|
66
93
|
getData(): NodeData;
|
|
67
94
|
/**
|
|
68
95
|
* 获取分组内的节点
|
|
@@ -82,10 +109,15 @@ export declare class DynamicGroupNodeModel extends RectNodeModel<IGroupNodePrope
|
|
|
82
109
|
* @param collapse {boolean} true -> 折叠;false -> 展开
|
|
83
110
|
*/
|
|
84
111
|
toggleCollapse(collapse?: boolean): void;
|
|
112
|
+
getTitleHtmlRect(): import("./utils").TitleForeignObjectRect;
|
|
113
|
+
/**
|
|
114
|
+
* autoResize 更新分组尺寸后同步展开态快照,避免折叠/展开回退到旧尺寸。
|
|
115
|
+
*/
|
|
116
|
+
updateExpandedSize(width: number, height: number): void;
|
|
85
117
|
setTextPosition(): void;
|
|
86
118
|
private collapse;
|
|
87
119
|
private expand;
|
|
88
|
-
createVirtualEdge(edgeConfig: EdgeConfig):
|
|
120
|
+
createVirtualEdge(edgeConfig: EdgeConfig, realEdgeId: string): BaseEdgeModel<LogicFlow.PropertiesType>;
|
|
89
121
|
/**
|
|
90
122
|
* 折叠分组的时候,需要处理分组自身的连线和分组内部子节点上的连线
|
|
91
123
|
* 边的分类:
|
|
@@ -133,6 +165,21 @@ export declare class DynamicGroupNodeModel extends RectNodeModel<IGroupNodePrope
|
|
|
133
165
|
/**
|
|
134
166
|
* 重写 Group 节点的 Resize Outline
|
|
135
167
|
*/
|
|
168
|
+
/**
|
|
169
|
+
* 展开态手动连线是否允许连到/从分组节点本身。
|
|
170
|
+
* 未设置 allowEdgeConnect 时由插件 disallowEdgeConnectToGroup 决定;折叠虚拟边不受影响。
|
|
171
|
+
*/
|
|
172
|
+
isManualEdgeConnectAllowed(): boolean;
|
|
173
|
+
getConnectedTargetRules(): import("@logicflow/core").Model.ConnectRule[];
|
|
174
|
+
getConnectedSourceRules(): import("@logicflow/core").Model.ConnectRule[];
|
|
175
|
+
/**
|
|
176
|
+
* 保留锚点供折叠态虚拟边使用;禁止手动连线时关闭 edgeAddable。
|
|
177
|
+
*/
|
|
178
|
+
getDefaultAnchor(): {
|
|
179
|
+
x: number;
|
|
180
|
+
y: number;
|
|
181
|
+
id: string;
|
|
182
|
+
}[];
|
|
136
183
|
getAnchorStyle(): LogicFlow.AnchorTheme;
|
|
137
184
|
/**
|
|
138
185
|
* 设置分组节点 drop 区域的样式
|