@logicflow/extension 1.2.25 → 1.2.27
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/cjs/NodeResize/Control/Control.js +43 -18
- package/cjs/materials/group/index.js +57 -0
- package/es/NodeResize/Control/Control.d.ts +3 -1
- package/es/NodeResize/Control/Control.js +43 -18
- package/es/materials/group/index.d.ts +3 -1
- package/es/materials/group/index.js +57 -0
- package/lib/Group.js +1 -1
- package/lib/NodeResize.js +1 -1
- package/package.json +2 -2
- package/types/NodeResize/BasicShape/Polygon.d.ts +0 -10
- package/types/NodeResize/BasicShape/Rect.d.ts +0 -17
- package/types/NodeResize/Control/Control.d.ts +0 -66
- package/types/NodeResize/Control/ControlGroup.d.ts +0 -13
- package/types/NodeResize/Control/Util.d.ts +0 -33
- package/types/NodeResize/Node/DiamondResize.d.ts +0 -30
- package/types/NodeResize/Node/EllipseResize.d.ts +0 -30
- package/types/NodeResize/Node/HtmlResize.d.ts +0 -30
- package/types/NodeResize/Node/RectResize.d.ts +0 -32
- package/types/NodeResize/index.d.ts +0 -11
- package/types/bpmn/constant.d.ts +0 -46
- package/types/bpmn/events/EndEvent.d.ts +0 -21
- package/types/bpmn/events/StartEvent.d.ts +0 -17
- package/types/bpmn/flow/SequenceFlow.d.ts +0 -15
- package/types/bpmn/gateways/ExclusiveGateway.d.ts +0 -16
- package/types/bpmn/getBpmnId.d.ts +0 -1
- package/types/bpmn/index.d.ts +0 -13
- package/types/bpmn/tasks/ServiceTask.d.ts +0 -17
- package/types/bpmn/tasks/UserTask.d.ts +0 -17
- package/types/bpmn-adapter/bpmnIds.d.ts +0 -1
- package/types/bpmn-adapter/index.d.ts +0 -63
- package/types/bpmn-adapter/json2xml.d.ts +0 -3
- package/types/bpmn-adapter/xml2json.d.ts +0 -2
- package/types/bpmn-elements/index.d.ts +0 -17
- package/types/bpmn-elements/presets/Event/EndEventFactory.d.ts +0 -5
- package/types/bpmn-elements/presets/Event/IntermediateCatchEvent.d.ts +0 -5
- package/types/bpmn-elements/presets/Event/IntermediateThrowEvent.d.ts +0 -5
- package/types/bpmn-elements/presets/Event/StartEventFactory.d.ts +0 -5
- package/types/bpmn-elements/presets/Event/boundaryEventFactory.d.ts +0 -5
- package/types/bpmn-elements/presets/Event/index.d.ts +0 -2
- package/types/bpmn-elements/presets/Flow/index.d.ts +0 -7
- package/types/bpmn-elements/presets/Flow/sequenceFlow.d.ts +0 -5
- package/types/bpmn-elements/presets/Gateway/gateway.d.ts +0 -17
- package/types/bpmn-elements/presets/Gateway/index.d.ts +0 -2
- package/types/bpmn-elements/presets/Task/index.d.ts +0 -2
- package/types/bpmn-elements/presets/Task/subProcess.d.ts +0 -5
- package/types/bpmn-elements/presets/Task/task.d.ts +0 -12
- package/types/bpmn-elements/presets/icons.d.ts +0 -25
- package/types/bpmn-elements/utils.d.ts +0 -2
- package/types/bpmn-elements-adapter/constant.d.ts +0 -66
- package/types/bpmn-elements-adapter/index.d.ts +0 -103
- package/types/bpmn-elements-adapter/json2xml.d.ts +0 -3
- package/types/bpmn-elements-adapter/xml2json.d.ts +0 -2
- package/types/components/context-menu/index.d.ts +0 -34
- package/types/components/control/index.d.ts +0 -26
- package/types/components/dnd-panel/index.d.ts +0 -26
- package/types/components/highlight/index.d.ts +0 -21
- package/types/components/menu/index.d.ts +0 -50
- package/types/components/mini-map/index.d.ts +0 -88
- package/types/components/selection-select/index.d.ts +0 -43
- package/types/index.d.ts +0 -21
- package/types/insert-node-in-polyline/edge.d.ts +0 -31
- package/types/insert-node-in-polyline/index.d.ts +0 -28
- package/types/materials/curved-edge/index.d.ts +0 -14
- package/types/materials/group/GroupNode.d.ts +0 -125
- package/types/materials/group/index.d.ts +0 -65
- package/types/tools/auto-layout/index.d.ts +0 -40
- package/types/tools/flow-path/index.d.ts +0 -47
- package/types/tools/snapshot/index.d.ts +0 -26
- package/types/turbo-adapter/index.d.ts +0 -21
- package/types/type/index.d.ts +0 -6
|
@@ -59,7 +59,7 @@ var Control = /** @class */ (function (_super) {
|
|
|
59
59
|
};
|
|
60
60
|
// 计算control拖动后,节点的宽高
|
|
61
61
|
_this.getResize = function (_a) {
|
|
62
|
-
var index = _a.index, deltaX = _a.deltaX, deltaY = _a.deltaY, width = _a.width, height = _a.height, PCTResizeInfo = _a.PCTResizeInfo, _b = _a.pct, pct = _b === void 0 ? 1 : _b;
|
|
62
|
+
var index = _a.index, deltaX = _a.deltaX, deltaY = _a.deltaY, width = _a.width, height = _a.height, PCTResizeInfo = _a.PCTResizeInfo, _b = _a.pct, pct = _b === void 0 ? 1 : _b, _c = _a.freezeWidth, freezeWidth = _c === void 0 ? false : _c, _d = _a.freezeHeight, freezeHeight = _d === void 0 ? false : _d;
|
|
63
63
|
var resize = { width: width, height: height, deltaX: deltaX, deltaY: deltaY };
|
|
64
64
|
if (PCTResizeInfo) {
|
|
65
65
|
var sensitivity = 4; // 越低越灵敏
|
|
@@ -117,22 +117,23 @@ var Control = /** @class */ (function (_super) {
|
|
|
117
117
|
resize.deltaY = deltaY / pct;
|
|
118
118
|
return resize;
|
|
119
119
|
}
|
|
120
|
+
// 如果限制了宽/高不变,对应的width/height保持一致
|
|
120
121
|
switch (index) {
|
|
121
122
|
case 0:
|
|
122
|
-
resize.width = width - deltaX * pct;
|
|
123
|
-
resize.height = height - deltaY * pct;
|
|
123
|
+
resize.width = freezeWidth ? width : width - deltaX * pct;
|
|
124
|
+
resize.height = freezeHeight ? height : height - deltaY * pct;
|
|
124
125
|
break;
|
|
125
126
|
case 1:
|
|
126
|
-
resize.width = width + deltaX * pct;
|
|
127
|
-
resize.height = height - deltaY * pct;
|
|
127
|
+
resize.width = freezeWidth ? width : width + deltaX * pct;
|
|
128
|
+
resize.height = freezeHeight ? height : height - deltaY * pct;
|
|
128
129
|
break;
|
|
129
130
|
case 2:
|
|
130
|
-
resize.width = width + deltaX * pct;
|
|
131
|
-
resize.height = height + deltaY * pct;
|
|
131
|
+
resize.width = freezeWidth ? width : width + deltaX * pct;
|
|
132
|
+
resize.height = freezeHeight ? height : height + deltaY * pct;
|
|
132
133
|
break;
|
|
133
134
|
case 3:
|
|
134
|
-
resize.width = width - deltaX * pct;
|
|
135
|
-
resize.height = height + deltaY * pct;
|
|
135
|
+
resize.width = freezeWidth ? width : width - deltaX * pct;
|
|
136
|
+
resize.height = freezeHeight ? height : height + deltaY * pct;
|
|
136
137
|
break;
|
|
137
138
|
default:
|
|
138
139
|
break;
|
|
@@ -172,8 +173,11 @@ var Control = /** @class */ (function (_super) {
|
|
|
172
173
|
_this.updateRect = function (_a) {
|
|
173
174
|
var deltaX = _a.deltaX, deltaY = _a.deltaY;
|
|
174
175
|
var _b = _this.nodeModel, id = _b.id, x = _b.x, y = _b.y, width = _b.width, height = _b.height, radius = _b.radius, PCTResizeInfo = _b.PCTResizeInfo;
|
|
176
|
+
var _c = _this.nodeModel, minWidth = _c.minWidth, minHeight = _c.minHeight, maxWidth = _c.maxWidth, maxHeight = _c.maxHeight;
|
|
175
177
|
// 更新中心点位置,更新文案位置
|
|
176
178
|
var index = _this.index;
|
|
179
|
+
var freezeWidth = (minWidth === maxWidth);
|
|
180
|
+
var freezeHeight = (minHeight === maxHeight);
|
|
177
181
|
var size = _this.getResize({
|
|
178
182
|
index: index,
|
|
179
183
|
deltaX: deltaX,
|
|
@@ -182,9 +186,10 @@ var Control = /** @class */ (function (_super) {
|
|
|
182
186
|
height: height,
|
|
183
187
|
PCTResizeInfo: PCTResizeInfo,
|
|
184
188
|
pct: 1,
|
|
189
|
+
freezeWidth: freezeWidth,
|
|
190
|
+
freezeHeight: freezeHeight,
|
|
185
191
|
});
|
|
186
192
|
// 限制放大缩小的最大最小范围
|
|
187
|
-
var _c = _this.nodeModel, minWidth = _c.minWidth, minHeight = _c.minHeight, maxWidth = _c.maxWidth, maxHeight = _c.maxHeight;
|
|
188
193
|
if (size.width < minWidth
|
|
189
194
|
|| size.width > maxWidth
|
|
190
195
|
|| size.height < minHeight
|
|
@@ -193,7 +198,11 @@ var Control = /** @class */ (function (_super) {
|
|
|
193
198
|
_this.dragHandler.cancelDrag();
|
|
194
199
|
return;
|
|
195
200
|
}
|
|
196
|
-
|
|
201
|
+
// 如果限制了宽/高不变,对应的x/y不产生位移
|
|
202
|
+
_this.updatePosition({
|
|
203
|
+
deltaX: freezeWidth ? 0 : size.deltaX,
|
|
204
|
+
deltaY: freezeHeight ? 0 : size.deltaY,
|
|
205
|
+
});
|
|
197
206
|
// 更新宽高
|
|
198
207
|
_this.nodeModel.width = size.width;
|
|
199
208
|
_this.nodeModel.height = size.height;
|
|
@@ -227,6 +236,9 @@ var Control = /** @class */ (function (_super) {
|
|
|
227
236
|
var deltaX = _a.deltaX, deltaY = _a.deltaY;
|
|
228
237
|
var _b = _this.nodeModel, id = _b.id, rx = _b.rx, ry = _b.ry, x = _b.x, y = _b.y, PCTResizeInfo = _b.PCTResizeInfo;
|
|
229
238
|
var index = _this.index;
|
|
239
|
+
var _c = _this.nodeModel, minWidth = _c.minWidth, minHeight = _c.minHeight, maxWidth = _c.maxWidth, maxHeight = _c.maxHeight;
|
|
240
|
+
var freezeWidth = (minWidth === maxWidth);
|
|
241
|
+
var freezeHeight = (minHeight === maxHeight);
|
|
230
242
|
var width = rx;
|
|
231
243
|
var height = ry;
|
|
232
244
|
var size = _this.getResize({
|
|
@@ -237,9 +249,10 @@ var Control = /** @class */ (function (_super) {
|
|
|
237
249
|
height: height,
|
|
238
250
|
PCTResizeInfo: PCTResizeInfo,
|
|
239
251
|
pct: 1 / 2,
|
|
252
|
+
freezeWidth: freezeWidth,
|
|
253
|
+
freezeHeight: freezeHeight,
|
|
240
254
|
});
|
|
241
255
|
// 限制放大缩小的最大最小范围
|
|
242
|
-
var _c = _this.nodeModel, minWidth = _c.minWidth, minHeight = _c.minHeight, maxWidth = _c.maxWidth, maxHeight = _c.maxHeight;
|
|
243
256
|
if (size.width < (minWidth / 2)
|
|
244
257
|
|| size.width > (maxWidth / 2)
|
|
245
258
|
|| size.height < (minHeight / 2)
|
|
@@ -248,7 +261,11 @@ var Control = /** @class */ (function (_super) {
|
|
|
248
261
|
return;
|
|
249
262
|
}
|
|
250
263
|
// 更新中心点位置,更新文案位置
|
|
251
|
-
|
|
264
|
+
// 如果限制了宽/高不变,对应的x/y不产生位移
|
|
265
|
+
_this.updatePosition({
|
|
266
|
+
deltaX: freezeWidth ? 0 : size.deltaX,
|
|
267
|
+
deltaY: freezeHeight ? 0 : size.deltaY,
|
|
268
|
+
});
|
|
252
269
|
// 更新rx ry,宽高为计算属性自动更新
|
|
253
270
|
// @ts-ignore
|
|
254
271
|
_this.nodeModel.rx = size.width;
|
|
@@ -277,6 +294,9 @@ var Control = /** @class */ (function (_super) {
|
|
|
277
294
|
var deltaX = _a.deltaX, deltaY = _a.deltaY;
|
|
278
295
|
var _b = _this.nodeModel, id = _b.id, rx = _b.rx, ry = _b.ry, x = _b.x, y = _b.y, PCTResizeInfo = _b.PCTResizeInfo;
|
|
279
296
|
var index = _this.index;
|
|
297
|
+
var _c = _this.nodeModel, minWidth = _c.minWidth, minHeight = _c.minHeight, maxWidth = _c.maxWidth, maxHeight = _c.maxHeight;
|
|
298
|
+
var freezeWidth = (minWidth === maxWidth);
|
|
299
|
+
var freezeHeight = (minHeight === maxHeight);
|
|
280
300
|
var width = rx;
|
|
281
301
|
var height = ry;
|
|
282
302
|
var size = _this.getResize({
|
|
@@ -287,9 +307,10 @@ var Control = /** @class */ (function (_super) {
|
|
|
287
307
|
height: height,
|
|
288
308
|
PCTResizeInfo: PCTResizeInfo,
|
|
289
309
|
pct: 1 / 2,
|
|
310
|
+
freezeWidth: freezeWidth,
|
|
311
|
+
freezeHeight: freezeHeight,
|
|
290
312
|
});
|
|
291
313
|
// 限制放大缩小的最大最小范围
|
|
292
|
-
var _c = _this.nodeModel, minWidth = _c.minWidth, minHeight = _c.minHeight, maxWidth = _c.maxWidth, maxHeight = _c.maxHeight;
|
|
293
314
|
if (size.width < (minWidth / 2)
|
|
294
315
|
|| size.width > (maxWidth / 2)
|
|
295
316
|
|| size.height < (minHeight / 2)
|
|
@@ -298,7 +319,11 @@ var Control = /** @class */ (function (_super) {
|
|
|
298
319
|
return;
|
|
299
320
|
}
|
|
300
321
|
// 更新中心点位置,更新文案位置
|
|
301
|
-
|
|
322
|
+
// 如果限制了宽/高不变,对应的x/y不产生位移
|
|
323
|
+
_this.updatePosition({
|
|
324
|
+
deltaX: freezeWidth ? 0 : size.deltaX,
|
|
325
|
+
deltaY: freezeHeight ? 0 : size.deltaY,
|
|
326
|
+
});
|
|
302
327
|
// 更新rx ry,宽高为计算属性自动更新
|
|
303
328
|
// @ts-ignore
|
|
304
329
|
_this.nodeModel.rx = size.width;
|
|
@@ -350,13 +375,13 @@ var Control = /** @class */ (function (_super) {
|
|
|
350
375
|
* 由于将拖拽放大缩小改成丝滑模式,这个时候需要在拖拽结束的时候,将节点的位置更新到grid上.
|
|
351
376
|
*/
|
|
352
377
|
_this.onDragEnd = function () {
|
|
353
|
-
// 先触发onDragging()->更新边->再触发用户自定义的getDefaultAnchor(),所以onDragging()拿到的anchors是滞后的
|
|
354
|
-
// 为了正确设置最终的位置,应该在拖拽结束的时候,再设置一次边的Point位置,此时拿到的anchors是最新的
|
|
355
|
-
_this.updateEdgePointByAnchors();
|
|
356
378
|
var _a = _this.graphModel.gridSize, gridSize = _a === void 0 ? 1 : _a;
|
|
357
379
|
var x = gridSize * Math.round(_this.nodeModel.x / gridSize);
|
|
358
380
|
var y = gridSize * Math.round(_this.nodeModel.y / gridSize);
|
|
359
381
|
_this.nodeModel.moveTo(x, y);
|
|
382
|
+
// 先触发onDragging()->更新边->再触发用户自定义的getDefaultAnchor(),所以onDragging()拿到的anchors是滞后的
|
|
383
|
+
// 为了正确设置最终的位置,应该在拖拽结束的时候,再设置一次边的Point位置,此时拿到的anchors是最新的
|
|
384
|
+
_this.updateEdgePointByAnchors();
|
|
360
385
|
};
|
|
361
386
|
_this.index = props.index;
|
|
362
387
|
_this.nodeModel = props.model;
|
|
@@ -65,6 +65,8 @@ var Group = /** @class */ (function () {
|
|
|
65
65
|
});
|
|
66
66
|
}
|
|
67
67
|
});
|
|
68
|
+
// 初始化nodes时进行this.topGroupZIndex的校准更新
|
|
69
|
+
_this.checkAndCorrectTopGroupZIndex(data.nodes);
|
|
68
70
|
}
|
|
69
71
|
};
|
|
70
72
|
this.appendNodeToGroup = function (_a) {
|
|
@@ -95,6 +97,8 @@ var Group = /** @class */ (function () {
|
|
|
95
97
|
data.children.forEach(function (nodeId) {
|
|
96
98
|
_this.nodeGroupMap.set(nodeId, data.id);
|
|
97
99
|
});
|
|
100
|
+
// 新增node时进行this.topGroupZIndex的校准更新
|
|
101
|
+
_this.checkAndCorrectTopGroupZIndex([data]);
|
|
98
102
|
_this.nodeSelected({ data: data, isSelected: false, isMultiple: false });
|
|
99
103
|
}
|
|
100
104
|
if (!group)
|
|
@@ -144,6 +148,59 @@ var Group = /** @class */ (function () {
|
|
|
144
148
|
_this.activeGroup = newGroup;
|
|
145
149
|
_this.activeGroup.setAllowAppendChild(true);
|
|
146
150
|
};
|
|
151
|
+
this.findNodeAndChildMaxZIndex = function (nodeModel) {
|
|
152
|
+
var maxZIndex = DEFAULT_BOTTOM_Z_INDEX;
|
|
153
|
+
if (nodeModel.isGroup) {
|
|
154
|
+
maxZIndex = nodeModel.zIndex > maxZIndex ? nodeModel.zIndex : maxZIndex;
|
|
155
|
+
}
|
|
156
|
+
if (nodeModel.children) {
|
|
157
|
+
nodeModel.children.forEach(function (nodeId) {
|
|
158
|
+
if (typeof nodeId === 'object') {
|
|
159
|
+
// 正常情况下, GroupNodeModel.children是一个id数组,这里只是做个兼容
|
|
160
|
+
// @ts-ignore
|
|
161
|
+
nodeId = nodeId.id;
|
|
162
|
+
}
|
|
163
|
+
var child = _this.lf.getNodeModelById(nodeId);
|
|
164
|
+
if (child.isGroup) {
|
|
165
|
+
var childMaxZIndex = _this.findNodeAndChildMaxZIndex(child);
|
|
166
|
+
maxZIndex = childMaxZIndex > maxZIndex ? childMaxZIndex : maxZIndex;
|
|
167
|
+
}
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
return maxZIndex;
|
|
171
|
+
};
|
|
172
|
+
this.checkAndCorrectTopGroupZIndex = function (nodes) {
|
|
173
|
+
// 初始化时/增加新节点时,找出新增nodes的最大zIndex
|
|
174
|
+
var maxZIndex = DEFAULT_BOTTOM_Z_INDEX;
|
|
175
|
+
nodes.forEach(function (node) {
|
|
176
|
+
var nodeModel = _this.lf.getNodeModelById(node.id);
|
|
177
|
+
var currentNodeMaxZIndex = _this.findNodeAndChildMaxZIndex(nodeModel);
|
|
178
|
+
if (currentNodeMaxZIndex > maxZIndex) {
|
|
179
|
+
maxZIndex = currentNodeMaxZIndex;
|
|
180
|
+
}
|
|
181
|
+
});
|
|
182
|
+
if (_this.topGroupZIndex >= maxZIndex) {
|
|
183
|
+
// 一般是初始化时/增加新节点时发生,因为外部强行设置了一个很大的zIndex
|
|
184
|
+
// 删除节点不会影响目前最高zIndex的赋值
|
|
185
|
+
return;
|
|
186
|
+
}
|
|
187
|
+
// 新增nodes中如果存在zIndex比this.topGroupZIndex大
|
|
188
|
+
// 说明this.topGroupZIndex已经失去意义,代表不了目前最高zIndex的group,需要重新校准
|
|
189
|
+
// https://github.com/didi/LogicFlow/issues/1535
|
|
190
|
+
// 当外部直接设置多个BaseNode.zIndex=1时
|
|
191
|
+
// 当点击某一个node时,由于这个this.topGroupZIndex是从-10000开始计算的,this.topGroupZIndex+1也就是-9999
|
|
192
|
+
// 这就造成当前点击的node的zIndex远远比其它node的zIndex小,因此造成zIndex错乱问题
|
|
193
|
+
var allGroupNodes = _this.lf.graphModel.nodes
|
|
194
|
+
.filter(function (node) { return node.isGroup; });
|
|
195
|
+
var max = _this.topGroupZIndex;
|
|
196
|
+
for (var i = 0; i < allGroupNodes.length; i++) {
|
|
197
|
+
var groupNode = allGroupNodes[i];
|
|
198
|
+
if (groupNode.zIndex > max) {
|
|
199
|
+
max = groupNode.zIndex;
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
_this.topGroupZIndex = max;
|
|
203
|
+
};
|
|
147
204
|
/**
|
|
148
205
|
* 1. 分组节点默认在普通节点下面。
|
|
149
206
|
* 2. 分组节点被选中后,会将分组节点以及其内部的其他分组节点放到其余分组节点的上面。
|
|
@@ -22,7 +22,7 @@ declare class Control extends Component<IProps> {
|
|
|
22
22
|
deltaX: any;
|
|
23
23
|
deltaY: any;
|
|
24
24
|
}) => void;
|
|
25
|
-
getResize: ({ index, deltaX, deltaY, width, height, PCTResizeInfo, pct }: {
|
|
25
|
+
getResize: ({ index, deltaX, deltaY, width, height, PCTResizeInfo, pct, freezeWidth, freezeHeight, }: {
|
|
26
26
|
index: any;
|
|
27
27
|
deltaX: any;
|
|
28
28
|
deltaY: any;
|
|
@@ -30,6 +30,8 @@ declare class Control extends Component<IProps> {
|
|
|
30
30
|
height: any;
|
|
31
31
|
PCTResizeInfo: any;
|
|
32
32
|
pct?: number;
|
|
33
|
+
freezeWidth?: boolean;
|
|
34
|
+
freezeHeight?: boolean;
|
|
33
35
|
}) => {
|
|
34
36
|
width: any;
|
|
35
37
|
height: any;
|
|
@@ -57,7 +57,7 @@ var Control = /** @class */ (function (_super) {
|
|
|
57
57
|
};
|
|
58
58
|
// 计算control拖动后,节点的宽高
|
|
59
59
|
_this.getResize = function (_a) {
|
|
60
|
-
var index = _a.index, deltaX = _a.deltaX, deltaY = _a.deltaY, width = _a.width, height = _a.height, PCTResizeInfo = _a.PCTResizeInfo, _b = _a.pct, pct = _b === void 0 ? 1 : _b;
|
|
60
|
+
var index = _a.index, deltaX = _a.deltaX, deltaY = _a.deltaY, width = _a.width, height = _a.height, PCTResizeInfo = _a.PCTResizeInfo, _b = _a.pct, pct = _b === void 0 ? 1 : _b, _c = _a.freezeWidth, freezeWidth = _c === void 0 ? false : _c, _d = _a.freezeHeight, freezeHeight = _d === void 0 ? false : _d;
|
|
61
61
|
var resize = { width: width, height: height, deltaX: deltaX, deltaY: deltaY };
|
|
62
62
|
if (PCTResizeInfo) {
|
|
63
63
|
var sensitivity = 4; // 越低越灵敏
|
|
@@ -115,22 +115,23 @@ var Control = /** @class */ (function (_super) {
|
|
|
115
115
|
resize.deltaY = deltaY / pct;
|
|
116
116
|
return resize;
|
|
117
117
|
}
|
|
118
|
+
// 如果限制了宽/高不变,对应的width/height保持一致
|
|
118
119
|
switch (index) {
|
|
119
120
|
case 0:
|
|
120
|
-
resize.width = width - deltaX * pct;
|
|
121
|
-
resize.height = height - deltaY * pct;
|
|
121
|
+
resize.width = freezeWidth ? width : width - deltaX * pct;
|
|
122
|
+
resize.height = freezeHeight ? height : height - deltaY * pct;
|
|
122
123
|
break;
|
|
123
124
|
case 1:
|
|
124
|
-
resize.width = width + deltaX * pct;
|
|
125
|
-
resize.height = height - deltaY * pct;
|
|
125
|
+
resize.width = freezeWidth ? width : width + deltaX * pct;
|
|
126
|
+
resize.height = freezeHeight ? height : height - deltaY * pct;
|
|
126
127
|
break;
|
|
127
128
|
case 2:
|
|
128
|
-
resize.width = width + deltaX * pct;
|
|
129
|
-
resize.height = height + deltaY * pct;
|
|
129
|
+
resize.width = freezeWidth ? width : width + deltaX * pct;
|
|
130
|
+
resize.height = freezeHeight ? height : height + deltaY * pct;
|
|
130
131
|
break;
|
|
131
132
|
case 3:
|
|
132
|
-
resize.width = width - deltaX * pct;
|
|
133
|
-
resize.height = height + deltaY * pct;
|
|
133
|
+
resize.width = freezeWidth ? width : width - deltaX * pct;
|
|
134
|
+
resize.height = freezeHeight ? height : height + deltaY * pct;
|
|
134
135
|
break;
|
|
135
136
|
default:
|
|
136
137
|
break;
|
|
@@ -170,8 +171,11 @@ var Control = /** @class */ (function (_super) {
|
|
|
170
171
|
_this.updateRect = function (_a) {
|
|
171
172
|
var deltaX = _a.deltaX, deltaY = _a.deltaY;
|
|
172
173
|
var _b = _this.nodeModel, id = _b.id, x = _b.x, y = _b.y, width = _b.width, height = _b.height, radius = _b.radius, PCTResizeInfo = _b.PCTResizeInfo;
|
|
174
|
+
var _c = _this.nodeModel, minWidth = _c.minWidth, minHeight = _c.minHeight, maxWidth = _c.maxWidth, maxHeight = _c.maxHeight;
|
|
173
175
|
// 更新中心点位置,更新文案位置
|
|
174
176
|
var index = _this.index;
|
|
177
|
+
var freezeWidth = (minWidth === maxWidth);
|
|
178
|
+
var freezeHeight = (minHeight === maxHeight);
|
|
175
179
|
var size = _this.getResize({
|
|
176
180
|
index: index,
|
|
177
181
|
deltaX: deltaX,
|
|
@@ -180,9 +184,10 @@ var Control = /** @class */ (function (_super) {
|
|
|
180
184
|
height: height,
|
|
181
185
|
PCTResizeInfo: PCTResizeInfo,
|
|
182
186
|
pct: 1,
|
|
187
|
+
freezeWidth: freezeWidth,
|
|
188
|
+
freezeHeight: freezeHeight,
|
|
183
189
|
});
|
|
184
190
|
// 限制放大缩小的最大最小范围
|
|
185
|
-
var _c = _this.nodeModel, minWidth = _c.minWidth, minHeight = _c.minHeight, maxWidth = _c.maxWidth, maxHeight = _c.maxHeight;
|
|
186
191
|
if (size.width < minWidth
|
|
187
192
|
|| size.width > maxWidth
|
|
188
193
|
|| size.height < minHeight
|
|
@@ -191,7 +196,11 @@ var Control = /** @class */ (function (_super) {
|
|
|
191
196
|
_this.dragHandler.cancelDrag();
|
|
192
197
|
return;
|
|
193
198
|
}
|
|
194
|
-
|
|
199
|
+
// 如果限制了宽/高不变,对应的x/y不产生位移
|
|
200
|
+
_this.updatePosition({
|
|
201
|
+
deltaX: freezeWidth ? 0 : size.deltaX,
|
|
202
|
+
deltaY: freezeHeight ? 0 : size.deltaY,
|
|
203
|
+
});
|
|
195
204
|
// 更新宽高
|
|
196
205
|
_this.nodeModel.width = size.width;
|
|
197
206
|
_this.nodeModel.height = size.height;
|
|
@@ -225,6 +234,9 @@ var Control = /** @class */ (function (_super) {
|
|
|
225
234
|
var deltaX = _a.deltaX, deltaY = _a.deltaY;
|
|
226
235
|
var _b = _this.nodeModel, id = _b.id, rx = _b.rx, ry = _b.ry, x = _b.x, y = _b.y, PCTResizeInfo = _b.PCTResizeInfo;
|
|
227
236
|
var index = _this.index;
|
|
237
|
+
var _c = _this.nodeModel, minWidth = _c.minWidth, minHeight = _c.minHeight, maxWidth = _c.maxWidth, maxHeight = _c.maxHeight;
|
|
238
|
+
var freezeWidth = (minWidth === maxWidth);
|
|
239
|
+
var freezeHeight = (minHeight === maxHeight);
|
|
228
240
|
var width = rx;
|
|
229
241
|
var height = ry;
|
|
230
242
|
var size = _this.getResize({
|
|
@@ -235,9 +247,10 @@ var Control = /** @class */ (function (_super) {
|
|
|
235
247
|
height: height,
|
|
236
248
|
PCTResizeInfo: PCTResizeInfo,
|
|
237
249
|
pct: 1 / 2,
|
|
250
|
+
freezeWidth: freezeWidth,
|
|
251
|
+
freezeHeight: freezeHeight,
|
|
238
252
|
});
|
|
239
253
|
// 限制放大缩小的最大最小范围
|
|
240
|
-
var _c = _this.nodeModel, minWidth = _c.minWidth, minHeight = _c.minHeight, maxWidth = _c.maxWidth, maxHeight = _c.maxHeight;
|
|
241
254
|
if (size.width < (minWidth / 2)
|
|
242
255
|
|| size.width > (maxWidth / 2)
|
|
243
256
|
|| size.height < (minHeight / 2)
|
|
@@ -246,7 +259,11 @@ var Control = /** @class */ (function (_super) {
|
|
|
246
259
|
return;
|
|
247
260
|
}
|
|
248
261
|
// 更新中心点位置,更新文案位置
|
|
249
|
-
|
|
262
|
+
// 如果限制了宽/高不变,对应的x/y不产生位移
|
|
263
|
+
_this.updatePosition({
|
|
264
|
+
deltaX: freezeWidth ? 0 : size.deltaX,
|
|
265
|
+
deltaY: freezeHeight ? 0 : size.deltaY,
|
|
266
|
+
});
|
|
250
267
|
// 更新rx ry,宽高为计算属性自动更新
|
|
251
268
|
// @ts-ignore
|
|
252
269
|
_this.nodeModel.rx = size.width;
|
|
@@ -275,6 +292,9 @@ var Control = /** @class */ (function (_super) {
|
|
|
275
292
|
var deltaX = _a.deltaX, deltaY = _a.deltaY;
|
|
276
293
|
var _b = _this.nodeModel, id = _b.id, rx = _b.rx, ry = _b.ry, x = _b.x, y = _b.y, PCTResizeInfo = _b.PCTResizeInfo;
|
|
277
294
|
var index = _this.index;
|
|
295
|
+
var _c = _this.nodeModel, minWidth = _c.minWidth, minHeight = _c.minHeight, maxWidth = _c.maxWidth, maxHeight = _c.maxHeight;
|
|
296
|
+
var freezeWidth = (minWidth === maxWidth);
|
|
297
|
+
var freezeHeight = (minHeight === maxHeight);
|
|
278
298
|
var width = rx;
|
|
279
299
|
var height = ry;
|
|
280
300
|
var size = _this.getResize({
|
|
@@ -285,9 +305,10 @@ var Control = /** @class */ (function (_super) {
|
|
|
285
305
|
height: height,
|
|
286
306
|
PCTResizeInfo: PCTResizeInfo,
|
|
287
307
|
pct: 1 / 2,
|
|
308
|
+
freezeWidth: freezeWidth,
|
|
309
|
+
freezeHeight: freezeHeight,
|
|
288
310
|
});
|
|
289
311
|
// 限制放大缩小的最大最小范围
|
|
290
|
-
var _c = _this.nodeModel, minWidth = _c.minWidth, minHeight = _c.minHeight, maxWidth = _c.maxWidth, maxHeight = _c.maxHeight;
|
|
291
312
|
if (size.width < (minWidth / 2)
|
|
292
313
|
|| size.width > (maxWidth / 2)
|
|
293
314
|
|| size.height < (minHeight / 2)
|
|
@@ -296,7 +317,11 @@ var Control = /** @class */ (function (_super) {
|
|
|
296
317
|
return;
|
|
297
318
|
}
|
|
298
319
|
// 更新中心点位置,更新文案位置
|
|
299
|
-
|
|
320
|
+
// 如果限制了宽/高不变,对应的x/y不产生位移
|
|
321
|
+
_this.updatePosition({
|
|
322
|
+
deltaX: freezeWidth ? 0 : size.deltaX,
|
|
323
|
+
deltaY: freezeHeight ? 0 : size.deltaY,
|
|
324
|
+
});
|
|
300
325
|
// 更新rx ry,宽高为计算属性自动更新
|
|
301
326
|
// @ts-ignore
|
|
302
327
|
_this.nodeModel.rx = size.width;
|
|
@@ -348,13 +373,13 @@ var Control = /** @class */ (function (_super) {
|
|
|
348
373
|
* 由于将拖拽放大缩小改成丝滑模式,这个时候需要在拖拽结束的时候,将节点的位置更新到grid上.
|
|
349
374
|
*/
|
|
350
375
|
_this.onDragEnd = function () {
|
|
351
|
-
// 先触发onDragging()->更新边->再触发用户自定义的getDefaultAnchor(),所以onDragging()拿到的anchors是滞后的
|
|
352
|
-
// 为了正确设置最终的位置,应该在拖拽结束的时候,再设置一次边的Point位置,此时拿到的anchors是最新的
|
|
353
|
-
_this.updateEdgePointByAnchors();
|
|
354
376
|
var _a = _this.graphModel.gridSize, gridSize = _a === void 0 ? 1 : _a;
|
|
355
377
|
var x = gridSize * Math.round(_this.nodeModel.x / gridSize);
|
|
356
378
|
var y = gridSize * Math.round(_this.nodeModel.y / gridSize);
|
|
357
379
|
_this.nodeModel.moveTo(x, y);
|
|
380
|
+
// 先触发onDragging()->更新边->再触发用户自定义的getDefaultAnchor(),所以onDragging()拿到的anchors是滞后的
|
|
381
|
+
// 为了正确设置最终的位置,应该在拖拽结束的时候,再设置一次边的Point位置,此时拿到的anchors是最新的
|
|
382
|
+
_this.updateEdgePointByAnchors();
|
|
358
383
|
};
|
|
359
384
|
_this.index = props.index;
|
|
360
385
|
_this.nodeModel = props.model;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import LogicFlow, { BaseEdgeModel, BaseNodeModel, EdgeConfig } from '@logicflow/core';
|
|
1
|
+
import LogicFlow, { BaseEdgeModel, BaseNodeModel, EdgeConfig, NodeData } from '@logicflow/core';
|
|
2
2
|
import GroupNode from './GroupNode';
|
|
3
3
|
declare type BaseNodeId = string;
|
|
4
4
|
declare type GroupId = string;
|
|
@@ -40,6 +40,8 @@ declare class Group {
|
|
|
40
40
|
setActiveGroup: ({ data }: {
|
|
41
41
|
data: any;
|
|
42
42
|
}) => void;
|
|
43
|
+
findNodeAndChildMaxZIndex: (nodeModel: BaseNodeModel) => number;
|
|
44
|
+
checkAndCorrectTopGroupZIndex: (nodes: NodeData[]) => void;
|
|
43
45
|
/**
|
|
44
46
|
* 1. 分组节点默认在普通节点下面。
|
|
45
47
|
* 2. 分组节点被选中后,会将分组节点以及其内部的其他分组节点放到其余分组节点的上面。
|
|
@@ -61,6 +61,8 @@ var Group = /** @class */ (function () {
|
|
|
61
61
|
});
|
|
62
62
|
}
|
|
63
63
|
});
|
|
64
|
+
// 初始化nodes时进行this.topGroupZIndex的校准更新
|
|
65
|
+
_this.checkAndCorrectTopGroupZIndex(data.nodes);
|
|
64
66
|
}
|
|
65
67
|
};
|
|
66
68
|
this.appendNodeToGroup = function (_a) {
|
|
@@ -91,6 +93,8 @@ var Group = /** @class */ (function () {
|
|
|
91
93
|
data.children.forEach(function (nodeId) {
|
|
92
94
|
_this.nodeGroupMap.set(nodeId, data.id);
|
|
93
95
|
});
|
|
96
|
+
// 新增node时进行this.topGroupZIndex的校准更新
|
|
97
|
+
_this.checkAndCorrectTopGroupZIndex([data]);
|
|
94
98
|
_this.nodeSelected({ data: data, isSelected: false, isMultiple: false });
|
|
95
99
|
}
|
|
96
100
|
if (!group)
|
|
@@ -140,6 +144,59 @@ var Group = /** @class */ (function () {
|
|
|
140
144
|
_this.activeGroup = newGroup;
|
|
141
145
|
_this.activeGroup.setAllowAppendChild(true);
|
|
142
146
|
};
|
|
147
|
+
this.findNodeAndChildMaxZIndex = function (nodeModel) {
|
|
148
|
+
var maxZIndex = DEFAULT_BOTTOM_Z_INDEX;
|
|
149
|
+
if (nodeModel.isGroup) {
|
|
150
|
+
maxZIndex = nodeModel.zIndex > maxZIndex ? nodeModel.zIndex : maxZIndex;
|
|
151
|
+
}
|
|
152
|
+
if (nodeModel.children) {
|
|
153
|
+
nodeModel.children.forEach(function (nodeId) {
|
|
154
|
+
if (typeof nodeId === 'object') {
|
|
155
|
+
// 正常情况下, GroupNodeModel.children是一个id数组,这里只是做个兼容
|
|
156
|
+
// @ts-ignore
|
|
157
|
+
nodeId = nodeId.id;
|
|
158
|
+
}
|
|
159
|
+
var child = _this.lf.getNodeModelById(nodeId);
|
|
160
|
+
if (child.isGroup) {
|
|
161
|
+
var childMaxZIndex = _this.findNodeAndChildMaxZIndex(child);
|
|
162
|
+
maxZIndex = childMaxZIndex > maxZIndex ? childMaxZIndex : maxZIndex;
|
|
163
|
+
}
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
return maxZIndex;
|
|
167
|
+
};
|
|
168
|
+
this.checkAndCorrectTopGroupZIndex = function (nodes) {
|
|
169
|
+
// 初始化时/增加新节点时,找出新增nodes的最大zIndex
|
|
170
|
+
var maxZIndex = DEFAULT_BOTTOM_Z_INDEX;
|
|
171
|
+
nodes.forEach(function (node) {
|
|
172
|
+
var nodeModel = _this.lf.getNodeModelById(node.id);
|
|
173
|
+
var currentNodeMaxZIndex = _this.findNodeAndChildMaxZIndex(nodeModel);
|
|
174
|
+
if (currentNodeMaxZIndex > maxZIndex) {
|
|
175
|
+
maxZIndex = currentNodeMaxZIndex;
|
|
176
|
+
}
|
|
177
|
+
});
|
|
178
|
+
if (_this.topGroupZIndex >= maxZIndex) {
|
|
179
|
+
// 一般是初始化时/增加新节点时发生,因为外部强行设置了一个很大的zIndex
|
|
180
|
+
// 删除节点不会影响目前最高zIndex的赋值
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
183
|
+
// 新增nodes中如果存在zIndex比this.topGroupZIndex大
|
|
184
|
+
// 说明this.topGroupZIndex已经失去意义,代表不了目前最高zIndex的group,需要重新校准
|
|
185
|
+
// https://github.com/didi/LogicFlow/issues/1535
|
|
186
|
+
// 当外部直接设置多个BaseNode.zIndex=1时
|
|
187
|
+
// 当点击某一个node时,由于这个this.topGroupZIndex是从-10000开始计算的,this.topGroupZIndex+1也就是-9999
|
|
188
|
+
// 这就造成当前点击的node的zIndex远远比其它node的zIndex小,因此造成zIndex错乱问题
|
|
189
|
+
var allGroupNodes = _this.lf.graphModel.nodes
|
|
190
|
+
.filter(function (node) { return node.isGroup; });
|
|
191
|
+
var max = _this.topGroupZIndex;
|
|
192
|
+
for (var i = 0; i < allGroupNodes.length; i++) {
|
|
193
|
+
var groupNode = allGroupNodes[i];
|
|
194
|
+
if (groupNode.zIndex > max) {
|
|
195
|
+
max = groupNode.zIndex;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
_this.topGroupZIndex = max;
|
|
199
|
+
};
|
|
143
200
|
/**
|
|
144
201
|
* 1. 分组节点默认在普通节点下面。
|
|
145
202
|
* 2. 分组节点被选中后,会将分组节点以及其内部的其他分组节点放到其余分组节点的上面。
|