@logicflow/extension 1.2.0-next.2 → 1.2.0-next.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/insert-node-in-polyline/edge.js +40 -17
- package/cjs/insert-node-in-polyline/index.js +12 -1
- package/cjs/materials/group/GroupNode.js +4 -0
- package/cjs/materials/group/index.js +22 -3
- package/es/insert-node-in-polyline/edge.d.ts +12 -2
- package/es/insert-node-in-polyline/edge.js +39 -16
- package/es/insert-node-in-polyline/index.d.ts +1 -0
- package/es/insert-node-in-polyline/index.js +12 -1
- package/es/materials/group/GroupNode.js +4 -0
- package/es/materials/group/index.d.ts +3 -1
- package/es/materials/group/index.js +22 -3
- package/lib/AutoLayout.js +1 -1
- package/lib/BpmnAdapter.js +1 -1
- package/lib/BpmnElement.js +1 -1
- package/lib/ContextMenu.js +1 -1
- package/lib/Control.js +1 -1
- package/lib/CurvedEdge.js +1 -1
- package/lib/DndPanel.js +1 -1
- package/lib/FlowPath.js +1 -1
- package/lib/Group.js +1 -1
- package/lib/Highlight.js +1 -1
- package/lib/InsertNodeInPolyline.js +1 -1
- package/lib/Menu.js +1 -1
- package/lib/MiniMap.js +1 -1
- package/lib/NodeResize.js +1 -1
- package/lib/RectLabelNode.js +1 -1
- package/lib/SelectionSelect.js +1 -1
- package/lib/Snapshot.js +1 -1
- package/lib/TurboAdapter.js +1 -1
- package/lib/lfJson2Xml.js +1 -1
- package/lib/lfXml2Json.js +1 -1
- package/package.json +2 -2
- package/types/insert-node-in-polyline/edge.d.ts +12 -2
- package/types/insert-node-in-polyline/index.d.ts +1 -0
- package/types/materials/group/index.d.ts +3 -1
|
@@ -1,21 +1,43 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isNodeInSegment = exports.crossPointInSegment = exports.isInSegment = void 0;
|
|
3
|
+
exports.isNodeInSegment = exports.crossPointInSegment = exports.distToSegment = exports.distToSegmentSquared = exports.isInSegment = void 0;
|
|
4
4
|
// 这个里面的函数有些在core中已经存在,为了解耦关系,没有引用
|
|
5
5
|
var SegmentDirection;
|
|
6
6
|
(function (SegmentDirection) {
|
|
7
7
|
SegmentDirection["HORIZONTAL"] = "horizontal";
|
|
8
8
|
SegmentDirection["VERTICAL"] = "vertical";
|
|
9
9
|
})(SegmentDirection || (SegmentDirection = {}));
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
10
|
+
/**
|
|
11
|
+
* 判断一个点是否在线段中
|
|
12
|
+
* @param point 判断的点
|
|
13
|
+
* @param start 线段的起点
|
|
14
|
+
* @param end 线段的终点
|
|
15
|
+
* @param deviation 误差范围
|
|
16
|
+
* @returns boolean
|
|
17
|
+
*/
|
|
18
|
+
exports.isInSegment = function (point, start, end, deviation) {
|
|
19
|
+
if (deviation === void 0) { deviation = 0; }
|
|
20
|
+
var distance = exports.distToSegment(point, start, end);
|
|
21
|
+
return distance <= deviation;
|
|
18
22
|
};
|
|
23
|
+
function sqr(x) {
|
|
24
|
+
return x * x;
|
|
25
|
+
}
|
|
26
|
+
function dist2(v, w) {
|
|
27
|
+
return sqr(v.x - w.x) + sqr(v.y - w.y);
|
|
28
|
+
}
|
|
29
|
+
exports.distToSegmentSquared = function (p, v, w) {
|
|
30
|
+
var l2 = dist2(v, w);
|
|
31
|
+
if (l2 === 0)
|
|
32
|
+
return dist2(p, v);
|
|
33
|
+
var t = ((p.x - v.x) * (w.x - v.x) + (p.y - v.y) * (w.y - v.y)) / l2;
|
|
34
|
+
t = Math.max(0, Math.min(1, t));
|
|
35
|
+
return dist2(p, {
|
|
36
|
+
x: v.x + t * (w.x - v.x),
|
|
37
|
+
y: v.y + t * (w.y - v.y),
|
|
38
|
+
});
|
|
39
|
+
};
|
|
40
|
+
exports.distToSegment = function (point, start, end) { return Math.sqrt(exports.distToSegmentSquared(point, start, end)); };
|
|
19
41
|
/* 获取节点bbox */
|
|
20
42
|
var getNodeBBox = function (node) {
|
|
21
43
|
var x = node.x, y = node.y, width = node.width, height = node.height;
|
|
@@ -55,29 +77,29 @@ exports.crossPointInSegment = function (node, start, end) {
|
|
|
55
77
|
var x = node.x, y = node.y, width = node.width, height = node.height;
|
|
56
78
|
if (direction === SegmentDirection.HORIZONTAL) {
|
|
57
79
|
// 同一水平线
|
|
58
|
-
if (
|
|
80
|
+
if (maxX >= bBox.maxX && minX <= bBox.minX) {
|
|
59
81
|
return {
|
|
60
82
|
startCrossPoint: {
|
|
61
83
|
x: start.x > end.x ? x + (width / 2) : x - (width / 2),
|
|
62
|
-
y: y,
|
|
84
|
+
y: start.y,
|
|
63
85
|
},
|
|
64
86
|
endCrossPoint: {
|
|
65
87
|
x: start.x > end.x ? x - (width / 2) : x + (width / 2),
|
|
66
|
-
y: y,
|
|
88
|
+
y: start.y,
|
|
67
89
|
},
|
|
68
90
|
};
|
|
69
91
|
}
|
|
70
92
|
}
|
|
71
93
|
else if (direction === SegmentDirection.VERTICAL) {
|
|
72
94
|
// 同一垂直线
|
|
73
|
-
if (
|
|
95
|
+
if (maxY >= bBox.maxY && minY <= bBox.minY) {
|
|
74
96
|
return {
|
|
75
97
|
startCrossPoint: {
|
|
76
|
-
x: x,
|
|
98
|
+
x: start.x,
|
|
77
99
|
y: start.y > end.y ? y + (height / 2) : y - (height / 2),
|
|
78
100
|
},
|
|
79
101
|
endCrossPoint: {
|
|
80
|
-
x: x,
|
|
102
|
+
x: start.x,
|
|
81
103
|
y: start.y > end.y ? y - (height / 2) : y + (height / 2),
|
|
82
104
|
},
|
|
83
105
|
};
|
|
@@ -86,11 +108,12 @@ exports.crossPointInSegment = function (node, start, end) {
|
|
|
86
108
|
};
|
|
87
109
|
// 节点是否在线段内
|
|
88
110
|
// eslint-disable-next-line max-len
|
|
89
|
-
exports.isNodeInSegment = function (node, polyline) {
|
|
111
|
+
exports.isNodeInSegment = function (node, polyline, deviation) {
|
|
112
|
+
if (deviation === void 0) { deviation = 0; }
|
|
90
113
|
var x = node.x, y = node.y;
|
|
91
114
|
var pointsList = polyline.pointsList;
|
|
92
115
|
for (var i = 0; i < pointsList.length - 1; i++) {
|
|
93
|
-
if (exports.isInSegment({ x: x, y: y }, pointsList[i], pointsList[i + 1])) {
|
|
116
|
+
if (exports.isInSegment({ x: x, y: y }, pointsList[i], pointsList[i + 1], deviation)) {
|
|
94
117
|
var bBoxCross = exports.crossPointInSegment(node, pointsList[i], pointsList[i + 1]);
|
|
95
118
|
if (bBoxCross) {
|
|
96
119
|
return {
|
|
@@ -21,11 +21,14 @@ var __spread = (this && this.__spread) || function () {
|
|
|
21
21
|
};
|
|
22
22
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
23
|
exports.InsertNodeInPolyline = void 0;
|
|
24
|
+
var lodash_es_1 = require("lodash-es");
|
|
24
25
|
var edge_1 = require("./edge");
|
|
25
26
|
var InsertNodeInPolyline = /** @class */ (function () {
|
|
26
27
|
function InsertNodeInPolyline(_a) {
|
|
27
28
|
var lf = _a.lf;
|
|
28
29
|
this._lf = lf;
|
|
30
|
+
// fix https://github.com/didi/LogicFlow/issues/754
|
|
31
|
+
this.deviation = 20;
|
|
29
32
|
this.dndAdd = true;
|
|
30
33
|
this.dropAdd = true;
|
|
31
34
|
this.eventHandler();
|
|
@@ -44,6 +47,7 @@ var InsertNodeInPolyline = /** @class */ (function () {
|
|
|
44
47
|
var data = _a.data;
|
|
45
48
|
var edges = _this._lf.graphModel.edges;
|
|
46
49
|
var id = data.id;
|
|
50
|
+
// 只有游离节点才能插入到连线上
|
|
47
51
|
var pureNode = true;
|
|
48
52
|
for (var i = 0; i < edges.length; i++) {
|
|
49
53
|
if (edges[i].sourceNodeId === id || edges[i].targetNodeId === id) {
|
|
@@ -62,19 +66,26 @@ var InsertNodeInPolyline = /** @class */ (function () {
|
|
|
62
66
|
var nodeModel = this._lf.getNodeModelById(nodeData.id);
|
|
63
67
|
for (var i = 0; i < edges.length; i++) {
|
|
64
68
|
// eslint-disable-next-line max-len
|
|
65
|
-
var _a = edge_1.isNodeInSegment(nodeModel, edges[i]), crossIndex = _a.crossIndex, crossPoints = _a.crossPoints;
|
|
69
|
+
var _a = edge_1.isNodeInSegment(nodeModel, edges[i], this.deviation), crossIndex = _a.crossIndex, crossPoints = _a.crossPoints;
|
|
66
70
|
if (crossIndex >= 0) {
|
|
67
71
|
var _b = edges[i], sourceNodeId = _b.sourceNodeId, targetNodeId = _b.targetNodeId, id = _b.id, type = _b.type, pointsList = _b.pointsList;
|
|
72
|
+
// fix https://github.com/didi/LogicFlow/issues/996
|
|
73
|
+
var startPoint = lodash_es_1.cloneDeep(pointsList[0]);
|
|
74
|
+
var endPoint = lodash_es_1.cloneDeep(crossPoints.startCrossPoint);
|
|
68
75
|
this._lf.addEdge({
|
|
69
76
|
type: type,
|
|
70
77
|
sourceNodeId: sourceNodeId,
|
|
71
78
|
targetNodeId: nodeData.id,
|
|
79
|
+
startPoint: startPoint,
|
|
80
|
+
endPoint: endPoint,
|
|
72
81
|
pointsList: __spread(pointsList.slice(0, crossIndex), [crossPoints.startCrossPoint]),
|
|
73
82
|
});
|
|
74
83
|
this._lf.addEdge({
|
|
75
84
|
type: type,
|
|
76
85
|
sourceNodeId: nodeData.id,
|
|
77
86
|
targetNodeId: targetNodeId,
|
|
87
|
+
startPoint: lodash_es_1.cloneDeep(crossPoints.endCrossPoint),
|
|
88
|
+
endPoint: lodash_es_1.cloneDeep(pointsList[pointsList.length - 1]),
|
|
78
89
|
pointsList: __spread([crossPoints.endCrossPoint], pointsList.slice(crossIndex)),
|
|
79
90
|
});
|
|
80
91
|
this._lf.deleteEdge(id);
|
|
@@ -124,6 +124,10 @@ var GroupNodeModel = /** @class */ (function (_super) {
|
|
|
124
124
|
var allEdges = this.incoming.edges.concat(this.outgoing.edges);
|
|
125
125
|
this.children.forEach(function (elementId) {
|
|
126
126
|
var nodeModel = _this.graphModel.getElement(elementId);
|
|
127
|
+
// FIX: https://github.com/didi/LogicFlow/issues/1007
|
|
128
|
+
if (nodeModel.isGroup && !nodeModel.isFolded) {
|
|
129
|
+
nodeModel.foldGroup(isFolded);
|
|
130
|
+
}
|
|
127
131
|
nodeModel.visible = !isFolded;
|
|
128
132
|
allEdges = allEdges.concat(nodeModel.incoming.edges.concat(nodeModel.outgoing.edges));
|
|
129
133
|
});
|
|
@@ -55,7 +55,7 @@ var Group = /** @class */ (function () {
|
|
|
55
55
|
data.children.forEach(function (nodeId) {
|
|
56
56
|
_this.nodeGroupMap.set(nodeId, data.id);
|
|
57
57
|
});
|
|
58
|
-
_this.nodeSelected({ data: data });
|
|
58
|
+
_this.nodeSelected({ data: data, isSelected: false, isMultiple: false });
|
|
59
59
|
}
|
|
60
60
|
};
|
|
61
61
|
this.deleteGroupChild = function (_a) {
|
|
@@ -98,7 +98,7 @@ var Group = /** @class */ (function () {
|
|
|
98
98
|
* 4. 由于LogicFlow核心目标是支持用户手动绘制流程图,所以不考虑一张流程图超过1000个分组节点的情况。
|
|
99
99
|
*/
|
|
100
100
|
this.nodeSelected = function (_a) {
|
|
101
|
-
var data = _a.data;
|
|
101
|
+
var data = _a.data, isMultiple = _a.isMultiple, isSelected = _a.isSelected;
|
|
102
102
|
var nodeModel = _this.lf.getNodeModelById(data.id);
|
|
103
103
|
_this.toFrontGroup(nodeModel);
|
|
104
104
|
// 重置所有的group zIndex,防止group节点zIndex增长为正。
|
|
@@ -117,6 +117,25 @@ var Group = /** @class */ (function () {
|
|
|
117
117
|
group.setZIndex(_this.topGroupZIndex);
|
|
118
118
|
}
|
|
119
119
|
}
|
|
120
|
+
// FIX #1004
|
|
121
|
+
// 如果节点被多选,
|
|
122
|
+
// 这个节点是分组,则将分组的所有子节点取消选中
|
|
123
|
+
// 这个节点是分组的子节点,且其所属分组节点已选,则取消选中
|
|
124
|
+
if (isMultiple && isSelected) {
|
|
125
|
+
if (nodeModel.isGroup) {
|
|
126
|
+
nodeModel.children.forEach(function (child) {
|
|
127
|
+
var childModel = _this.lf.graphModel.getElement(child);
|
|
128
|
+
childModel.setSelected(false);
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
else {
|
|
132
|
+
var groupId = _this.nodeGroupMap.get(data.id);
|
|
133
|
+
if (groupId) {
|
|
134
|
+
var groupModel = _this.lf.getNodeModelById(groupId);
|
|
135
|
+
groupModel.isSelected && nodeModel.setSelected(false);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
120
139
|
};
|
|
121
140
|
this.toFrontGroup = function (model) {
|
|
122
141
|
if (!model || !model.isGroup) {
|
|
@@ -153,7 +172,7 @@ var Group = /** @class */ (function () {
|
|
|
153
172
|
return true;
|
|
154
173
|
});
|
|
155
174
|
lf.graphModel.group = this;
|
|
156
|
-
lf.on('node:add,node:drop', this.appendNodeToGroup);
|
|
175
|
+
lf.on('node:add,node:drop,node:dnd-add', this.appendNodeToGroup);
|
|
157
176
|
lf.on('node:delete', this.deleteGroupChild);
|
|
158
177
|
lf.on('node:dnd-drag,node:drag', this.setActiveGroup);
|
|
159
178
|
lf.on('node:click', this.nodeSelected);
|
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
import { Point, PolylineEdgeModel, BaseNodeModel } from '@logicflow/core';
|
|
2
|
-
|
|
2
|
+
/**
|
|
3
|
+
* 判断一个点是否在线段中
|
|
4
|
+
* @param point 判断的点
|
|
5
|
+
* @param start 线段的起点
|
|
6
|
+
* @param end 线段的终点
|
|
7
|
+
* @param deviation 误差范围
|
|
8
|
+
* @returns boolean
|
|
9
|
+
*/
|
|
10
|
+
export declare const isInSegment: (point: any, start: any, end: any, deviation?: number) => boolean;
|
|
11
|
+
export declare const distToSegmentSquared: (p: any, v: any, w: any) => number;
|
|
12
|
+
export declare const distToSegment: (point: Point, start: Point, end: Point) => number;
|
|
3
13
|
export declare const crossPointInSegment: (node: BaseNodeModel, start: Point, end: Point) => {
|
|
4
14
|
startCrossPoint: {
|
|
5
15
|
x: number;
|
|
@@ -17,5 +27,5 @@ interface SegmentCross {
|
|
|
17
27
|
endCrossPoint: Point;
|
|
18
28
|
};
|
|
19
29
|
}
|
|
20
|
-
export declare const isNodeInSegment: (node: BaseNodeModel, polyline: PolylineEdgeModel) => SegmentCross;
|
|
30
|
+
export declare const isNodeInSegment: (node: BaseNodeModel, polyline: PolylineEdgeModel, deviation?: number) => SegmentCross;
|
|
21
31
|
export {};
|
|
@@ -4,15 +4,37 @@ var SegmentDirection;
|
|
|
4
4
|
SegmentDirection["HORIZONTAL"] = "horizontal";
|
|
5
5
|
SegmentDirection["VERTICAL"] = "vertical";
|
|
6
6
|
})(SegmentDirection || (SegmentDirection = {}));
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
7
|
+
/**
|
|
8
|
+
* 判断一个点是否在线段中
|
|
9
|
+
* @param point 判断的点
|
|
10
|
+
* @param start 线段的起点
|
|
11
|
+
* @param end 线段的终点
|
|
12
|
+
* @param deviation 误差范围
|
|
13
|
+
* @returns boolean
|
|
14
|
+
*/
|
|
15
|
+
export var isInSegment = function (point, start, end, deviation) {
|
|
16
|
+
if (deviation === void 0) { deviation = 0; }
|
|
17
|
+
var distance = distToSegment(point, start, end);
|
|
18
|
+
return distance <= deviation;
|
|
15
19
|
};
|
|
20
|
+
function sqr(x) {
|
|
21
|
+
return x * x;
|
|
22
|
+
}
|
|
23
|
+
function dist2(v, w) {
|
|
24
|
+
return sqr(v.x - w.x) + sqr(v.y - w.y);
|
|
25
|
+
}
|
|
26
|
+
export var distToSegmentSquared = function (p, v, w) {
|
|
27
|
+
var l2 = dist2(v, w);
|
|
28
|
+
if (l2 === 0)
|
|
29
|
+
return dist2(p, v);
|
|
30
|
+
var t = ((p.x - v.x) * (w.x - v.x) + (p.y - v.y) * (w.y - v.y)) / l2;
|
|
31
|
+
t = Math.max(0, Math.min(1, t));
|
|
32
|
+
return dist2(p, {
|
|
33
|
+
x: v.x + t * (w.x - v.x),
|
|
34
|
+
y: v.y + t * (w.y - v.y),
|
|
35
|
+
});
|
|
36
|
+
};
|
|
37
|
+
export var distToSegment = function (point, start, end) { return Math.sqrt(distToSegmentSquared(point, start, end)); };
|
|
16
38
|
/* 获取节点bbox */
|
|
17
39
|
var getNodeBBox = function (node) {
|
|
18
40
|
var x = node.x, y = node.y, width = node.width, height = node.height;
|
|
@@ -52,29 +74,29 @@ export var crossPointInSegment = function (node, start, end) {
|
|
|
52
74
|
var x = node.x, y = node.y, width = node.width, height = node.height;
|
|
53
75
|
if (direction === SegmentDirection.HORIZONTAL) {
|
|
54
76
|
// 同一水平线
|
|
55
|
-
if (
|
|
77
|
+
if (maxX >= bBox.maxX && minX <= bBox.minX) {
|
|
56
78
|
return {
|
|
57
79
|
startCrossPoint: {
|
|
58
80
|
x: start.x > end.x ? x + (width / 2) : x - (width / 2),
|
|
59
|
-
y: y,
|
|
81
|
+
y: start.y,
|
|
60
82
|
},
|
|
61
83
|
endCrossPoint: {
|
|
62
84
|
x: start.x > end.x ? x - (width / 2) : x + (width / 2),
|
|
63
|
-
y: y,
|
|
85
|
+
y: start.y,
|
|
64
86
|
},
|
|
65
87
|
};
|
|
66
88
|
}
|
|
67
89
|
}
|
|
68
90
|
else if (direction === SegmentDirection.VERTICAL) {
|
|
69
91
|
// 同一垂直线
|
|
70
|
-
if (
|
|
92
|
+
if (maxY >= bBox.maxY && minY <= bBox.minY) {
|
|
71
93
|
return {
|
|
72
94
|
startCrossPoint: {
|
|
73
|
-
x: x,
|
|
95
|
+
x: start.x,
|
|
74
96
|
y: start.y > end.y ? y + (height / 2) : y - (height / 2),
|
|
75
97
|
},
|
|
76
98
|
endCrossPoint: {
|
|
77
|
-
x: x,
|
|
99
|
+
x: start.x,
|
|
78
100
|
y: start.y > end.y ? y - (height / 2) : y + (height / 2),
|
|
79
101
|
},
|
|
80
102
|
};
|
|
@@ -83,11 +105,12 @@ export var crossPointInSegment = function (node, start, end) {
|
|
|
83
105
|
};
|
|
84
106
|
// 节点是否在线段内
|
|
85
107
|
// eslint-disable-next-line max-len
|
|
86
|
-
export var isNodeInSegment = function (node, polyline) {
|
|
108
|
+
export var isNodeInSegment = function (node, polyline, deviation) {
|
|
109
|
+
if (deviation === void 0) { deviation = 0; }
|
|
87
110
|
var x = node.x, y = node.y;
|
|
88
111
|
var pointsList = polyline.pointsList;
|
|
89
112
|
for (var i = 0; i < pointsList.length - 1; i++) {
|
|
90
|
-
if (isInSegment({ x: x, y: y }, pointsList[i], pointsList[i + 1])) {
|
|
113
|
+
if (isInSegment({ x: x, y: y }, pointsList[i], pointsList[i + 1], deviation)) {
|
|
91
114
|
var bBoxCross = crossPointInSegment(node, pointsList[i], pointsList[i + 1]);
|
|
92
115
|
if (bBoxCross) {
|
|
93
116
|
return {
|
|
@@ -18,11 +18,14 @@ var __spread = (this && this.__spread) || function () {
|
|
|
18
18
|
for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i]));
|
|
19
19
|
return ar;
|
|
20
20
|
};
|
|
21
|
+
import { cloneDeep } from 'lodash-es';
|
|
21
22
|
import { isNodeInSegment } from './edge';
|
|
22
23
|
var InsertNodeInPolyline = /** @class */ (function () {
|
|
23
24
|
function InsertNodeInPolyline(_a) {
|
|
24
25
|
var lf = _a.lf;
|
|
25
26
|
this._lf = lf;
|
|
27
|
+
// fix https://github.com/didi/LogicFlow/issues/754
|
|
28
|
+
this.deviation = 20;
|
|
26
29
|
this.dndAdd = true;
|
|
27
30
|
this.dropAdd = true;
|
|
28
31
|
this.eventHandler();
|
|
@@ -41,6 +44,7 @@ var InsertNodeInPolyline = /** @class */ (function () {
|
|
|
41
44
|
var data = _a.data;
|
|
42
45
|
var edges = _this._lf.graphModel.edges;
|
|
43
46
|
var id = data.id;
|
|
47
|
+
// 只有游离节点才能插入到连线上
|
|
44
48
|
var pureNode = true;
|
|
45
49
|
for (var i = 0; i < edges.length; i++) {
|
|
46
50
|
if (edges[i].sourceNodeId === id || edges[i].targetNodeId === id) {
|
|
@@ -59,19 +63,26 @@ var InsertNodeInPolyline = /** @class */ (function () {
|
|
|
59
63
|
var nodeModel = this._lf.getNodeModelById(nodeData.id);
|
|
60
64
|
for (var i = 0; i < edges.length; i++) {
|
|
61
65
|
// eslint-disable-next-line max-len
|
|
62
|
-
var _a = isNodeInSegment(nodeModel, edges[i]), crossIndex = _a.crossIndex, crossPoints = _a.crossPoints;
|
|
66
|
+
var _a = isNodeInSegment(nodeModel, edges[i], this.deviation), crossIndex = _a.crossIndex, crossPoints = _a.crossPoints;
|
|
63
67
|
if (crossIndex >= 0) {
|
|
64
68
|
var _b = edges[i], sourceNodeId = _b.sourceNodeId, targetNodeId = _b.targetNodeId, id = _b.id, type = _b.type, pointsList = _b.pointsList;
|
|
69
|
+
// fix https://github.com/didi/LogicFlow/issues/996
|
|
70
|
+
var startPoint = cloneDeep(pointsList[0]);
|
|
71
|
+
var endPoint = cloneDeep(crossPoints.startCrossPoint);
|
|
65
72
|
this._lf.addEdge({
|
|
66
73
|
type: type,
|
|
67
74
|
sourceNodeId: sourceNodeId,
|
|
68
75
|
targetNodeId: nodeData.id,
|
|
76
|
+
startPoint: startPoint,
|
|
77
|
+
endPoint: endPoint,
|
|
69
78
|
pointsList: __spread(pointsList.slice(0, crossIndex), [crossPoints.startCrossPoint]),
|
|
70
79
|
});
|
|
71
80
|
this._lf.addEdge({
|
|
72
81
|
type: type,
|
|
73
82
|
sourceNodeId: nodeData.id,
|
|
74
83
|
targetNodeId: targetNodeId,
|
|
84
|
+
startPoint: cloneDeep(crossPoints.endCrossPoint),
|
|
85
|
+
endPoint: cloneDeep(pointsList[pointsList.length - 1]),
|
|
75
86
|
pointsList: __spread([crossPoints.endCrossPoint], pointsList.slice(crossIndex)),
|
|
76
87
|
});
|
|
77
88
|
this._lf.deleteEdge(id);
|
|
@@ -122,6 +122,10 @@ var GroupNodeModel = /** @class */ (function (_super) {
|
|
|
122
122
|
var allEdges = this.incoming.edges.concat(this.outgoing.edges);
|
|
123
123
|
this.children.forEach(function (elementId) {
|
|
124
124
|
var nodeModel = _this.graphModel.getElement(elementId);
|
|
125
|
+
// FIX: https://github.com/didi/LogicFlow/issues/1007
|
|
126
|
+
if (nodeModel.isGroup && !nodeModel.isFolded) {
|
|
127
|
+
nodeModel.foldGroup(isFolded);
|
|
128
|
+
}
|
|
125
129
|
nodeModel.visible = !isFolded;
|
|
126
130
|
allEdges = allEdges.concat(nodeModel.incoming.edges.concat(nodeModel.outgoing.edges));
|
|
127
131
|
});
|
|
@@ -37,8 +37,10 @@ declare class Group {
|
|
|
37
37
|
* 3. 分组节点取消选中后,不会将分组节点重置为原来的高度。
|
|
38
38
|
* 4. 由于LogicFlow核心目标是支持用户手动绘制流程图,所以不考虑一张流程图超过1000个分组节点的情况。
|
|
39
39
|
*/
|
|
40
|
-
nodeSelected: ({ data }: {
|
|
40
|
+
nodeSelected: ({ data, isMultiple, isSelected }: {
|
|
41
41
|
data: any;
|
|
42
|
+
isMultiple: any;
|
|
43
|
+
isSelected: any;
|
|
42
44
|
}) => void;
|
|
43
45
|
toFrontGroup: (model: any) => void;
|
|
44
46
|
/**
|
|
@@ -51,7 +51,7 @@ var Group = /** @class */ (function () {
|
|
|
51
51
|
data.children.forEach(function (nodeId) {
|
|
52
52
|
_this.nodeGroupMap.set(nodeId, data.id);
|
|
53
53
|
});
|
|
54
|
-
_this.nodeSelected({ data: data });
|
|
54
|
+
_this.nodeSelected({ data: data, isSelected: false, isMultiple: false });
|
|
55
55
|
}
|
|
56
56
|
};
|
|
57
57
|
this.deleteGroupChild = function (_a) {
|
|
@@ -94,7 +94,7 @@ var Group = /** @class */ (function () {
|
|
|
94
94
|
* 4. 由于LogicFlow核心目标是支持用户手动绘制流程图,所以不考虑一张流程图超过1000个分组节点的情况。
|
|
95
95
|
*/
|
|
96
96
|
this.nodeSelected = function (_a) {
|
|
97
|
-
var data = _a.data;
|
|
97
|
+
var data = _a.data, isMultiple = _a.isMultiple, isSelected = _a.isSelected;
|
|
98
98
|
var nodeModel = _this.lf.getNodeModelById(data.id);
|
|
99
99
|
_this.toFrontGroup(nodeModel);
|
|
100
100
|
// 重置所有的group zIndex,防止group节点zIndex增长为正。
|
|
@@ -113,6 +113,25 @@ var Group = /** @class */ (function () {
|
|
|
113
113
|
group.setZIndex(_this.topGroupZIndex);
|
|
114
114
|
}
|
|
115
115
|
}
|
|
116
|
+
// FIX #1004
|
|
117
|
+
// 如果节点被多选,
|
|
118
|
+
// 这个节点是分组,则将分组的所有子节点取消选中
|
|
119
|
+
// 这个节点是分组的子节点,且其所属分组节点已选,则取消选中
|
|
120
|
+
if (isMultiple && isSelected) {
|
|
121
|
+
if (nodeModel.isGroup) {
|
|
122
|
+
nodeModel.children.forEach(function (child) {
|
|
123
|
+
var childModel = _this.lf.graphModel.getElement(child);
|
|
124
|
+
childModel.setSelected(false);
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
else {
|
|
128
|
+
var groupId = _this.nodeGroupMap.get(data.id);
|
|
129
|
+
if (groupId) {
|
|
130
|
+
var groupModel = _this.lf.getNodeModelById(groupId);
|
|
131
|
+
groupModel.isSelected && nodeModel.setSelected(false);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
116
135
|
};
|
|
117
136
|
this.toFrontGroup = function (model) {
|
|
118
137
|
if (!model || !model.isGroup) {
|
|
@@ -149,7 +168,7 @@ var Group = /** @class */ (function () {
|
|
|
149
168
|
return true;
|
|
150
169
|
});
|
|
151
170
|
lf.graphModel.group = this;
|
|
152
|
-
lf.on('node:add,node:drop', this.appendNodeToGroup);
|
|
171
|
+
lf.on('node:add,node:drop,node:dnd-add', this.appendNodeToGroup);
|
|
153
172
|
lf.on('node:delete', this.deleteGroupChild);
|
|
154
173
|
lf.on('node:dnd-drag,node:drag', this.setActiveGroup);
|
|
155
174
|
lf.on('node:click', this.nodeSelected);
|