@logicflow/extension 1.1.20 → 1.2.0-alpha.10
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 +21 -17
- package/cjs/NodeResize/Control/Util.js +11 -11
- package/cjs/NodeResize/Node/DiamondResize.js +10 -8
- package/cjs/NodeResize/Node/EllipseResize.js +10 -8
- package/cjs/NodeResize/Node/HtmlResize.js +10 -8
- package/cjs/NodeResize/Node/RectResize.js +10 -8
- package/cjs/bpmn-adapter/index.js +124 -76
- package/cjs/bpmn-adapter/json2xml.js +5 -2
- package/cjs/bpmn-adapter/xml2json.js +38 -284
- package/cjs/components/context-menu/index.js +2 -2
- package/cjs/components/control/index.js +16 -16
- package/cjs/components/menu/index.js +32 -32
- package/cjs/components/mini-map/index.js +2 -2
- package/cjs/components/selection-select/index.js +27 -7
- package/cjs/index.js +1 -0
- package/cjs/insert-node-in-polyline/edge.js +4 -4
- package/cjs/insert-node-in-polyline/index.js +1 -1
- package/cjs/locale/en-locale/en.js +22 -0
- package/cjs/locale/en-locale/index.js +29 -0
- package/cjs/locale/locale.js +19 -0
- package/cjs/materials/group/GroupNode.js +24 -14
- package/cjs/materials/group/index.js +3 -3
- package/cjs/tools/auto-layout/index.js +9 -9
- package/es/NodeResize/Control/Control.d.ts +1 -1
- package/es/NodeResize/Control/Control.js +22 -18
- package/es/NodeResize/Control/Util.d.ts +3 -3
- package/es/NodeResize/Control/Util.js +7 -7
- package/es/NodeResize/Node/DiamondResize.d.ts +1 -1
- package/es/NodeResize/Node/DiamondResize.js +10 -8
- package/es/NodeResize/Node/EllipseResize.d.ts +1 -1
- package/es/NodeResize/Node/EllipseResize.js +10 -8
- package/es/NodeResize/Node/HtmlResize.d.ts +1 -1
- package/es/NodeResize/Node/HtmlResize.js +10 -8
- package/es/NodeResize/Node/RectResize.d.ts +1 -1
- package/es/NodeResize/Node/RectResize.js +10 -8
- package/es/bpmn-adapter/index.d.ts +41 -33
- package/es/bpmn-adapter/index.js +124 -76
- package/es/bpmn-adapter/json2xml.js +5 -2
- package/es/bpmn-adapter/xml2json.js +38 -284
- package/es/components/context-menu/index.js +2 -2
- package/es/components/control/index.d.ts +2 -3
- package/es/components/control/index.js +16 -16
- package/es/components/menu/index.d.ts +2 -3
- package/es/components/menu/index.js +32 -32
- package/es/components/mini-map/index.js +2 -2
- package/es/components/selection-select/index.d.ts +2 -1
- package/es/components/selection-select/index.js +27 -7
- package/es/index.d.ts +1 -0
- package/es/index.js +1 -0
- package/es/insert-node-in-polyline/edge.d.ts +3 -3
- package/es/insert-node-in-polyline/edge.js +3 -3
- package/es/insert-node-in-polyline/index.js +2 -2
- package/es/locale/en-locale/en.d.ts +19 -0
- package/es/locale/en-locale/en.js +19 -0
- package/es/locale/en-locale/index.d.ts +9 -0
- package/es/locale/en-locale/index.js +26 -0
- package/es/locale/locale.d.ts +6 -0
- package/es/locale/locale.js +16 -0
- package/es/materials/group/GroupNode.d.ts +1 -1
- package/es/materials/group/GroupNode.js +24 -14
- package/es/materials/group/index.d.ts +1 -1
- package/es/materials/group/index.js +3 -3
- package/es/tools/auto-layout/index.d.ts +2 -2
- package/es/tools/auto-layout/index.js +9 -9
- 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/EnLocale.js +1 -0
- 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/NodeResize/Control/Control.d.ts +1 -1
- package/types/NodeResize/Control/Util.d.ts +3 -3
- package/types/NodeResize/Node/DiamondResize.d.ts +1 -1
- package/types/NodeResize/Node/EllipseResize.d.ts +1 -1
- package/types/NodeResize/Node/HtmlResize.d.ts +1 -1
- package/types/NodeResize/Node/RectResize.d.ts +1 -1
- package/types/bpmn-adapter/index.d.ts +41 -33
- package/types/components/control/index.d.ts +2 -3
- package/types/components/menu/index.d.ts +2 -3
- package/types/components/selection-select/index.d.ts +2 -1
- package/types/index.d.ts +1 -0
- package/types/insert-node-in-polyline/edge.d.ts +3 -3
- package/types/materials/group/GroupNode.d.ts +1 -1
- package/types/materials/group/index.d.ts +1 -1
- package/types/tools/auto-layout/index.d.ts +2 -2
|
@@ -175,11 +175,11 @@ var MiniMap = /** @class */ (function () {
|
|
|
175
175
|
nodes.forEach(function (_a) {
|
|
176
176
|
var x = _a.x, y = _a.y, _b = _a.width, width = _b === void 0 ? 200 : _b, _c = _a.height, height = _c === void 0 ? 200 : _c;
|
|
177
177
|
var nodeLeft = x - width / 2;
|
|
178
|
-
var
|
|
178
|
+
var nodeRight = x + width / 2;
|
|
179
179
|
var nodeTop = y - height / 2;
|
|
180
180
|
var nodeBottom = y + height / 2;
|
|
181
181
|
left = nodeLeft < left ? nodeLeft : left;
|
|
182
|
-
right =
|
|
182
|
+
right = nodeRight > right ? nodeRight : right;
|
|
183
183
|
top = nodeTop < top ? nodeTop : top;
|
|
184
184
|
bottom = nodeBottom > bottom ? nodeBottom : bottom;
|
|
185
185
|
});
|
|
@@ -6,7 +6,7 @@ var SelectionSelect = /** @class */ (function () {
|
|
|
6
6
|
var _this = this;
|
|
7
7
|
var lf = _a.lf;
|
|
8
8
|
this.__disabled = false;
|
|
9
|
-
this.
|
|
9
|
+
this.isDefaultStopMoveGraph = false;
|
|
10
10
|
this.isWholeNode = true;
|
|
11
11
|
this.isWholeEdge = true;
|
|
12
12
|
this.__draw = function (ev) {
|
|
@@ -43,16 +43,18 @@ var SelectionSelect = /** @class */ (function () {
|
|
|
43
43
|
}
|
|
44
44
|
var lt = [Math.min(x, x1), Math.min(y, y1)];
|
|
45
45
|
var rt = [Math.max(x, x1), Math.max(y, y1)];
|
|
46
|
-
var elements = _this.lf.getAreaElement(lt, rt, _this.isWholeEdge, _this.isWholeNode);
|
|
46
|
+
var elements = _this.lf.graphModel.getAreaElement(lt, rt, _this.isWholeEdge, _this.isWholeNode);
|
|
47
47
|
elements.forEach(function (element) {
|
|
48
|
-
_this.
|
|
48
|
+
if (_this.isSelectElement(element)) {
|
|
49
|
+
_this.lf.selectElementById(element.id, true);
|
|
50
|
+
}
|
|
49
51
|
});
|
|
50
52
|
_this.lf.emit('selection:selected', elements);
|
|
51
53
|
};
|
|
52
54
|
this.lf = lf;
|
|
53
|
-
// 初始化
|
|
55
|
+
// 初始化isDefaultStopMoveGraph取值
|
|
54
56
|
var stopMoveGraph = lf.getEditConfig().stopMoveGraph;
|
|
55
|
-
this.
|
|
57
|
+
this.isDefaultStopMoveGraph = stopMoveGraph;
|
|
56
58
|
lf.openSelectionSelect = function () {
|
|
57
59
|
_this.openSelectionSelect();
|
|
58
60
|
};
|
|
@@ -100,7 +102,7 @@ var SelectionSelect = /** @class */ (function () {
|
|
|
100
102
|
SelectionSelect.prototype.openSelectionSelect = function () {
|
|
101
103
|
var stopMoveGraph = this.lf.getEditConfig().stopMoveGraph;
|
|
102
104
|
if (!stopMoveGraph) {
|
|
103
|
-
this.
|
|
105
|
+
this.isDefaultStopMoveGraph = false;
|
|
104
106
|
this.lf.updateEditConfig({
|
|
105
107
|
stopMoveGraph: true,
|
|
106
108
|
});
|
|
@@ -111,13 +113,31 @@ var SelectionSelect = /** @class */ (function () {
|
|
|
111
113
|
* 关闭选区
|
|
112
114
|
*/
|
|
113
115
|
SelectionSelect.prototype.closeSelectionSelect = function () {
|
|
114
|
-
if (!this.
|
|
116
|
+
if (!this.isDefaultStopMoveGraph) {
|
|
115
117
|
this.lf.updateEditConfig({
|
|
116
118
|
stopMoveGraph: false,
|
|
117
119
|
});
|
|
118
120
|
}
|
|
119
121
|
this.close();
|
|
120
122
|
};
|
|
123
|
+
SelectionSelect.prototype.isSelectElement = function (elementModel) {
|
|
124
|
+
// 如果不可见,则不被选中
|
|
125
|
+
if (!elementModel.visible)
|
|
126
|
+
return false;
|
|
127
|
+
var group = this.lf.extension.group;
|
|
128
|
+
// 节点在group中,则不被选中
|
|
129
|
+
if (group) {
|
|
130
|
+
if (elementModel.BaseType === 'node' && group.getNodeGroup(elementModel.id))
|
|
131
|
+
return false;
|
|
132
|
+
if (elementModel.BaseType === 'edge') {
|
|
133
|
+
if (group.getNodeGroup(elementModel.sourceNodeId)
|
|
134
|
+
|| group.getNodeGroup(elementModel.targetNodeId)) {
|
|
135
|
+
return false;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
return true;
|
|
140
|
+
};
|
|
121
141
|
SelectionSelect.prototype.open = function () {
|
|
122
142
|
this.__disabled = false;
|
|
123
143
|
};
|
package/cjs/index.js
CHANGED
|
@@ -29,4 +29,5 @@ __exportStar(require("./tools/flow-path"), exports);
|
|
|
29
29
|
__exportStar(require("./tools/auto-layout"), exports);
|
|
30
30
|
__exportStar(require("./bpmn-adapter/xml2json"), exports);
|
|
31
31
|
__exportStar(require("./bpmn-adapter/json2xml"), exports);
|
|
32
|
+
__exportStar(require("./locale/en-locale"), exports);
|
|
32
33
|
__exportStar(require("./components/highlight"), exports);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.isNodeInSegment = exports.crossPointInSegment = exports.isInSegment = void 0;
|
|
4
4
|
// 这个里面的函数有些在core中已经存在,为了解耦关系,没有引用
|
|
5
5
|
var SegmentDirection;
|
|
6
6
|
(function (SegmentDirection) {
|
|
@@ -45,7 +45,7 @@ var segmentDirection = function (start, end) {
|
|
|
45
45
|
return direction;
|
|
46
46
|
};
|
|
47
47
|
// 节点是够在线段内,求出节点与线段的交点
|
|
48
|
-
exports.
|
|
48
|
+
exports.crossPointInSegment = function (node, start, end) {
|
|
49
49
|
var bBox = getNodeBBox(node);
|
|
50
50
|
var direction = segmentDirection(start, end);
|
|
51
51
|
var maxX = Math.max(start.x, end.x);
|
|
@@ -86,12 +86,12 @@ exports.corssPointInSegement = function (node, start, end) {
|
|
|
86
86
|
};
|
|
87
87
|
// 节点是否在线段内
|
|
88
88
|
// eslint-disable-next-line max-len
|
|
89
|
-
exports.
|
|
89
|
+
exports.isNodeInSegment = function (node, polyline) {
|
|
90
90
|
var x = node.x, y = node.y;
|
|
91
91
|
var pointsList = polyline.pointsList;
|
|
92
92
|
for (var i = 0; i < pointsList.length - 1; i++) {
|
|
93
93
|
if (exports.isInSegment({ x: x, y: y }, pointsList[i], pointsList[i + 1])) {
|
|
94
|
-
var bBoxCross = exports.
|
|
94
|
+
var bBoxCross = exports.crossPointInSegment(node, pointsList[i], pointsList[i + 1]);
|
|
95
95
|
if (bBoxCross) {
|
|
96
96
|
return {
|
|
97
97
|
crossIndex: i + 1,
|
|
@@ -62,7 +62,7 @@ var InsertNodeInPolyline = /** @class */ (function () {
|
|
|
62
62
|
var nodeModel = this._lf.getNodeModelById(nodeData.id);
|
|
63
63
|
for (var i = 0; i < edges.length; i++) {
|
|
64
64
|
// eslint-disable-next-line max-len
|
|
65
|
-
var _a = edge_1.
|
|
65
|
+
var _a = edge_1.isNodeInSegment(nodeModel, edges[i]), crossIndex = _a.crossIndex, crossPoints = _a.crossPoints;
|
|
66
66
|
if (crossIndex >= 0) {
|
|
67
67
|
var _b = edges[i], sourceNodeId = _b.sourceNodeId, targetNodeId = _b.targetNodeId, id = _b.id, type = _b.type, pointsList = _b.pointsList;
|
|
68
68
|
this._lf.addEdge({
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.en = void 0;
|
|
4
|
+
var en = {
|
|
5
|
+
文本: 'text',
|
|
6
|
+
开始: 'start',
|
|
7
|
+
缩小流程图: 'zoom in',
|
|
8
|
+
缩小: 'zoom in',
|
|
9
|
+
放大流程图: 'zoom out',
|
|
10
|
+
放大: 'zoom out',
|
|
11
|
+
恢复流程原有尺寸: 'adapt to original size',
|
|
12
|
+
适应: 'adapt',
|
|
13
|
+
回到上一步: 'undo',
|
|
14
|
+
上一步: 'undo',
|
|
15
|
+
移到下一步: 'redo',
|
|
16
|
+
下一步: 'redo',
|
|
17
|
+
删除: 'delete',
|
|
18
|
+
编辑文本: 'edit text',
|
|
19
|
+
复制: 'copy',
|
|
20
|
+
};
|
|
21
|
+
exports.en = en;
|
|
22
|
+
exports.default = en;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
extendStatics(d, b);
|
|
11
|
+
function __() { this.constructor = d; }
|
|
12
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
13
|
+
};
|
|
14
|
+
})();
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.EnLocale = void 0;
|
|
17
|
+
var locale_1 = require("../locale");
|
|
18
|
+
var en_1 = require("./en");
|
|
19
|
+
var EnLocale = /** @class */ (function (_super) {
|
|
20
|
+
__extends(EnLocale, _super);
|
|
21
|
+
function EnLocale(_a) {
|
|
22
|
+
var LogicFlow = _a.LogicFlow;
|
|
23
|
+
return _super.call(this, LogicFlow, en_1.default) || this;
|
|
24
|
+
}
|
|
25
|
+
EnLocale.pluginName = 'enLocale';
|
|
26
|
+
return EnLocale;
|
|
27
|
+
}(locale_1.Locale));
|
|
28
|
+
exports.EnLocale = EnLocale;
|
|
29
|
+
exports.default = EnLocale;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Locale = void 0;
|
|
4
|
+
var Locale = /** @class */ (function () {
|
|
5
|
+
function Locale(LogicFlow, map) {
|
|
6
|
+
if (LogicFlow && map) {
|
|
7
|
+
this.replaceTranslator(LogicFlow, map);
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
Locale.prototype.replaceTranslator = function (LogicFlow, map) {
|
|
11
|
+
LogicFlow.t = function (text) { return (map[text] ? map[text] : text); };
|
|
12
|
+
};
|
|
13
|
+
Locale.prototype.setDefault = function (LogicFlow) {
|
|
14
|
+
LogicFlow.t = Locale.defaultTranslator;
|
|
15
|
+
};
|
|
16
|
+
Locale.defaultTranslator = function (text) { return text; };
|
|
17
|
+
return Locale;
|
|
18
|
+
}());
|
|
19
|
+
exports.Locale = Locale;
|
|
@@ -107,24 +107,30 @@ var GroupNodeModel = /** @class */ (function (_super) {
|
|
|
107
107
|
this.isFolded = isFolded;
|
|
108
108
|
// step 1
|
|
109
109
|
if (isFolded) {
|
|
110
|
-
this.x = this.x - this.width / 2 + this.foldedWidth / 2;
|
|
111
|
-
this.y = this.y - this.height / 2 + this.foldedHeight / 2;
|
|
112
110
|
this.unfoldedWidth = this.width;
|
|
113
111
|
this.unfoldedHight = this.height;
|
|
114
|
-
this.
|
|
115
|
-
|
|
112
|
+
this.updateAttributes({
|
|
113
|
+
x: this.x - this.width / 2 + this.foldedWidth / 2,
|
|
114
|
+
y: this.y - this.height / 2 + this.foldedHeight / 2,
|
|
115
|
+
width: this.foldedWidth,
|
|
116
|
+
height: this.foldedHeight,
|
|
117
|
+
});
|
|
116
118
|
}
|
|
117
119
|
else {
|
|
118
|
-
this.
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
120
|
+
this.updateAttributes({
|
|
121
|
+
width: this.unfoldedWidth,
|
|
122
|
+
height: this.unfoldedHight,
|
|
123
|
+
x: this.x + this.unfoldedWidth / 2 - this.foldedWidth / 2,
|
|
124
|
+
y: this.y + this.unfoldedHight / 2 - this.foldedHeight / 2,
|
|
125
|
+
});
|
|
122
126
|
}
|
|
123
127
|
// step 2
|
|
124
128
|
var allEdges = this.incoming.edges.concat(this.outgoing.edges);
|
|
125
129
|
this.children.forEach(function (elementId) {
|
|
126
130
|
var nodeModel = _this.graphModel.getElement(elementId);
|
|
127
|
-
nodeModel.
|
|
131
|
+
nodeModel.updateAttributes({
|
|
132
|
+
visible: !isFolded,
|
|
133
|
+
});
|
|
128
134
|
allEdges = allEdges.concat(nodeModel.incoming.edges.concat(nodeModel.outgoing.edges));
|
|
129
135
|
});
|
|
130
136
|
// step 3
|
|
@@ -196,7 +202,9 @@ var GroupNodeModel = /** @class */ (function (_super) {
|
|
|
196
202
|
if (targetNodeIdGroup.id !== _this.id || sourceNodeIdGroup.id !== _this.id) {
|
|
197
203
|
_this.createVirtualEdge(data);
|
|
198
204
|
}
|
|
199
|
-
edgeModel.
|
|
205
|
+
edgeModel.updateAttributes({
|
|
206
|
+
visible: false,
|
|
207
|
+
});
|
|
200
208
|
}
|
|
201
209
|
// 展开时,处理被隐藏的边的逻辑
|
|
202
210
|
if (!isFolded && edgeModel.visible === false) {
|
|
@@ -212,7 +220,9 @@ var GroupNodeModel = /** @class */ (function (_super) {
|
|
|
212
220
|
_this.createVirtualEdge(data);
|
|
213
221
|
}
|
|
214
222
|
else {
|
|
215
|
-
edgeModel.
|
|
223
|
+
edgeModel.updateAttributes({
|
|
224
|
+
visible: true,
|
|
225
|
+
});
|
|
216
226
|
}
|
|
217
227
|
}
|
|
218
228
|
});
|
|
@@ -222,7 +232,7 @@ var GroupNodeModel = /** @class */ (function (_super) {
|
|
|
222
232
|
var model = this.graphModel.addEdge(edgeData);
|
|
223
233
|
model.virtual = true;
|
|
224
234
|
// 强制不保存group连线数据
|
|
225
|
-
model.getData =
|
|
235
|
+
// model.getData = () => null;
|
|
226
236
|
model.text.editable = false;
|
|
227
237
|
model.isFoldedEdge = true;
|
|
228
238
|
};
|
|
@@ -295,7 +305,7 @@ var GroupNode = /** @class */ (function (_super) {
|
|
|
295
305
|
var _a = this.props.model, resizable = _a.resizable, properties = _a.properties;
|
|
296
306
|
return resizable && !properties.isFolded ? _super.prototype.getControlGroup.call(this) : null;
|
|
297
307
|
};
|
|
298
|
-
GroupNode.prototype.
|
|
308
|
+
GroupNode.prototype.getAddAbleShape = function () {
|
|
299
309
|
var _a = this.props.model, width = _a.width, height = _a.height, x = _a.x, y = _a.y, radius = _a.radius, properties = _a.properties;
|
|
300
310
|
if (!properties.groupAddable)
|
|
301
311
|
return null;
|
|
@@ -341,7 +351,7 @@ var GroupNode = /** @class */ (function (_super) {
|
|
|
341
351
|
};
|
|
342
352
|
GroupNode.prototype.getResizeShape = function () {
|
|
343
353
|
return core_1.h('g', {}, [
|
|
344
|
-
this.
|
|
354
|
+
this.getAddAbleShape(),
|
|
345
355
|
_super.prototype.getResizeShape.call(this),
|
|
346
356
|
this.getFoldIcon(),
|
|
347
357
|
]);
|
|
@@ -40,7 +40,7 @@ var Group = /** @class */ (function () {
|
|
|
40
40
|
});
|
|
41
41
|
}
|
|
42
42
|
};
|
|
43
|
-
this.
|
|
43
|
+
this.appendNodeToGroup = function (_a) {
|
|
44
44
|
var data = _a.data;
|
|
45
45
|
// 如果这个节点之前已经在group中了,则将其从之前的group中移除
|
|
46
46
|
var preGroupId = _this.nodeGroupMap.get(data.id);
|
|
@@ -114,9 +114,9 @@ var Group = /** @class */ (function () {
|
|
|
114
114
|
return true;
|
|
115
115
|
});
|
|
116
116
|
lf.graphModel.group = this;
|
|
117
|
-
lf.on('node:add', this.
|
|
117
|
+
lf.on('node:add', this.appendNodeToGroup);
|
|
118
118
|
lf.on('node:delete', this.deleteGroupChild);
|
|
119
|
-
lf.on('node:drop', this.
|
|
119
|
+
lf.on('node:drop', this.appendNodeToGroup);
|
|
120
120
|
lf.on('node:dnd-drag', this.setActiveGroup);
|
|
121
121
|
lf.on('node:drag', this.setActiveGroup);
|
|
122
122
|
lf.on('graph:rendered', this.graphRendered);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/**
|
|
3
3
|
* 自动布局插件
|
|
4
|
-
* 依赖
|
|
4
|
+
* 依赖flow-path插件
|
|
5
5
|
* 未完善
|
|
6
6
|
*/
|
|
7
7
|
var __assign = (this && this.__assign) || function () {
|
|
@@ -141,7 +141,7 @@ var AutoLayout = /** @class */ (function () {
|
|
|
141
141
|
var target = this.newNodeMap.get(targetNodeId);
|
|
142
142
|
var _a = this.getShape(sourceNodeId), width = _a.width, height = _a.height;
|
|
143
143
|
var _b = this.getShape(targetNodeId), targetWidth = _b.width, targetHeight = _b.height;
|
|
144
|
-
var
|
|
144
|
+
var positionType = this.getRelativePosition(source, target);
|
|
145
145
|
var startPoint = {
|
|
146
146
|
x: source.x,
|
|
147
147
|
y: source.y,
|
|
@@ -150,7 +150,7 @@ var AutoLayout = /** @class */ (function () {
|
|
|
150
150
|
x: target.x,
|
|
151
151
|
y: target.y,
|
|
152
152
|
};
|
|
153
|
-
switch (
|
|
153
|
+
switch (positionType) {
|
|
154
154
|
case POSITION_TYPE.LEFT:
|
|
155
155
|
startPoint.x = source.x + width / 2;
|
|
156
156
|
endPoint.x = target.x - targetWidth / 2;
|
|
@@ -176,22 +176,22 @@ var AutoLayout = /** @class */ (function () {
|
|
|
176
176
|
* source一定在target左边。
|
|
177
177
|
* 1. 如果source和target在同一x, y坐标内容。
|
|
178
178
|
* 2. 如果source在target左上方。
|
|
179
|
-
* 3. 如果
|
|
179
|
+
* 3. 如果source在target左下方。
|
|
180
180
|
*/
|
|
181
181
|
AutoLayout.prototype.getRelativePosition = function (source, target) {
|
|
182
182
|
var y = source.y;
|
|
183
183
|
var y1 = target.y;
|
|
184
|
-
var
|
|
184
|
+
var positionType;
|
|
185
185
|
if (y < y1) {
|
|
186
|
-
|
|
186
|
+
positionType = -1;
|
|
187
187
|
}
|
|
188
188
|
else if (y === y1) {
|
|
189
|
-
|
|
189
|
+
positionType = 0;
|
|
190
190
|
}
|
|
191
191
|
else {
|
|
192
|
-
|
|
192
|
+
positionType = 1;
|
|
193
193
|
}
|
|
194
|
-
return
|
|
194
|
+
return positionType;
|
|
195
195
|
};
|
|
196
196
|
/**
|
|
197
197
|
* 获取边节点图形的宽高。
|
|
@@ -25,7 +25,7 @@ var __assign = (this && this.__assign) || function () {
|
|
|
25
25
|
import { h, Component } from 'preact';
|
|
26
26
|
import { LogicFlowUtil } from '@logicflow/core';
|
|
27
27
|
import Rect from '../BasicShape/Rect';
|
|
28
|
-
import {
|
|
28
|
+
import { getDiamondResizeEdgePoint, getEllipseResizeEdgePoint, getRectResizeEdgePoint, ModelType } from './Util';
|
|
29
29
|
var StepDrag = LogicFlowUtil.StepDrag;
|
|
30
30
|
var Control = /** @class */ (function (_super) {
|
|
31
31
|
__extends(Control, _super);
|
|
@@ -35,9 +35,11 @@ var Control = /** @class */ (function (_super) {
|
|
|
35
35
|
_this.updatePosition = function (_a) {
|
|
36
36
|
var deltaX = _a.deltaX, deltaY = _a.deltaY;
|
|
37
37
|
var _b = _this.nodeModel, x = _b.x, y = _b.y;
|
|
38
|
-
_this.nodeModel.x = x + deltaX / 2;
|
|
39
|
-
_this.nodeModel.y = y + deltaY / 2;
|
|
40
38
|
_this.nodeModel.moveText(deltaX / 2, deltaY / 2);
|
|
39
|
+
_this.nodeModel.updateAttributes({
|
|
40
|
+
x: x + deltaX / 2,
|
|
41
|
+
y: y + deltaY / 2,
|
|
42
|
+
});
|
|
41
43
|
};
|
|
42
44
|
// 计算control拖动后,节点的宽高
|
|
43
45
|
_this.getResize = function (_a) {
|
|
@@ -53,7 +55,7 @@ var Control = /** @class */ (function (_super) {
|
|
|
53
55
|
resize.height = height - deltaY * pct;
|
|
54
56
|
break;
|
|
55
57
|
case 2:
|
|
56
|
-
resize.width = width + deltaX;
|
|
58
|
+
resize.width = width + deltaX * pct;
|
|
57
59
|
resize.height = height + deltaY * pct;
|
|
58
60
|
break;
|
|
59
61
|
case 3:
|
|
@@ -91,14 +93,16 @@ var Control = /** @class */ (function (_super) {
|
|
|
91
93
|
}
|
|
92
94
|
_this.updatePosition({ deltaX: deltaX, deltaY: deltaY });
|
|
93
95
|
// 更新宽高
|
|
94
|
-
_this.nodeModel.width = size.width;
|
|
95
|
-
_this.nodeModel.height = size.height;
|
|
96
96
|
_this.nodeModel.setProperties({
|
|
97
97
|
nodeSize: {
|
|
98
98
|
width: size.width,
|
|
99
99
|
height: size.height,
|
|
100
100
|
},
|
|
101
101
|
});
|
|
102
|
+
_this.nodeModel.updateAttributes({
|
|
103
|
+
width: size.width,
|
|
104
|
+
height: size.height,
|
|
105
|
+
});
|
|
102
106
|
var edges = _this.getNodeEdges(id);
|
|
103
107
|
var beforeNode = {
|
|
104
108
|
x: x,
|
|
@@ -123,12 +127,12 @@ var Control = /** @class */ (function (_super) {
|
|
|
123
127
|
var afterPoint;
|
|
124
128
|
edges.sourceEdges.forEach(function (item) {
|
|
125
129
|
params.point = item.startPoint;
|
|
126
|
-
afterPoint =
|
|
130
|
+
afterPoint = getRectResizeEdgePoint(params);
|
|
127
131
|
item.updateStartPoint(afterPoint);
|
|
128
132
|
});
|
|
129
133
|
edges.targetEdges.forEach(function (item) {
|
|
130
134
|
params.point = item.endPoint;
|
|
131
|
-
afterPoint =
|
|
135
|
+
afterPoint = getRectResizeEdgePoint(params);
|
|
132
136
|
item.updateEndPoint(afterPoint);
|
|
133
137
|
});
|
|
134
138
|
_this.eventEmit({ beforeNode: beforeNode, afterNode: afterNode });
|
|
@@ -161,9 +165,9 @@ var Control = /** @class */ (function (_super) {
|
|
|
161
165
|
_this.updatePosition({ deltaX: deltaX, deltaY: deltaY });
|
|
162
166
|
// 更新rx ry,宽高为计算属性自动更新
|
|
163
167
|
// @ts-ignore
|
|
164
|
-
_this.nodeModel.rx =
|
|
168
|
+
_this.nodeModel.rx = size.width;
|
|
165
169
|
// @ts-ignore
|
|
166
|
-
_this.nodeModel.ry =
|
|
170
|
+
_this.nodeModel.ry = size.height;
|
|
167
171
|
_this.nodeModel.setProperties({
|
|
168
172
|
nodeSize: {
|
|
169
173
|
rx: size.width,
|
|
@@ -187,12 +191,12 @@ var Control = /** @class */ (function (_super) {
|
|
|
187
191
|
var afterPoint;
|
|
188
192
|
edges.sourceEdges.forEach(function (item) {
|
|
189
193
|
params.point = item.startPoint;
|
|
190
|
-
afterPoint =
|
|
194
|
+
afterPoint = getEllipseResizeEdgePoint(params);
|
|
191
195
|
item.updateStartPoint(afterPoint);
|
|
192
196
|
});
|
|
193
197
|
edges.targetEdges.forEach(function (item) {
|
|
194
198
|
params.point = item.endPoint;
|
|
195
|
-
afterPoint =
|
|
199
|
+
afterPoint = getEllipseResizeEdgePoint(params);
|
|
196
200
|
item.updateEndPoint(afterPoint);
|
|
197
201
|
});
|
|
198
202
|
_this.eventEmit({ beforeNode: __assign(__assign({}, beforeNode), { rx: rx, ry: ry }), afterNode: afterNode });
|
|
@@ -225,9 +229,9 @@ var Control = /** @class */ (function (_super) {
|
|
|
225
229
|
_this.updatePosition({ deltaX: deltaX, deltaY: deltaY });
|
|
226
230
|
// 更新rx ry,宽高为计算属性自动更新
|
|
227
231
|
// @ts-ignore
|
|
228
|
-
_this.nodeModel.rx =
|
|
232
|
+
_this.nodeModel.rx = size.width;
|
|
229
233
|
// @ts-ignore
|
|
230
|
-
_this.nodeModel.ry =
|
|
234
|
+
_this.nodeModel.ry = size.height;
|
|
231
235
|
_this.nodeModel.setProperties({
|
|
232
236
|
nodeSize: {
|
|
233
237
|
rx: size.width,
|
|
@@ -251,12 +255,12 @@ var Control = /** @class */ (function (_super) {
|
|
|
251
255
|
var edges = _this.getNodeEdges(id);
|
|
252
256
|
edges.sourceEdges.forEach(function (item) {
|
|
253
257
|
params.point = item.startPoint;
|
|
254
|
-
afterPoint =
|
|
258
|
+
afterPoint = getDiamondResizeEdgePoint(params);
|
|
255
259
|
item.updateStartPoint(afterPoint);
|
|
256
260
|
});
|
|
257
261
|
edges.targetEdges.forEach(function (item) {
|
|
258
262
|
params.point = item.endPoint;
|
|
259
|
-
afterPoint =
|
|
263
|
+
afterPoint = getDiamondResizeEdgePoint(params);
|
|
260
264
|
item.updateEndPoint(afterPoint);
|
|
261
265
|
});
|
|
262
266
|
_this.eventEmit({ beforeNode: beforeNode, afterNode: afterNode });
|
|
@@ -268,7 +272,7 @@ var Control = /** @class */ (function (_super) {
|
|
|
268
272
|
var newNodeSize = __assign({ id: id, modelType: modelType, type: type }, afterNode);
|
|
269
273
|
_this.graphModel.eventCenter.emit('node:resize', { oldNodeSize: oldNodeSize, newNodeSize: newNodeSize });
|
|
270
274
|
};
|
|
271
|
-
_this.
|
|
275
|
+
_this.onDragging = function (_a) {
|
|
272
276
|
var deltaX = _a.deltaX, deltaY = _a.deltaY;
|
|
273
277
|
var modelType = _this.nodeModel.modelType;
|
|
274
278
|
// html和矩形的计算方式是一样的,共用一个方法
|
|
@@ -298,7 +302,7 @@ var Control = /** @class */ (function (_super) {
|
|
|
298
302
|
}
|
|
299
303
|
_this.state = {};
|
|
300
304
|
_this.dragHandler = new StepDrag({
|
|
301
|
-
|
|
305
|
+
onDragging: _this.onDragging,
|
|
302
306
|
step: step,
|
|
303
307
|
});
|
|
304
308
|
return _this;
|
|
@@ -13,7 +13,7 @@ export declare enum ModelType {
|
|
|
13
13
|
BEZIER_EDGE = "bezier-edge",
|
|
14
14
|
GRAPH = "graph"
|
|
15
15
|
}
|
|
16
|
-
export declare function
|
|
16
|
+
export declare function getRectResizeEdgePoint({ point, beforeNode, afterNode }: {
|
|
17
17
|
point: any;
|
|
18
18
|
beforeNode: any;
|
|
19
19
|
afterNode: any;
|
|
@@ -21,12 +21,12 @@ export declare function getRectReizeEdgePoint({ point, beforeNode, afterNode }:
|
|
|
21
21
|
x: any;
|
|
22
22
|
y: any;
|
|
23
23
|
};
|
|
24
|
-
export declare function
|
|
24
|
+
export declare function getEllipseResizeEdgePoint({ point, beforeNode, afterNode }: {
|
|
25
25
|
point: any;
|
|
26
26
|
beforeNode: any;
|
|
27
27
|
afterNode: any;
|
|
28
28
|
}): any;
|
|
29
|
-
export declare function
|
|
29
|
+
export declare function getDiamondResizeEdgePoint({ point, beforeNode, afterNode }: {
|
|
30
30
|
point: any;
|
|
31
31
|
beforeNode: any;
|
|
32
32
|
afterNode: any;
|
|
@@ -25,7 +25,7 @@ function getNodeBox(node) {
|
|
|
25
25
|
};
|
|
26
26
|
}
|
|
27
27
|
// 计算矩形radius设置后,四个圆角的圆心
|
|
28
|
-
function
|
|
28
|
+
function getRadiusCenter(node) {
|
|
29
29
|
var nodeBox = getNodeBox(node);
|
|
30
30
|
var radius = node.radius;
|
|
31
31
|
var minX = nodeBox.minX, minY = nodeBox.minY, maxX = nodeBox.maxX, maxY = nodeBox.maxY;
|
|
@@ -49,7 +49,7 @@ function getRidusCenter(node) {
|
|
|
49
49
|
];
|
|
50
50
|
}
|
|
51
51
|
// 获取矩形resize之后,与矩形连接边的新端点
|
|
52
|
-
export function
|
|
52
|
+
export function getRectResizeEdgePoint(_a) {
|
|
53
53
|
var point = _a.point, beforeNode = _a.beforeNode, afterNode = _a.afterNode;
|
|
54
54
|
var x = point.x, y = point.y;
|
|
55
55
|
var afterPoint = {
|
|
@@ -104,8 +104,8 @@ export function getRectReizeEdgePoint(_a) {
|
|
|
104
104
|
}
|
|
105
105
|
else {
|
|
106
106
|
// 在圆角部分
|
|
107
|
-
var
|
|
108
|
-
var afterCoc =
|
|
107
|
+
var beforeCoc = getRadiusCenter(beforeNode);
|
|
108
|
+
var afterCoc = getRadiusCenter(afterNode);
|
|
109
109
|
var nodeBox = getNodeBox(beforeNode);
|
|
110
110
|
var minX = nodeBox.minX, minY = nodeBox.minY, maxX = nodeBox.maxX, maxY = nodeBox.maxY;
|
|
111
111
|
var index = -1;
|
|
@@ -127,7 +127,7 @@ export function getRectReizeEdgePoint(_a) {
|
|
|
127
127
|
}
|
|
128
128
|
if (index > -1) {
|
|
129
129
|
// 根据夹角角度计算位置
|
|
130
|
-
var angle = Math.atan2((y -
|
|
130
|
+
var angle = Math.atan2((y - beforeCoc[index].y), (x - beforeCoc[index].x));
|
|
131
131
|
afterPoint.x = afterCoc[index].x + radius * Math.cos(angle);
|
|
132
132
|
afterPoint.y = afterCoc[index].y + radius * Math.sin(angle);
|
|
133
133
|
}
|
|
@@ -135,7 +135,7 @@ export function getRectReizeEdgePoint(_a) {
|
|
|
135
135
|
return afterPoint;
|
|
136
136
|
}
|
|
137
137
|
// 获取椭圆resize之后,与椭圆连接边的新端点
|
|
138
|
-
export function
|
|
138
|
+
export function getEllipseResizeEdgePoint(_a) {
|
|
139
139
|
var point = _a.point, beforeNode = _a.beforeNode, afterNode = _a.afterNode;
|
|
140
140
|
var rx = afterNode.rx, ry = afterNode.ry;
|
|
141
141
|
var afterPoint = point;
|
|
@@ -173,7 +173,7 @@ export function getEllipseReizeEdgePoint(_a) {
|
|
|
173
173
|
return afterPoint;
|
|
174
174
|
}
|
|
175
175
|
// 获取菱形resize之后,与菱形连接边的新端点
|
|
176
|
-
export function
|
|
176
|
+
export function getDiamondResizeEdgePoint(_a) {
|
|
177
177
|
var point = _a.point, beforeNode = _a.beforeNode, afterNode = _a.afterNode;
|
|
178
178
|
var afterPoint = point;
|
|
179
179
|
var x;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { h, DiamondNode, DiamondNodeModel } from '@logicflow/core';
|
|
2
2
|
declare class DiamondResizeModel extends DiamondNodeModel {
|
|
3
|
-
constructor(data: any, graphModel: any);
|
|
4
3
|
initNodeData(data: any): void;
|
|
4
|
+
init(): void;
|
|
5
5
|
getOutlineStyle(): import("@logicflow/core/types/constant/DefaultTheme").OutlineTheme;
|
|
6
6
|
getResizeOutlineStyle(): {
|
|
7
7
|
stroke: string;
|
|
@@ -27,14 +27,8 @@ import ControlGroup from '../Control/ControlGroup';
|
|
|
27
27
|
import Polygon from '../BasicShape/Polygon';
|
|
28
28
|
var DiamondResizeModel = /** @class */ (function (_super) {
|
|
29
29
|
__extends(DiamondResizeModel, _super);
|
|
30
|
-
function DiamondResizeModel(
|
|
31
|
-
|
|
32
|
-
var nodeSize = _this.properties.nodeSize;
|
|
33
|
-
if (nodeSize) {
|
|
34
|
-
_this.rx = nodeSize.rx;
|
|
35
|
-
_this.ry = nodeSize.ry;
|
|
36
|
-
}
|
|
37
|
-
return _this;
|
|
30
|
+
function DiamondResizeModel() {
|
|
31
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
38
32
|
}
|
|
39
33
|
DiamondResizeModel.prototype.initNodeData = function (data) {
|
|
40
34
|
_super.prototype.initNodeData.call(this, data);
|
|
@@ -44,6 +38,14 @@ var DiamondResizeModel = /** @class */ (function (_super) {
|
|
|
44
38
|
this.maxHeight = 2000;
|
|
45
39
|
this.gridSize = 1;
|
|
46
40
|
};
|
|
41
|
+
DiamondResizeModel.prototype.init = function () {
|
|
42
|
+
_super.prototype.init.call(this);
|
|
43
|
+
var nodeSize = this.properties.nodeSize;
|
|
44
|
+
if (nodeSize) {
|
|
45
|
+
this.rx = nodeSize.rx;
|
|
46
|
+
this.ry = nodeSize.ry;
|
|
47
|
+
}
|
|
48
|
+
};
|
|
47
49
|
DiamondResizeModel.prototype.getOutlineStyle = function () {
|
|
48
50
|
var style = _super.prototype.getOutlineStyle.call(this);
|
|
49
51
|
style.stroke = 'none';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { h, EllipseNode, EllipseNodeModel } from '@logicflow/core';
|
|
2
2
|
declare class EllipseResizeModel extends EllipseNodeModel {
|
|
3
|
-
constructor(data: any, graphModel: any);
|
|
4
3
|
initNodeData(data: any): void;
|
|
4
|
+
init(): void;
|
|
5
5
|
getOutlineStyle(): import("@logicflow/core/types/constant/DefaultTheme").OutlineTheme;
|
|
6
6
|
getResizeOutlineStyle(): {
|
|
7
7
|
stroke: string;
|