@logicflow/extension 1.2.0-alpha.9 → 1.2.0-next.1
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 +37 -9
- package/cjs/NodeResize/Node/DiamondResize.js +5 -2
- package/cjs/NodeResize/Node/EllipseResize.js +5 -2
- package/cjs/NodeResize/Node/HtmlResize.js +5 -2
- package/cjs/NodeResize/Node/RectResize.js +5 -2
- package/cjs/bpmn-adapter/json2xml.js +0 -1
- package/cjs/components/mini-map/index.js +24 -4
- package/cjs/components/selection-select/index.js +7 -1
- package/cjs/materials/curved-edge/index.js +47 -40
- package/cjs/materials/group/GroupNode.js +46 -13
- package/cjs/materials/group/index.js +73 -21
- package/cjs/tools/snapshot/index.js +1 -1
- package/cjs/turbo-adapter/index.js +4 -6
- package/es/NodeResize/Control/Control.d.ts +4 -0
- package/es/NodeResize/Control/Control.js +37 -9
- package/es/NodeResize/Node/DiamondResize.js +5 -2
- package/es/NodeResize/Node/EllipseResize.js +5 -2
- package/es/NodeResize/Node/HtmlResize.js +5 -2
- package/es/NodeResize/Node/RectResize.js +5 -2
- package/es/bpmn-adapter/json2xml.js +0 -1
- package/es/components/mini-map/index.d.ts +1 -0
- package/es/components/mini-map/index.js +24 -4
- package/es/components/selection-select/index.js +7 -1
- package/es/materials/curved-edge/index.d.ts +7 -6
- package/es/materials/curved-edge/index.js +47 -39
- package/es/materials/group/GroupNode.d.ts +10 -0
- package/es/materials/group/GroupNode.js +46 -13
- package/es/materials/group/index.d.ts +5 -7
- package/es/materials/group/index.js +73 -21
- package/es/tools/snapshot/index.js +1 -1
- package/es/turbo-adapter/index.js +4 -6
- 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 -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 +4 -4
- package/types/NodeResize/Control/Control.d.ts +4 -0
- package/types/components/mini-map/index.d.ts +1 -0
- package/types/materials/curved-edge/index.d.ts +7 -6
- package/types/materials/group/GroupNode.d.ts +10 -0
- package/types/materials/group/index.d.ts +5 -7
|
@@ -84,7 +84,7 @@ function convertEdgeToTurboElement(edge) {
|
|
|
84
84
|
outgoing: [targetNodeId],
|
|
85
85
|
type: getTurboType(type),
|
|
86
86
|
dockers: [],
|
|
87
|
-
properties: __assign(__assign({}, properties), { name: (text && text.value) || '', text: text, startPoint: JSON.stringify(startPoint), endPoint: JSON.stringify(endPoint), pointsList: JSON.stringify(
|
|
87
|
+
properties: __assign(__assign({}, properties), { name: (text && text.value) || '', text: text, startPoint: JSON.stringify(startPoint), endPoint: JSON.stringify(endPoint), pointsList: JSON.stringify(pointsList) }),
|
|
88
88
|
key: id,
|
|
89
89
|
};
|
|
90
90
|
}
|
|
@@ -123,16 +123,13 @@ function convertFlowElementToEdge(element) {
|
|
|
123
123
|
properties: {},
|
|
124
124
|
};
|
|
125
125
|
if (startPoint) {
|
|
126
|
-
// @ts-ignore
|
|
127
126
|
edge.startPoint = JSON.parse(startPoint);
|
|
128
127
|
}
|
|
129
128
|
if (endPoint) {
|
|
130
|
-
// @ts-ignore
|
|
131
129
|
edge.endPoint = JSON.parse(endPoint);
|
|
132
130
|
}
|
|
133
131
|
if (pointsList) {
|
|
134
|
-
|
|
135
|
-
edge.endPoint = JSON.parse(pointsList);
|
|
132
|
+
edge.pointsList = JSON.parse(pointsList);
|
|
136
133
|
}
|
|
137
134
|
// 这种转换方式,在自定义属性中不能与excludeProperties中的属性重名,否则将在转换过程中丢失
|
|
138
135
|
var excludeProperties = ['startPoint', 'endPoint', 'pointsList', 'text'];
|
|
@@ -147,6 +144,7 @@ function convertFlowElementToEdge(element) {
|
|
|
147
144
|
function convertFlowElementToNode(element) {
|
|
148
145
|
var properties = element.properties, key = element.key, type = element.type, bounds = element.bounds;
|
|
149
146
|
var x = properties.x, y = properties.y;
|
|
147
|
+
var text = properties.text;
|
|
150
148
|
if (x === undefined) {
|
|
151
149
|
var _a = __read(bounds, 2), _b = _a[0], x1 = _b.x, y1 = _b.y, _c = _a[1], x2 = _c.x, y2 = _c.y;
|
|
152
150
|
x = (x1 + x2) / 2;
|
|
@@ -157,7 +155,7 @@ function convertFlowElementToNode(element) {
|
|
|
157
155
|
type: TurboTypeMap[type],
|
|
158
156
|
x: x,
|
|
159
157
|
y: y,
|
|
160
|
-
text:
|
|
158
|
+
text: text,
|
|
161
159
|
properties: {},
|
|
162
160
|
};
|
|
163
161
|
// 这种转换方式,在自定义属性中不能与excludeProperties中的属性重名,否则将在转换过程中丢失
|
|
@@ -22,6 +22,22 @@ var __assign = (this && this.__assign) || function () {
|
|
|
22
22
|
};
|
|
23
23
|
return __assign.apply(this, arguments);
|
|
24
24
|
};
|
|
25
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
26
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
27
|
+
if (!m) return o;
|
|
28
|
+
var i = m.call(o), r, ar = [], e;
|
|
29
|
+
try {
|
|
30
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
31
|
+
}
|
|
32
|
+
catch (error) { e = { error: error }; }
|
|
33
|
+
finally {
|
|
34
|
+
try {
|
|
35
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
36
|
+
}
|
|
37
|
+
finally { if (e) throw e.error; }
|
|
38
|
+
}
|
|
39
|
+
return ar;
|
|
40
|
+
};
|
|
25
41
|
import { h, Component } from 'preact';
|
|
26
42
|
import { LogicFlowUtil } from '@logicflow/core';
|
|
27
43
|
import Rect from '../BasicShape/Rect';
|
|
@@ -273,8 +289,11 @@ var Control = /** @class */ (function (_super) {
|
|
|
273
289
|
_this.graphModel.eventCenter.emit('node:resize', { oldNodeSize: oldNodeSize, newNodeSize: newNodeSize });
|
|
274
290
|
};
|
|
275
291
|
_this.onDragging = function (_a) {
|
|
292
|
+
var _b;
|
|
276
293
|
var deltaX = _a.deltaX, deltaY = _a.deltaY;
|
|
294
|
+
var transformModel = _this.graphModel.transformModel;
|
|
277
295
|
var modelType = _this.nodeModel.modelType;
|
|
296
|
+
_b = __read(transformModel.fixDeltaXY(deltaX, deltaY), 2), deltaX = _b[0], deltaY = _b[1];
|
|
278
297
|
// html和矩形的计算方式是一样的,共用一个方法
|
|
279
298
|
if (modelType === ModelType.RECT_NODE || modelType === ModelType.HTML_NODE) {
|
|
280
299
|
_this.updateRect({ deltaX: deltaX, deltaY: deltaY });
|
|
@@ -287,23 +306,32 @@ var Control = /** @class */ (function (_super) {
|
|
|
287
306
|
_this.updateDiamond({ deltaX: deltaX, deltaY: deltaY });
|
|
288
307
|
}
|
|
289
308
|
};
|
|
309
|
+
/**
|
|
310
|
+
* 由于将拖拽放大缩小改成丝滑模式,这个时候需要在拖拽结束的时候,将节点的位置更新到grid上.
|
|
311
|
+
*/
|
|
312
|
+
_this.onDragEnd = function () {
|
|
313
|
+
var _a = _this.graphModel.gridSize, gridSize = _a === void 0 ? 1 : _a;
|
|
314
|
+
var x = gridSize * Math.round(_this.nodeModel.x / gridSize);
|
|
315
|
+
var y = gridSize * Math.round(_this.nodeModel.y / gridSize);
|
|
316
|
+
_this.nodeModel.moveTo(x, y);
|
|
317
|
+
};
|
|
290
318
|
_this.index = props.index;
|
|
291
319
|
_this.nodeModel = props.model;
|
|
292
320
|
_this.graphModel = props.graphModel;
|
|
293
|
-
var gridSize = _this.graphModel.gridSize;
|
|
294
321
|
// 为保证对齐线功能正常使用,step默认是网格grid的两倍,
|
|
295
322
|
// 没有网格设置,默认为2,保证坐标是整数
|
|
296
|
-
|
|
297
|
-
if (gridSize > 1) {
|
|
298
|
-
|
|
299
|
-
}
|
|
300
|
-
if (
|
|
301
|
-
|
|
302
|
-
}
|
|
323
|
+
// let step = 2;
|
|
324
|
+
// if (gridSize > 1) {
|
|
325
|
+
// step = 2 * gridSize;
|
|
326
|
+
// }
|
|
327
|
+
// if (this.nodeModel.gridSize) {
|
|
328
|
+
// step = 2 * this.nodeModel.gridSize;
|
|
329
|
+
// }
|
|
303
330
|
_this.state = {};
|
|
304
331
|
_this.dragHandler = new StepDrag({
|
|
305
332
|
onDragging: _this.onDragging,
|
|
306
|
-
|
|
333
|
+
onDragEnd: _this.onDragEnd,
|
|
334
|
+
step: 1,
|
|
307
335
|
});
|
|
308
336
|
return _this;
|
|
309
337
|
}
|
|
@@ -48,6 +48,9 @@ var DiamondResizeModel = /** @class */ (function (_super) {
|
|
|
48
48
|
};
|
|
49
49
|
DiamondResizeModel.prototype.getOutlineStyle = function () {
|
|
50
50
|
var style = _super.prototype.getOutlineStyle.call(this);
|
|
51
|
+
var isSilentMode = this.graphModel.editConfigModel.isSilentMode;
|
|
52
|
+
if (isSilentMode)
|
|
53
|
+
return style;
|
|
51
54
|
style.stroke = 'none';
|
|
52
55
|
if (style.hover) {
|
|
53
56
|
style.hover.stroke = 'none';
|
|
@@ -89,10 +92,10 @@ var DiamondResizeView = /** @class */ (function (_super) {
|
|
|
89
92
|
h(Polygon, __assign({}, style, { points: points }))));
|
|
90
93
|
};
|
|
91
94
|
DiamondResizeView.prototype.getShape = function () {
|
|
92
|
-
var
|
|
95
|
+
var _a = this.props, isSelected = _a.model.isSelected, isSilentMode = _a.graphModel.editConfigModel.isSilentMode;
|
|
93
96
|
return (h("g", null,
|
|
94
97
|
this.getResizeShape(),
|
|
95
|
-
isSelected ? this.getControlGroup() : ''));
|
|
98
|
+
isSelected && !isSilentMode ? this.getControlGroup() : ''));
|
|
96
99
|
};
|
|
97
100
|
return DiamondResizeView;
|
|
98
101
|
}(DiamondNode));
|
|
@@ -35,6 +35,9 @@ var EllipseResizeModel = /** @class */ (function (_super) {
|
|
|
35
35
|
};
|
|
36
36
|
EllipseResizeModel.prototype.getOutlineStyle = function () {
|
|
37
37
|
var style = _super.prototype.getOutlineStyle.call(this);
|
|
38
|
+
var isSilentMode = this.graphModel.editConfigModel.isSilentMode;
|
|
39
|
+
if (isSilentMode)
|
|
40
|
+
return style;
|
|
38
41
|
style.stroke = 'none';
|
|
39
42
|
if (style.hover) {
|
|
40
43
|
style.hover.stroke = 'none';
|
|
@@ -72,10 +75,10 @@ var EllipseResizeView = /** @class */ (function (_super) {
|
|
|
72
75
|
return _super.prototype.getShape.call(this);
|
|
73
76
|
};
|
|
74
77
|
EllipseResizeView.prototype.getShape = function () {
|
|
75
|
-
var
|
|
78
|
+
var _a = this.props, model = _a.model, isSilentMode = _a.graphModel.editConfigModel.isSilentMode;
|
|
76
79
|
return (h("g", null,
|
|
77
80
|
this.getResizeShape(),
|
|
78
|
-
model.isSelected ? this.getControlGroup() : ''));
|
|
81
|
+
model.isSelected && !isSilentMode ? this.getControlGroup() : ''));
|
|
79
82
|
};
|
|
80
83
|
return EllipseResizeView;
|
|
81
84
|
}(EllipseNode));
|
|
@@ -35,6 +35,9 @@ var HtmlResizeModel = /** @class */ (function (_super) {
|
|
|
35
35
|
};
|
|
36
36
|
HtmlResizeModel.prototype.getOutlineStyle = function () {
|
|
37
37
|
var style = _super.prototype.getOutlineStyle.call(this);
|
|
38
|
+
var isSilentMode = this.graphModel.editConfigModel.isSilentMode;
|
|
39
|
+
if (isSilentMode)
|
|
40
|
+
return style;
|
|
38
41
|
style.stroke = 'none';
|
|
39
42
|
if (style.hover) {
|
|
40
43
|
style.hover.stroke = 'none';
|
|
@@ -72,10 +75,10 @@ var HtmlResizeView = /** @class */ (function (_super) {
|
|
|
72
75
|
return _super.prototype.getShape.call(this);
|
|
73
76
|
};
|
|
74
77
|
HtmlResizeView.prototype.getShape = function () {
|
|
75
|
-
var
|
|
78
|
+
var _a = this.props, isSelected = _a.model.isSelected, isSilentMode = _a.graphModel.editConfigModel.isSilentMode;
|
|
76
79
|
return (h("g", null,
|
|
77
80
|
this.getResizeShape(),
|
|
78
|
-
isSelected ? this.getControlGroup() : ''));
|
|
81
|
+
isSelected && !isSilentMode ? this.getControlGroup() : ''));
|
|
79
82
|
};
|
|
80
83
|
return HtmlResizeView;
|
|
81
84
|
}(HtmlNode));
|
|
@@ -35,6 +35,9 @@ var RectResizeModel = /** @class */ (function (_super) {
|
|
|
35
35
|
};
|
|
36
36
|
RectResizeModel.prototype.getOutlineStyle = function () {
|
|
37
37
|
var style = _super.prototype.getOutlineStyle.call(this);
|
|
38
|
+
var isSilentMode = this.graphModel.editConfigModel.isSilentMode;
|
|
39
|
+
if (isSilentMode)
|
|
40
|
+
return style;
|
|
38
41
|
style.stroke = 'none';
|
|
39
42
|
if (style.hover) {
|
|
40
43
|
style.hover.stroke = 'none';
|
|
@@ -76,10 +79,10 @@ var RectResizeView = /** @class */ (function (_super) {
|
|
|
76
79
|
return _super.prototype.getShape.call(this);
|
|
77
80
|
};
|
|
78
81
|
RectResizeView.prototype.getShape = function () {
|
|
79
|
-
var
|
|
82
|
+
var _a = this.props, isSelected = _a.model.isSelected, isSilentMode = _a.graphModel.editConfigModel.isSilentMode;
|
|
80
83
|
return (h("g", null,
|
|
81
84
|
this.getResizeShape(),
|
|
82
|
-
isSelected ? this.getControlGroup() : ''));
|
|
85
|
+
isSelected && !isSilentMode ? this.getControlGroup() : ''));
|
|
83
86
|
};
|
|
84
87
|
return RectResizeView;
|
|
85
88
|
}(RectNode));
|
|
@@ -61,12 +61,17 @@ var MiniMap = /** @class */ (function () {
|
|
|
61
61
|
y: e.y,
|
|
62
62
|
};
|
|
63
63
|
};
|
|
64
|
-
this.
|
|
64
|
+
this.moveViewport = function (top, left) {
|
|
65
65
|
var viewStyle = _this.__viewport.style;
|
|
66
|
-
_this.__viewPortTop
|
|
67
|
-
_this.__viewPortLeft
|
|
66
|
+
_this.__viewPortTop = top;
|
|
67
|
+
_this.__viewPortLeft = left;
|
|
68
68
|
viewStyle.top = _this.__viewPortTop + "px";
|
|
69
69
|
viewStyle.left = _this.__viewPortLeft + "px";
|
|
70
|
+
};
|
|
71
|
+
this.__drag = function (e) {
|
|
72
|
+
var top = _this.__viewPortTop + e.y - _this.__startPosition.y;
|
|
73
|
+
var left = _this.__viewPortLeft + e.x - _this.__startPosition.x;
|
|
74
|
+
_this.moveViewport(top, left);
|
|
70
75
|
_this.__startPosition = {
|
|
71
76
|
x: e.x,
|
|
72
77
|
y: e.y,
|
|
@@ -85,6 +90,21 @@ var MiniMap = /** @class */ (function () {
|
|
|
85
90
|
this.__drop = function () {
|
|
86
91
|
document.removeEventListener('mousemove', _this.__drag);
|
|
87
92
|
document.removeEventListener('mouseup', _this.__drop);
|
|
93
|
+
var top = _this.__viewPortTop;
|
|
94
|
+
var left = _this.__viewPortLeft;
|
|
95
|
+
if (_this.__viewPortLeft > _this.__width) {
|
|
96
|
+
left = _this.__width - _this.__viewPortWidth;
|
|
97
|
+
}
|
|
98
|
+
if (_this.__viewPortTop > _this.__height) {
|
|
99
|
+
top = _this.__height - _this.__viewPortHeight;
|
|
100
|
+
}
|
|
101
|
+
if (_this.__viewPortLeft < -_this.__width) {
|
|
102
|
+
left = 0;
|
|
103
|
+
}
|
|
104
|
+
if (_this.__viewPortTop < -_this.__height) {
|
|
105
|
+
top = 0;
|
|
106
|
+
}
|
|
107
|
+
_this.moveViewport(top, left);
|
|
88
108
|
};
|
|
89
109
|
this.__lf = lf;
|
|
90
110
|
this.__miniMapWidth = lf.graphModel.width;
|
|
@@ -308,7 +328,7 @@ var MiniMap = /** @class */ (function () {
|
|
|
308
328
|
var graphRatio = (this.__lf.graphModel.width / this.__lf.graphModel.height);
|
|
309
329
|
var realViewPortHeight = realViewPortWidth / graphRatio;
|
|
310
330
|
this.__viewPortTop = TRANSLATE_Y > 0 ? 0 : -TRANSLATE_Y * scale;
|
|
311
|
-
this.__viewPortLeft = -TRANSLATE_X * scale;
|
|
331
|
+
this.__viewPortLeft = TRANSLATE_X > 0 ? 0 : -TRANSLATE_X * scale;
|
|
312
332
|
this.__viewPortWidth = realViewPortWidth;
|
|
313
333
|
this.__viewPortHeight = realViewPortHeight;
|
|
314
334
|
viewStyle.top = this.__viewPortTop + "px";
|
|
@@ -31,6 +31,7 @@ var SelectionSelect = /** @class */ (function () {
|
|
|
31
31
|
this.__drawOff = function () {
|
|
32
32
|
document.removeEventListener('mousemove', _this.__draw);
|
|
33
33
|
document.removeEventListener('mouseup', _this.__drawOff);
|
|
34
|
+
_this.wrapper.oncontextmenu = null;
|
|
34
35
|
_this.__domContainer.removeChild(_this.wrapper);
|
|
35
36
|
var _a = _this.startPoint, x = _a.x, y = _a.y;
|
|
36
37
|
var _b = _this.endPoint, x1 = _b.x, y1 = _b.y;
|
|
@@ -40,8 +41,10 @@ var SelectionSelect = /** @class */ (function () {
|
|
|
40
41
|
}
|
|
41
42
|
var lt = [Math.min(x, x1), Math.min(y, y1)];
|
|
42
43
|
var rt = [Math.max(x, x1), Math.max(y, y1)];
|
|
43
|
-
var elements = _this.lf.graphModel.getAreaElement(lt, rt, _this.isWholeEdge, _this.isWholeNode);
|
|
44
|
+
var elements = _this.lf.graphModel.getAreaElement(lt, rt, _this.isWholeEdge, _this.isWholeNode, true);
|
|
45
|
+
var group = _this.lf.graphModel.group;
|
|
44
46
|
elements.forEach(function (element) {
|
|
47
|
+
// 如果节点属于分组,则不不选中节点
|
|
45
48
|
if (_this.isSelectElement(element)) {
|
|
46
49
|
_this.lf.selectElementById(element.id, true);
|
|
47
50
|
}
|
|
@@ -74,6 +77,9 @@ var SelectionSelect = /** @class */ (function () {
|
|
|
74
77
|
_this.endPoint = { x: x, y: y };
|
|
75
78
|
var wrapper = document.createElement('div');
|
|
76
79
|
wrapper.className = 'lf-selection-select';
|
|
80
|
+
wrapper.oncontextmenu = function prevent(ev) {
|
|
81
|
+
ev.preventDefault();
|
|
82
|
+
};
|
|
77
83
|
wrapper.style.top = _this.startPoint.y + "px";
|
|
78
84
|
wrapper.style.left = _this.startPoint.x + "px";
|
|
79
85
|
domContainer.appendChild(wrapper);
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { PolylineEdge, PolylineEdgeModel } from '@logicflow/core';
|
|
2
|
+
declare class CurvedEdge extends PolylineEdge {
|
|
3
|
+
pointFilter(points: any): any;
|
|
4
|
+
getEdge(): import("preact").VNode<any>;
|
|
4
5
|
}
|
|
5
|
-
declare
|
|
6
|
-
|
|
7
|
-
export { CurvedEdge, };
|
|
6
|
+
declare class CurvedEdgeModel extends PolylineEdgeModel {
|
|
7
|
+
}
|
|
8
|
+
export { CurvedEdge, CurvedEdgeModel, };
|
|
@@ -11,6 +11,17 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
11
11
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
12
12
|
};
|
|
13
13
|
})();
|
|
14
|
+
var __assign = (this && this.__assign) || function () {
|
|
15
|
+
__assign = Object.assign || function(t) {
|
|
16
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
17
|
+
s = arguments[i];
|
|
18
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
19
|
+
t[p] = s[p];
|
|
20
|
+
}
|
|
21
|
+
return t;
|
|
22
|
+
};
|
|
23
|
+
return __assign.apply(this, arguments);
|
|
24
|
+
};
|
|
14
25
|
var __read = (this && this.__read) || function (o, n) {
|
|
15
26
|
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
16
27
|
if (!m) return o;
|
|
@@ -28,15 +39,34 @@ var __read = (this && this.__read) || function (o, n) {
|
|
|
28
39
|
return ar;
|
|
29
40
|
};
|
|
30
41
|
import { PolylineEdge, PolylineEdgeModel, h } from '@logicflow/core';
|
|
31
|
-
var
|
|
32
|
-
__extends(
|
|
33
|
-
function
|
|
42
|
+
var CurvedEdge = /** @class */ (function (_super) {
|
|
43
|
+
__extends(CurvedEdge, _super);
|
|
44
|
+
function CurvedEdge() {
|
|
34
45
|
return _super !== null && _super.apply(this, arguments) || this;
|
|
35
46
|
}
|
|
36
|
-
|
|
37
|
-
var
|
|
38
|
-
var
|
|
39
|
-
|
|
47
|
+
CurvedEdge.prototype.pointFilter = function (points) {
|
|
48
|
+
var allPoints = points;
|
|
49
|
+
var i = 1;
|
|
50
|
+
while (i < allPoints.length - 1) {
|
|
51
|
+
var _a = __read(allPoints[i - 1], 2), x = _a[0], y = _a[1];
|
|
52
|
+
var _b = __read(allPoints[i], 2), x1 = _b[0], y1 = _b[1];
|
|
53
|
+
var _c = __read(allPoints[i + 1], 2), x2 = _c[0], y2 = _c[1];
|
|
54
|
+
if ((x === x1 && x1 === x2)
|
|
55
|
+
|| (y === y1 && y1 === y2)) {
|
|
56
|
+
allPoints.splice(i, 1);
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
i++;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return allPoints;
|
|
63
|
+
};
|
|
64
|
+
CurvedEdge.prototype.getEdge = function () {
|
|
65
|
+
var model = this.props.model;
|
|
66
|
+
var points = model.points, isAnimation = model.isAnimation, arrowConfig = model.arrowConfig, _a = model.radius, radius = _a === void 0 ? 5 : _a;
|
|
67
|
+
var style = model.getEdgeStyle();
|
|
68
|
+
var animationStyle = model.getEdgeAnimationStyle();
|
|
69
|
+
var points2 = this.pointFilter(points.split(' ').map(function (p) { return p.split(',').map(function (a) { return Number(a); }); }));
|
|
40
70
|
var _b = __read(points2[0], 2), startX = _b[0], startY = _b[1];
|
|
41
71
|
var d = "M" + startX + " " + startY;
|
|
42
72
|
// 1) 如果一个点不为开始和结束,则在这个点的前后增加弧度开始和结束点。
|
|
@@ -44,42 +74,34 @@ var CurvedEdgeView = /** @class */ (function (_super) {
|
|
|
44
74
|
// 如果x相同则前一个点的x也不变,
|
|
45
75
|
// y为(这个点的y 大于前一个点的y, 则 为 这个点的y - 5;小于前一个点的y, 则为这个点的y+5)
|
|
46
76
|
// 同理,判断这个点与后一个点的x,y是否相同,如果x相同,则y进行加减,如果y相同,则x进行加减
|
|
47
|
-
// todo: 好丑,看看怎么优化下
|
|
48
|
-
var space = 5;
|
|
49
77
|
for (var i = 1; i < points2.length - 1; i++) {
|
|
50
78
|
var _c = __read(points2[i - 1], 2), preX = _c[0], preY = _c[1];
|
|
51
79
|
var _d = __read(points2[i], 2), currentX = _d[0], currentY = _d[1];
|
|
52
80
|
var _e = __read(points2[i + 1], 2), nextX = _e[0], nextY = _e[1];
|
|
53
81
|
if (currentX === preX && currentY !== preY) {
|
|
54
|
-
var y = currentY > preY ? currentY -
|
|
82
|
+
var y = currentY > preY ? currentY - radius : currentY + radius;
|
|
55
83
|
d = d + " L " + currentX + " " + y;
|
|
56
84
|
}
|
|
57
85
|
if (currentY === preY && currentX !== preX) {
|
|
58
|
-
var x = currentX > preX ? currentX -
|
|
86
|
+
var x = currentX > preX ? currentX - radius : currentX + radius;
|
|
59
87
|
d = d + " L " + x + " " + currentY;
|
|
60
88
|
}
|
|
61
89
|
d = d + " Q " + currentX + " " + currentY;
|
|
62
90
|
if (currentX === nextX && currentY !== nextY) {
|
|
63
|
-
var y = currentY > nextY ? currentY -
|
|
91
|
+
var y = currentY > nextY ? currentY - radius : currentY + radius;
|
|
64
92
|
d = d + " " + currentX + " " + y;
|
|
65
93
|
}
|
|
66
94
|
if (currentY === nextY && currentX !== nextX) {
|
|
67
|
-
var x = currentX > nextX ? currentX -
|
|
95
|
+
var x = currentX > nextX ? currentX - radius : currentX + radius;
|
|
68
96
|
d = d + " " + x + " " + currentY;
|
|
69
97
|
}
|
|
70
98
|
}
|
|
71
99
|
var _f = __read(points2[points2.length - 1], 2), endX = _f[0], endY = _f[1];
|
|
72
100
|
d = d + " L " + endX + " " + endY;
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
strokeWidth: strokeWidth,
|
|
76
|
-
stroke: stroke,
|
|
77
|
-
fill: 'none',
|
|
78
|
-
strokeDashArray: strokeDashArray,
|
|
79
|
-
});
|
|
101
|
+
var attrs = __assign(__assign(__assign({ d: d, style: isAnimation ? animationStyle : {} }, style), arrowConfig), { fill: 'none' });
|
|
102
|
+
return h('path', __assign({ d: d }, attrs));
|
|
80
103
|
};
|
|
81
|
-
|
|
82
|
-
return CurvedEdgeView;
|
|
104
|
+
return CurvedEdge;
|
|
83
105
|
}(PolylineEdge));
|
|
84
106
|
var CurvedEdgeModel = /** @class */ (function (_super) {
|
|
85
107
|
__extends(CurvedEdgeModel, _super);
|
|
@@ -88,20 +110,6 @@ var CurvedEdgeModel = /** @class */ (function (_super) {
|
|
|
88
110
|
}
|
|
89
111
|
return CurvedEdgeModel;
|
|
90
112
|
}(PolylineEdgeModel));
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
init: function (_a) {
|
|
95
|
-
var curvedSpace = _a.curvedSpace;
|
|
96
|
-
CurvedEdge.curvedSpace = curvedSpace;
|
|
97
|
-
},
|
|
98
|
-
install: function (lf) {
|
|
99
|
-
lf.register({
|
|
100
|
-
type: 'curved-edge',
|
|
101
|
-
view: CurvedEdgeView,
|
|
102
|
-
model: CurvedEdgeModel,
|
|
103
|
-
});
|
|
104
|
-
},
|
|
105
|
-
};
|
|
106
|
-
export default CurvedEdge;
|
|
107
|
-
export { CurvedEdge, };
|
|
113
|
+
export { CurvedEdge,
|
|
114
|
+
// CurvedEdgeView,
|
|
115
|
+
CurvedEdgeModel, };
|
|
@@ -47,6 +47,8 @@ declare class GroupNodeModel extends RectResize.model {
|
|
|
47
47
|
*/
|
|
48
48
|
foldGroup(isFolded: any): void;
|
|
49
49
|
getAnchorStyle(anchorInfo: any): Record<string, any>;
|
|
50
|
+
foldRect(isFolded: any): void;
|
|
51
|
+
foldChildren(isFolded: any): import("@logicflow/core/types/model/edge/BaseEdgeModel").BaseEdgeModel[];
|
|
50
52
|
/**
|
|
51
53
|
* 折叠分组的时候,处理分组自身的连线和分组内部子节点上的连线
|
|
52
54
|
* 边的分类:
|
|
@@ -90,6 +92,10 @@ declare class GroupNodeModel extends RectResize.model {
|
|
|
90
92
|
* @param id 节点id
|
|
91
93
|
*/
|
|
92
94
|
removeChild(id: any): void;
|
|
95
|
+
/**
|
|
96
|
+
* 获得包含嵌套组的所有子节点
|
|
97
|
+
*/
|
|
98
|
+
getChildren(): any[];
|
|
93
99
|
getAddableOutlineStyle(): {
|
|
94
100
|
stroke: string;
|
|
95
101
|
strokeWidth: number;
|
|
@@ -98,6 +104,10 @@ declare class GroupNodeModel extends RectResize.model {
|
|
|
98
104
|
};
|
|
99
105
|
getData(): import("@logicflow/core").NodeData;
|
|
100
106
|
getHistoryData(): import("@logicflow/core").NodeData;
|
|
107
|
+
/**
|
|
108
|
+
* 是否允许此节点添加到此分组中
|
|
109
|
+
*/
|
|
110
|
+
isAllowAppendIn(nodeData: any): boolean;
|
|
101
111
|
}
|
|
102
112
|
declare class GroupNode extends RectResize.view {
|
|
103
113
|
getControlGroup(): h.JSX.Element;
|
|
@@ -77,6 +77,8 @@ var GroupNodeModel = /** @class */ (function (_super) {
|
|
|
77
77
|
this.resizable = false;
|
|
78
78
|
this.autoToFront = false;
|
|
79
79
|
this.foldable = false;
|
|
80
|
+
// 是否可以被嵌套
|
|
81
|
+
this.nestable = false;
|
|
80
82
|
if (this.properties.isFolded === undefined) {
|
|
81
83
|
this.properties.isFolded = false;
|
|
82
84
|
}
|
|
@@ -100,10 +102,24 @@ var GroupNodeModel = /** @class */ (function (_super) {
|
|
|
100
102
|
* 3. 处理连线
|
|
101
103
|
*/
|
|
102
104
|
GroupNodeModel.prototype.foldGroup = function (isFolded) {
|
|
103
|
-
var _this = this;
|
|
104
105
|
this.setProperty('isFolded', isFolded);
|
|
105
106
|
this.isFolded = isFolded;
|
|
106
107
|
// step 1
|
|
108
|
+
this.foldRect(isFolded);
|
|
109
|
+
// step 2
|
|
110
|
+
var allEdges = this.foldChildren(isFolded);
|
|
111
|
+
// step 3
|
|
112
|
+
this.foldEdge(isFolded, allEdges);
|
|
113
|
+
};
|
|
114
|
+
GroupNodeModel.prototype.getAnchorStyle = function (anchorInfo) {
|
|
115
|
+
var style = _super.prototype.getAnchorStyle.call(this, anchorInfo);
|
|
116
|
+
style.stroke = 'transparent';
|
|
117
|
+
style.fill = 'transparent';
|
|
118
|
+
style.hover.fill = 'transparent';
|
|
119
|
+
style.hover.stroke = 'transparent';
|
|
120
|
+
return style;
|
|
121
|
+
};
|
|
122
|
+
GroupNodeModel.prototype.foldRect = function (isFolded) {
|
|
107
123
|
if (isFolded) {
|
|
108
124
|
this.unfoldedWidth = this.width;
|
|
109
125
|
this.unfoldedHight = this.height;
|
|
@@ -122,25 +138,23 @@ var GroupNodeModel = /** @class */ (function (_super) {
|
|
|
122
138
|
y: this.y + this.unfoldedHight / 2 - this.foldedHeight / 2,
|
|
123
139
|
});
|
|
124
140
|
}
|
|
125
|
-
|
|
141
|
+
};
|
|
142
|
+
GroupNodeModel.prototype.foldChildren = function (isFolded) {
|
|
143
|
+
var _this = this;
|
|
126
144
|
var allEdges = this.incoming.edges.concat(this.outgoing.edges);
|
|
127
145
|
this.children.forEach(function (elementId) {
|
|
128
146
|
var nodeModel = _this.graphModel.getElement(elementId);
|
|
147
|
+
if (nodeModel.isGroup) {
|
|
148
|
+
var childEdges = nodeModel.foldChildren(isFolded || nodeModel.isFolded);
|
|
149
|
+
allEdges = allEdges.concat(childEdges);
|
|
150
|
+
nodeModel.foldEdge(isFolded, childEdges);
|
|
151
|
+
}
|
|
152
|
+
allEdges = allEdges.concat(nodeModel.incoming.edges.concat(nodeModel.outgoing.edges));
|
|
129
153
|
nodeModel.updateAttributes({
|
|
130
154
|
visible: !isFolded,
|
|
131
155
|
});
|
|
132
|
-
allEdges = allEdges.concat(nodeModel.incoming.edges.concat(nodeModel.outgoing.edges));
|
|
133
156
|
});
|
|
134
|
-
|
|
135
|
-
this.foldEdge(isFolded, allEdges);
|
|
136
|
-
};
|
|
137
|
-
GroupNodeModel.prototype.getAnchorStyle = function (anchorInfo) {
|
|
138
|
-
var style = _super.prototype.getAnchorStyle.call(this, anchorInfo);
|
|
139
|
-
style.stroke = 'transparent';
|
|
140
|
-
style.fill = 'transparent';
|
|
141
|
-
style.hover.fill = 'transparent';
|
|
142
|
-
style.hover.stroke = 'transparent';
|
|
143
|
-
return style;
|
|
157
|
+
return allEdges;
|
|
144
158
|
};
|
|
145
159
|
/**
|
|
146
160
|
* 折叠分组的时候,处理分组自身的连线和分组内部子节点上的连线
|
|
@@ -265,6 +279,19 @@ var GroupNodeModel = /** @class */ (function (_super) {
|
|
|
265
279
|
GroupNodeModel.prototype.removeChild = function (id) {
|
|
266
280
|
this.children.delete(id);
|
|
267
281
|
};
|
|
282
|
+
/**
|
|
283
|
+
* 获得包含嵌套组的所有子节点
|
|
284
|
+
*/
|
|
285
|
+
GroupNodeModel.prototype.getChildren = function () {
|
|
286
|
+
var _this = this;
|
|
287
|
+
return __spread(this.children).flatMap(function (child) {
|
|
288
|
+
var model = _this.graphModel.getElement(child);
|
|
289
|
+
if (model.isGroup) {
|
|
290
|
+
return __spread([child], model.getChildren());
|
|
291
|
+
}
|
|
292
|
+
return child;
|
|
293
|
+
});
|
|
294
|
+
};
|
|
268
295
|
GroupNodeModel.prototype.getAddableOutlineStyle = function () {
|
|
269
296
|
return {
|
|
270
297
|
stroke: '#FEB663',
|
|
@@ -292,6 +319,12 @@ var GroupNodeModel = /** @class */ (function (_super) {
|
|
|
292
319
|
}
|
|
293
320
|
return data;
|
|
294
321
|
};
|
|
322
|
+
/**
|
|
323
|
+
* 是否允许此节点添加到此分组中
|
|
324
|
+
*/
|
|
325
|
+
GroupNodeModel.prototype.isAllowAppendIn = function (nodeData) {
|
|
326
|
+
return true;
|
|
327
|
+
};
|
|
295
328
|
return GroupNodeModel;
|
|
296
329
|
}(RectResize.model));
|
|
297
330
|
var GroupNode = /** @class */ (function (_super) {
|
|
@@ -2,12 +2,6 @@ import LogicFlow, { BaseNodeModel } from '@logicflow/core';
|
|
|
2
2
|
import GroupNode from './GroupNode';
|
|
3
3
|
declare type BaseNodeId = string;
|
|
4
4
|
declare type GroupId = string;
|
|
5
|
-
declare type Bounds = {
|
|
6
|
-
x1: number;
|
|
7
|
-
y1: number;
|
|
8
|
-
x2: number;
|
|
9
|
-
y2: number;
|
|
10
|
-
};
|
|
11
5
|
declare class Group {
|
|
12
6
|
static pluginName: string;
|
|
13
7
|
lf: LogicFlow;
|
|
@@ -16,6 +10,10 @@ declare class Group {
|
|
|
16
10
|
constructor({ lf }: {
|
|
17
11
|
lf: any;
|
|
18
12
|
});
|
|
13
|
+
/**
|
|
14
|
+
* 获取一个节点内部所有的子节点,包裹分组的子节点
|
|
15
|
+
*/
|
|
16
|
+
getNodeAllChild(model: any): any[];
|
|
19
17
|
graphRendered: (data: any) => void;
|
|
20
18
|
appendNodeToGroup: ({ data }: {
|
|
21
19
|
data: any;
|
|
@@ -29,7 +27,7 @@ declare class Group {
|
|
|
29
27
|
/**
|
|
30
28
|
* 获取自定位置其所属分组
|
|
31
29
|
*/
|
|
32
|
-
getGroup(
|
|
30
|
+
getGroup(nodeModel: BaseNodeModel): BaseNodeModel | undefined;
|
|
33
31
|
/**
|
|
34
32
|
* 获取某个节点所属的groupModel
|
|
35
33
|
*/
|