@logicflow/extension 1.1.0-alpha.3 → 1.1.0-alpha.7
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 +9 -9
- package/cjs/NodeResize/Control/ControlGroup.js +8 -4
- package/cjs/NodeResize/Node/DiamondResize.js +21 -1
- package/cjs/NodeResize/Node/EllipseResize.js +15 -0
- package/cjs/NodeResize/Node/HtmlResize.js +15 -0
- package/cjs/NodeResize/Node/RectResize.js +19 -0
- package/cjs/NodeResize/index.js +2 -36
- package/cjs/materials/group/GroupNode.js +137 -7
- package/cjs/materials/group/index.js +1 -1
- package/cjs/tools/snapshot/index.js +7 -2
- package/es/NodeResize/Control/Control.js +9 -9
- package/es/NodeResize/Control/ControlGroup.js +8 -4
- package/es/NodeResize/Node/DiamondResize.d.ts +15 -0
- package/es/NodeResize/Node/DiamondResize.js +21 -1
- package/es/NodeResize/Node/EllipseResize.d.ts +11 -0
- package/es/NodeResize/Node/EllipseResize.js +15 -0
- package/es/NodeResize/Node/HtmlResize.d.ts +11 -0
- package/es/NodeResize/Node/HtmlResize.js +15 -0
- package/es/NodeResize/Node/RectResize.d.ts +13 -0
- package/es/NodeResize/Node/RectResize.js +19 -0
- package/es/NodeResize/index.d.ts +2 -28
- package/es/NodeResize/index.js +1 -36
- package/es/materials/group/GroupNode.d.ts +21 -4
- package/es/materials/group/GroupNode.js +137 -7
- package/es/materials/group/index.js +1 -1
- package/es/tools/snapshot/index.js +7 -2
- 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/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/Node/DiamondResize.d.ts +15 -0
- package/types/NodeResize/Node/EllipseResize.d.ts +11 -0
- package/types/NodeResize/Node/HtmlResize.d.ts +11 -0
- package/types/NodeResize/Node/RectResize.d.ts +13 -0
- package/types/NodeResize/index.d.ts +2 -28
- package/types/group-shrink/index.d.ts +28 -0
- package/types/materials/group/GroupNode.d.ts +21 -4
|
@@ -28,7 +28,6 @@ var preact_1 = require("preact");
|
|
|
28
28
|
var core_1 = require("@logicflow/core");
|
|
29
29
|
var Rect_1 = require("../BasicShape/Rect");
|
|
30
30
|
var Util_1 = require("./Util");
|
|
31
|
-
var index_1 = require("../index");
|
|
32
31
|
var createDrag = core_1.LogicFlowUtil.createDrag;
|
|
33
32
|
var Control = /** @class */ (function (_super) {
|
|
34
33
|
__extends(Control, _super);
|
|
@@ -213,11 +212,11 @@ var Control = /** @class */ (function (_super) {
|
|
|
213
212
|
pct: 1 / 2,
|
|
214
213
|
});
|
|
215
214
|
// 限制放大缩小的最大最小范围
|
|
216
|
-
var _c =
|
|
217
|
-
if (size.width <
|
|
218
|
-
|| size.width >
|
|
219
|
-
|| size.height <
|
|
220
|
-
|| size.height >
|
|
215
|
+
var _c = _this.nodeModel, minWidth = _c.minWidth, minHeight = _c.minHeight, maxWidth = _c.maxWidth, maxHeight = _c.maxHeight;
|
|
216
|
+
if (size.width < (minWidth / 2)
|
|
217
|
+
|| size.width > (maxWidth / 2)
|
|
218
|
+
|| size.height < (minHeight / 2)
|
|
219
|
+
|| size.height > (maxHeight / 2)) {
|
|
221
220
|
return;
|
|
222
221
|
}
|
|
223
222
|
// 更新中心点位置,更新文案位置
|
|
@@ -273,6 +272,7 @@ var Control = /** @class */ (function (_super) {
|
|
|
273
272
|
// html和矩形的计算方式是一样的,共用一个方法
|
|
274
273
|
if (modelType === Util_1.ModelType.RECT_NODE || modelType === Util_1.ModelType.HTML_NODE) {
|
|
275
274
|
_this.updateRect({ deltaX: deltaX, deltaY: deltaY });
|
|
275
|
+
// this.nodeModel.resize(deltaX, deltaY);
|
|
276
276
|
}
|
|
277
277
|
else if (modelType === Util_1.ModelType.ELLIPSE_NODE) {
|
|
278
278
|
_this.updateEllipse({ deltaX: deltaX, deltaY: deltaY });
|
|
@@ -315,10 +315,10 @@ var Control = /** @class */ (function (_super) {
|
|
|
315
315
|
return { sourceEdges: sourceEdges, targetEdges: targetEdges };
|
|
316
316
|
};
|
|
317
317
|
Control.prototype.render = function () {
|
|
318
|
-
var _a = this.props, x = _a.x, y = _a.y,
|
|
319
|
-
var
|
|
318
|
+
var _a = this.props, x = _a.x, y = _a.y, index = _a.index, model = _a.model;
|
|
319
|
+
var style = model.getControlPointStyle();
|
|
320
320
|
return (preact_1.h("g", { className: "lf-resize-control-" + index },
|
|
321
|
-
preact_1.h(Rect_1.default, __assign({ className: "lf-node-control" }, { x: x, y: y }, style, {
|
|
321
|
+
preact_1.h(Rect_1.default, __assign({ className: "lf-node-control" }, { x: x, y: y }, style, { onMouseDown: this.dragHandler }))));
|
|
322
322
|
};
|
|
323
323
|
return Control;
|
|
324
324
|
}(preact_1.Component));
|
|
@@ -27,7 +27,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
27
27
|
var preact_1 = require("preact");
|
|
28
28
|
var Control_1 = require("./Control");
|
|
29
29
|
var Rect_1 = require("../BasicShape/Rect");
|
|
30
|
-
var index_1 = require("../index");
|
|
31
30
|
var ControlGroup = /** @class */ (function (_super) {
|
|
32
31
|
__extends(ControlGroup, _super);
|
|
33
32
|
function ControlGroup() {
|
|
@@ -46,18 +45,22 @@ var ControlGroup = /** @class */ (function (_super) {
|
|
|
46
45
|
};
|
|
47
46
|
var minX = box.minX, minY = box.minY, maxX = box.maxX, maxY = box.maxY;
|
|
48
47
|
var controlList = [
|
|
48
|
+
// 左上角
|
|
49
49
|
{
|
|
50
50
|
x: minX,
|
|
51
51
|
y: minY,
|
|
52
52
|
},
|
|
53
|
+
// 右上角
|
|
53
54
|
{
|
|
54
55
|
x: maxX,
|
|
55
56
|
y: minY,
|
|
56
57
|
},
|
|
58
|
+
// 右下角
|
|
57
59
|
{
|
|
58
60
|
x: maxX,
|
|
59
61
|
y: maxY,
|
|
60
62
|
},
|
|
63
|
+
// 左下角
|
|
61
64
|
{
|
|
62
65
|
x: minX,
|
|
63
66
|
y: maxY,
|
|
@@ -67,9 +70,10 @@ var ControlGroup = /** @class */ (function (_super) {
|
|
|
67
70
|
};
|
|
68
71
|
// 一般节点被选中了会有outline, 先不用这个
|
|
69
72
|
ControlGroup.prototype.getGroupSolid = function () {
|
|
70
|
-
var
|
|
71
|
-
var
|
|
72
|
-
|
|
73
|
+
var model = this.props.model;
|
|
74
|
+
var x = model.x, y = model.y, width = model.width, height = model.height;
|
|
75
|
+
var style = model.getResizeOutlineStyle();
|
|
76
|
+
return (preact_1.h(Rect_1.default, __assign({ fill: "none" }, style, { x: x, y: y, width: width, height: height })));
|
|
73
77
|
};
|
|
74
78
|
ControlGroup.prototype.render = function () {
|
|
75
79
|
return (preact_1.h("g", { className: "lf-resize-control" },
|
|
@@ -30,7 +30,12 @@ var Polygon_1 = require("../BasicShape/Polygon");
|
|
|
30
30
|
var DiamondResizeModel = /** @class */ (function (_super) {
|
|
31
31
|
__extends(DiamondResizeModel, _super);
|
|
32
32
|
function DiamondResizeModel() {
|
|
33
|
-
|
|
33
|
+
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
34
|
+
_this.minWidth = 30;
|
|
35
|
+
_this.minHeight = 30;
|
|
36
|
+
_this.maxWidth = 2000;
|
|
37
|
+
_this.maxHeight = 2000;
|
|
38
|
+
return _this;
|
|
34
39
|
}
|
|
35
40
|
DiamondResizeModel.prototype.getOutlineStyle = function () {
|
|
36
41
|
var style = _super.prototype.getOutlineStyle.call(this);
|
|
@@ -40,6 +45,21 @@ var DiamondResizeModel = /** @class */ (function (_super) {
|
|
|
40
45
|
}
|
|
41
46
|
return style;
|
|
42
47
|
};
|
|
48
|
+
DiamondResizeModel.prototype.getResizeOutlineStyle = function () {
|
|
49
|
+
return {
|
|
50
|
+
stroke: '#000000',
|
|
51
|
+
strokeWidth: 1,
|
|
52
|
+
strokeDasharray: '3,3',
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
DiamondResizeModel.prototype.getControlPointStyle = function () {
|
|
56
|
+
return {
|
|
57
|
+
width: 7,
|
|
58
|
+
height: 7,
|
|
59
|
+
fill: '#FFFFFF',
|
|
60
|
+
stroke: '#000000',
|
|
61
|
+
};
|
|
62
|
+
};
|
|
43
63
|
DiamondResizeModel.prototype.setAttributes = function () {
|
|
44
64
|
// @ts-ignore
|
|
45
65
|
var nodeSize = this.properties.nodeSize;
|
|
@@ -35,6 +35,21 @@ var EllipseResizeModel = /** @class */ (function (_super) {
|
|
|
35
35
|
}
|
|
36
36
|
return style;
|
|
37
37
|
};
|
|
38
|
+
EllipseResizeModel.prototype.getResizeOutlineStyle = function () {
|
|
39
|
+
return {
|
|
40
|
+
stroke: '#000000',
|
|
41
|
+
strokeWidth: 1,
|
|
42
|
+
strokeDasharray: '3,3',
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
EllipseResizeModel.prototype.getControlPointStyle = function () {
|
|
46
|
+
return {
|
|
47
|
+
width: 7,
|
|
48
|
+
height: 7,
|
|
49
|
+
fill: '#FFFFFF',
|
|
50
|
+
stroke: '#000000',
|
|
51
|
+
};
|
|
52
|
+
};
|
|
38
53
|
EllipseResizeModel.prototype.setAttributes = function () {
|
|
39
54
|
// @ts-ignore
|
|
40
55
|
var nodeSize = this.properties.nodeSize;
|
|
@@ -33,6 +33,21 @@ var HtmlResizeModel = /** @class */ (function (_super) {
|
|
|
33
33
|
}
|
|
34
34
|
return style;
|
|
35
35
|
};
|
|
36
|
+
HtmlResizeModel.prototype.getResizeOutlineStyle = function () {
|
|
37
|
+
return {
|
|
38
|
+
stroke: '#000000',
|
|
39
|
+
strokeWidth: 1,
|
|
40
|
+
strokeDasharray: '3,3',
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
HtmlResizeModel.prototype.getControlPointStyle = function () {
|
|
44
|
+
return {
|
|
45
|
+
width: 7,
|
|
46
|
+
height: 7,
|
|
47
|
+
fill: '#FFFFFF',
|
|
48
|
+
stroke: '#000000',
|
|
49
|
+
};
|
|
50
|
+
};
|
|
36
51
|
HtmlResizeModel.prototype.setAttributes = function () {
|
|
37
52
|
// @ts-ignore
|
|
38
53
|
var nodeSize = this.properties.nodeSize;
|
|
@@ -33,6 +33,22 @@ var RectResizeModel = /** @class */ (function (_super) {
|
|
|
33
33
|
}
|
|
34
34
|
return style;
|
|
35
35
|
};
|
|
36
|
+
RectResizeModel.prototype.getResizeOutlineStyle = function () {
|
|
37
|
+
return {
|
|
38
|
+
fill: 'none',
|
|
39
|
+
stroke: '#000000',
|
|
40
|
+
strokeWidth: 1,
|
|
41
|
+
strokeDasharray: '3,3',
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
RectResizeModel.prototype.getControlPointStyle = function () {
|
|
45
|
+
return {
|
|
46
|
+
width: 7,
|
|
47
|
+
height: 7,
|
|
48
|
+
fill: '#FFFFFF',
|
|
49
|
+
stroke: '#000000',
|
|
50
|
+
};
|
|
51
|
+
};
|
|
36
52
|
RectResizeModel.prototype.setAttributes = function () {
|
|
37
53
|
// @ts-ignore
|
|
38
54
|
var nodeSize = this.properties.nodeSize;
|
|
@@ -41,6 +57,9 @@ var RectResizeModel = /** @class */ (function (_super) {
|
|
|
41
57
|
this.height = nodeSize.height;
|
|
42
58
|
}
|
|
43
59
|
};
|
|
60
|
+
RectResizeModel.prototype.resize = function (deltaX, deltaY) {
|
|
61
|
+
console.log(deltaX, deltaY);
|
|
62
|
+
};
|
|
44
63
|
return RectResizeModel;
|
|
45
64
|
}(core_1.RectNodeModel));
|
|
46
65
|
var RectResizeView = /** @class */ (function (_super) {
|
package/cjs/NodeResize/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DiamondResize = exports.EllipseResize = exports.RectResize = exports.NodeResize = void 0;
|
|
3
|
+
exports.HtmlResize = exports.DiamondResize = exports.EllipseResize = exports.RectResize = exports.NodeResize = void 0;
|
|
4
4
|
var RectResize_1 = require("./Node/RectResize");
|
|
5
5
|
exports.RectResize = RectResize_1.default;
|
|
6
6
|
var EllipseResize_1 = require("./Node/EllipseResize");
|
|
@@ -8,45 +8,11 @@ exports.EllipseResize = EllipseResize_1.default;
|
|
|
8
8
|
var DiamondResize_1 = require("./Node/DiamondResize");
|
|
9
9
|
exports.DiamondResize = DiamondResize_1.default;
|
|
10
10
|
var HtmlResize_1 = require("./Node/HtmlResize");
|
|
11
|
+
exports.HtmlResize = HtmlResize_1.default;
|
|
11
12
|
var NodeResize = {
|
|
12
13
|
pluginName: 'nodeResize',
|
|
13
14
|
// 拖动step
|
|
14
15
|
step: 0,
|
|
15
|
-
// 边框和contol拖动点样式的设置
|
|
16
|
-
style: {
|
|
17
|
-
outline: {
|
|
18
|
-
stroke: '#000000',
|
|
19
|
-
strokeWidth: 1,
|
|
20
|
-
strokeDasharray: '3,3',
|
|
21
|
-
},
|
|
22
|
-
controlPoint: {
|
|
23
|
-
width: 7,
|
|
24
|
-
height: 7,
|
|
25
|
-
fill: '#FFFFFF',
|
|
26
|
-
stroke: '#000000',
|
|
27
|
-
},
|
|
28
|
-
},
|
|
29
|
-
// 缩放范围
|
|
30
|
-
sizeRange: {
|
|
31
|
-
// rect: {
|
|
32
|
-
// minWidth: 30,
|
|
33
|
-
// minHeight: 30,
|
|
34
|
-
// maxWidth: 300,
|
|
35
|
-
// maxHeight: 300,
|
|
36
|
-
// },
|
|
37
|
-
ellipse: {
|
|
38
|
-
minRx: 15,
|
|
39
|
-
minRy: 15,
|
|
40
|
-
maxRx: 150,
|
|
41
|
-
maxRy: 150,
|
|
42
|
-
},
|
|
43
|
-
diamond: {
|
|
44
|
-
minRx: 15,
|
|
45
|
-
minRy: 15,
|
|
46
|
-
maxRx: 150,
|
|
47
|
-
maxRy: 150,
|
|
48
|
-
},
|
|
49
|
-
},
|
|
50
16
|
install: function (lf) {
|
|
51
17
|
lf.register({
|
|
52
18
|
type: RectResize_1.default.type,
|
|
@@ -46,11 +46,15 @@ var __spread = (this && this.__spread) || function () {
|
|
|
46
46
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
47
47
|
var core_1 = require("@logicflow/core");
|
|
48
48
|
var NodeResize_1 = require("../../NodeResize");
|
|
49
|
+
var defaultWidth = 500;
|
|
50
|
+
var defaultHeight = 300;
|
|
49
51
|
var GroupNodeModel = /** @class */ (function (_super) {
|
|
50
52
|
__extends(GroupNodeModel, _super);
|
|
51
53
|
function GroupNodeModel() {
|
|
52
54
|
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
53
55
|
_this.isGroup = true;
|
|
56
|
+
_this.unfoldedWidth = defaultWidth;
|
|
57
|
+
_this.unfoldedHight = defaultHeight;
|
|
54
58
|
return _this;
|
|
55
59
|
}
|
|
56
60
|
GroupNodeModel.prototype.initNodeData = function (data) {
|
|
@@ -61,8 +65,10 @@ var GroupNodeModel = /** @class */ (function (_super) {
|
|
|
61
65
|
}
|
|
62
66
|
// 初始化组的子节点
|
|
63
67
|
this.children = new Set(children);
|
|
64
|
-
this.width =
|
|
65
|
-
this.height =
|
|
68
|
+
this.width = defaultWidth;
|
|
69
|
+
this.height = defaultHeight;
|
|
70
|
+
this.foldedWidth = 80;
|
|
71
|
+
this.foldedHeight = 60;
|
|
66
72
|
// todo: 参考bpmn.js, 分组和未加入分组的节点重合时,未加入分组的节点在分组之下。方便标识。
|
|
67
73
|
this.zIndex = -1;
|
|
68
74
|
this.radius = 0;
|
|
@@ -70,6 +76,97 @@ var GroupNodeModel = /** @class */ (function (_super) {
|
|
|
70
76
|
this.text.draggable = false;
|
|
71
77
|
this.isRestrict = false;
|
|
72
78
|
this.resizable = false;
|
|
79
|
+
this.autoToFront = false;
|
|
80
|
+
this.foldable = false;
|
|
81
|
+
this.properties.isFolded = false;
|
|
82
|
+
this.isFolded = this.properties.isFolded;
|
|
83
|
+
};
|
|
84
|
+
GroupNodeModel.prototype.getResizeOutlineStyle = function () {
|
|
85
|
+
var style = _super.prototype.getResizeOutlineStyle.call(this);
|
|
86
|
+
style.stroke = 'none';
|
|
87
|
+
return style;
|
|
88
|
+
};
|
|
89
|
+
GroupNodeModel.prototype.foldGroup = function (isFolded) {
|
|
90
|
+
var _this = this;
|
|
91
|
+
this.setProperty('isFolded', isFolded);
|
|
92
|
+
this.isFolded = isFolded;
|
|
93
|
+
if (isFolded) {
|
|
94
|
+
this.x = this.x - this.width / 2 + this.foldedWidth / 2;
|
|
95
|
+
this.y = this.y - this.height / 2 + this.foldedHeight / 2;
|
|
96
|
+
this.unfoldedWidth = this.width;
|
|
97
|
+
this.unfoldedHight = this.height;
|
|
98
|
+
this.width = this.foldedWidth;
|
|
99
|
+
this.height = this.foldedHeight;
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
this.width = this.unfoldedWidth;
|
|
103
|
+
this.height = this.unfoldedHight;
|
|
104
|
+
this.x = this.x + this.width / 2 - this.foldedWidth / 2;
|
|
105
|
+
this.y = this.y + this.height / 2 - this.foldedHeight / 2;
|
|
106
|
+
}
|
|
107
|
+
// 移动分组上的连线
|
|
108
|
+
var inCommingEdges = this.graphModel.getNodeIncomingEdge(this.id);
|
|
109
|
+
var outgoingEdges = this.graphModel.getNodeOutgoingEdge(this.id);
|
|
110
|
+
inCommingEdges.concat(outgoingEdges).forEach(function (edgeModel) {
|
|
111
|
+
_this.graphModel.deleteEdgeById(edgeModel.id);
|
|
112
|
+
if (!edgeModel.isFoldedEdge) {
|
|
113
|
+
var isCommingEdge = edgeModel.targetNodeId === _this.id;
|
|
114
|
+
var data = edgeModel.getData();
|
|
115
|
+
if (isCommingEdge) {
|
|
116
|
+
data.endPoint = undefined;
|
|
117
|
+
}
|
|
118
|
+
else {
|
|
119
|
+
data.startPoint = undefined;
|
|
120
|
+
}
|
|
121
|
+
data.pointsList = undefined;
|
|
122
|
+
_this.graphModel.addEdge(data);
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
this.children.forEach(function (elementId) {
|
|
126
|
+
var nodeModel = _this.graphModel.getElement(elementId);
|
|
127
|
+
nodeModel.visible = !isFolded;
|
|
128
|
+
_this.foldEdge(elementId, isFolded);
|
|
129
|
+
});
|
|
130
|
+
};
|
|
131
|
+
/**
|
|
132
|
+
* 折叠分组的时候,处理分组内部子节点上的连线
|
|
133
|
+
* 1. 为了保证校验规则不被打乱,所以只隐藏子节点上面的连线。
|
|
134
|
+
* 2. 重新创建一个属性一样的边。
|
|
135
|
+
* 3. 这个边拥有virtual=true的属性,表示不支持直接修改此边内容。
|
|
136
|
+
*/
|
|
137
|
+
GroupNodeModel.prototype.foldEdge = function (nodeId, isFolded) {
|
|
138
|
+
var _this = this;
|
|
139
|
+
var inCommingEdges = this.graphModel.getNodeIncomingEdge(nodeId);
|
|
140
|
+
var outgoingEdges = this.graphModel.getNodeOutgoingEdge(nodeId);
|
|
141
|
+
inCommingEdges.concat(outgoingEdges).forEach(function (edgeModel, index) {
|
|
142
|
+
var _a;
|
|
143
|
+
edgeModel.visible = !isFolded;
|
|
144
|
+
if (isFolded
|
|
145
|
+
&& (!_this.children.has(edgeModel.targetNodeId)
|
|
146
|
+
|| !_this.children.has(edgeModel.sourceNodeId))) {
|
|
147
|
+
var isCommingEdge = edgeModel.targetNodeId === nodeId;
|
|
148
|
+
if (isFolded) {
|
|
149
|
+
var data = edgeModel.getData();
|
|
150
|
+
data.id = data.id + "__" + index;
|
|
151
|
+
if (isCommingEdge) {
|
|
152
|
+
data.endPoint = undefined;
|
|
153
|
+
data.targetNodeId = _this.id;
|
|
154
|
+
}
|
|
155
|
+
else {
|
|
156
|
+
data.startPoint = undefined;
|
|
157
|
+
data.sourceNodeId = _this.id;
|
|
158
|
+
}
|
|
159
|
+
data.text = (_a = data.text) === null || _a === void 0 ? void 0 : _a.value;
|
|
160
|
+
data.pointsList = undefined;
|
|
161
|
+
var model = _this.graphModel.addEdge(data);
|
|
162
|
+
model.virtual = true;
|
|
163
|
+
// 强制不保存group连线数据
|
|
164
|
+
model.getData = function () { return null; };
|
|
165
|
+
model.text.editable = false;
|
|
166
|
+
model.isFoldedEdge = true;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
});
|
|
73
170
|
};
|
|
74
171
|
GroupNodeModel.prototype.isInRange = function (_a) {
|
|
75
172
|
var x1 = _a.x1, y1 = _a.y1, x2 = _a.x2, y2 = _a.y2;
|
|
@@ -108,6 +205,7 @@ var GroupNodeModel = /** @class */ (function (_super) {
|
|
|
108
205
|
data.children = __spread(this.children);
|
|
109
206
|
var properties = data.properties;
|
|
110
207
|
delete properties.groupAddable;
|
|
208
|
+
delete properties.isFolded;
|
|
111
209
|
return data;
|
|
112
210
|
};
|
|
113
211
|
return GroupNodeModel;
|
|
@@ -117,12 +215,9 @@ var GroupNode = /** @class */ (function (_super) {
|
|
|
117
215
|
function GroupNode() {
|
|
118
216
|
return _super !== null && _super.apply(this, arguments) || this;
|
|
119
217
|
}
|
|
120
|
-
/**
|
|
121
|
-
* 重新toFront,阻止其置顶
|
|
122
|
-
*/
|
|
123
|
-
GroupNode.prototype.toFront = function () { };
|
|
124
218
|
GroupNode.prototype.getControlGroup = function () {
|
|
125
|
-
|
|
219
|
+
var _a = this.props.model, resizable = _a.resizable, properties = _a.properties;
|
|
220
|
+
return resizable && !properties.isFolded ? _super.prototype.getControlGroup.call(this) : null;
|
|
126
221
|
};
|
|
127
222
|
GroupNode.prototype.getAddedableShape = function () {
|
|
128
223
|
var _a = this.props.model, width = _a.width, height = _a.height, x = _a.x, y = _a.y, radius = _a.radius, properties = _a.properties;
|
|
@@ -134,10 +229,45 @@ var GroupNode = /** @class */ (function (_super) {
|
|
|
134
229
|
var newHeight = height + strokeWidth + 8;
|
|
135
230
|
return core_1.h('rect', __assign(__assign({}, style), { width: newWidth, height: newHeight, x: x - newWidth / 2, y: y - newHeight / 2, rx: radius, ry: radius }));
|
|
136
231
|
};
|
|
232
|
+
GroupNode.prototype.getFoldIcon = function () {
|
|
233
|
+
var model = this.props.model;
|
|
234
|
+
var foldX = model.x - model.width / 2 + 5;
|
|
235
|
+
var foldY = model.y - model.height / 2 + 5;
|
|
236
|
+
if (!model.foldable)
|
|
237
|
+
return null;
|
|
238
|
+
var iconIcon = core_1.h('path', {
|
|
239
|
+
fill: 'none',
|
|
240
|
+
stroke: '#818281',
|
|
241
|
+
strokeWidth: 2,
|
|
242
|
+
'pointer-events': 'none',
|
|
243
|
+
d: model.properties.isFolded
|
|
244
|
+
? "M " + (foldX + 3) + "," + (foldY + 6) + " " + (foldX + 11) + "," + (foldY + 6) + " M" + (foldX + 7) + "," + (foldY + 2) + " " + (foldX + 7) + "," + (foldY + 10)
|
|
245
|
+
: "M " + (foldX + 3) + "," + (foldY + 6) + " " + (foldX + 11) + "," + (foldY + 6) + " ",
|
|
246
|
+
});
|
|
247
|
+
return core_1.h('g', {}, [
|
|
248
|
+
core_1.h('rect', {
|
|
249
|
+
height: 12,
|
|
250
|
+
width: 14,
|
|
251
|
+
rx: 2,
|
|
252
|
+
ry: 2,
|
|
253
|
+
strokeWidth: 1,
|
|
254
|
+
fill: '#F4F5F6',
|
|
255
|
+
stroke: '#CECECE',
|
|
256
|
+
cursor: 'pointer',
|
|
257
|
+
x: model.x - model.width / 2 + 5,
|
|
258
|
+
y: model.y - model.height / 2 + 5,
|
|
259
|
+
onClick: function () {
|
|
260
|
+
model.foldGroup(!model.properties.isFolded);
|
|
261
|
+
},
|
|
262
|
+
}),
|
|
263
|
+
iconIcon,
|
|
264
|
+
]);
|
|
265
|
+
};
|
|
137
266
|
GroupNode.prototype.getResizeShape = function () {
|
|
138
267
|
return core_1.h('g', {}, [
|
|
139
268
|
this.getAddedableShape(),
|
|
140
269
|
_super.prototype.getResizeShape.call(this),
|
|
270
|
+
this.getFoldIcon(),
|
|
141
271
|
]);
|
|
142
272
|
};
|
|
143
273
|
return GroupNode;
|
|
@@ -98,7 +98,7 @@ var Group = /** @class */ (function () {
|
|
|
98
98
|
});
|
|
99
99
|
lf.on('node:add', this.appendNodeToGrop);
|
|
100
100
|
lf.on('node:drop', this.appendNodeToGrop);
|
|
101
|
-
lf.on('node:dnd-
|
|
101
|
+
lf.on('node:dnd-drag', this.setActiveGroup);
|
|
102
102
|
lf.on('node:drag', this.setActiveGroup);
|
|
103
103
|
lf.on('graph:rendered', this.graphRendered);
|
|
104
104
|
}
|
|
@@ -9,21 +9,25 @@ var Snapshot = {
|
|
|
9
9
|
install: function (lf) {
|
|
10
10
|
var _this = this;
|
|
11
11
|
this.lf = lf;
|
|
12
|
-
this.offsetX = Number.MAX_SAFE_INTEGER;
|
|
13
|
-
this.offsetY = Number.MAX_SAFE_INTEGER;
|
|
14
12
|
/* 下载快照 */
|
|
15
13
|
lf.getSnapshot = function (fileName, backgroundColor) {
|
|
14
|
+
_this.offsetX = Number.MAX_SAFE_INTEGER;
|
|
15
|
+
_this.offsetY = Number.MAX_SAFE_INTEGER;
|
|
16
16
|
_this.fileName = fileName || "logic-flow." + Date.now() + ".png";
|
|
17
17
|
var svgRootElement = _this.getSvgRootElement(lf);
|
|
18
18
|
_this.downloadSvg(svgRootElement, _this.fileName, backgroundColor);
|
|
19
19
|
};
|
|
20
20
|
/* 获取Blob对象,用户图片上传 */
|
|
21
21
|
lf.getSnapshotBlob = function (backgroundColor) {
|
|
22
|
+
_this.offsetX = Number.MAX_SAFE_INTEGER;
|
|
23
|
+
_this.offsetY = Number.MAX_SAFE_INTEGER;
|
|
22
24
|
var svgRootElement = _this.getSvgRootElement(lf);
|
|
23
25
|
return _this.getBlob(svgRootElement, backgroundColor);
|
|
24
26
|
};
|
|
25
27
|
/* 获取Base64对象,用户图片上传 */
|
|
26
28
|
lf.getSnapshotBase64 = function (backgroundColor) {
|
|
29
|
+
_this.offsetX = Number.MAX_SAFE_INTEGER;
|
|
30
|
+
_this.offsetY = Number.MAX_SAFE_INTEGER;
|
|
27
31
|
var svgRootElement = _this.getSvgRootElement(lf);
|
|
28
32
|
return _this.getBase64(svgRootElement, backgroundColor);
|
|
29
33
|
};
|
|
@@ -175,6 +179,7 @@ var Snapshot = {
|
|
|
175
179
|
canvas.width = bboxWidth * dpr + 80;
|
|
176
180
|
canvas.height = bboxHeight * dpr + 80;
|
|
177
181
|
var ctx = canvas.getContext('2d');
|
|
182
|
+
ctx.clearRect(0, 0, canvas.width, canvas.height);
|
|
178
183
|
ctx.scale(dpr, dpr);
|
|
179
184
|
// 如果有背景色,设置流程图导出的背景色
|
|
180
185
|
if (backgroundColor) {
|
|
@@ -26,7 +26,6 @@ import { h, Component } from 'preact';
|
|
|
26
26
|
import { LogicFlowUtil } from '@logicflow/core';
|
|
27
27
|
import Rect from '../BasicShape/Rect';
|
|
28
28
|
import { getDiamondReizeEdgePoint, getEllipseReizeEdgePoint, getRectReizeEdgePoint, ModelType } from './Util';
|
|
29
|
-
import NodeResize from '../index';
|
|
30
29
|
var createDrag = LogicFlowUtil.createDrag;
|
|
31
30
|
var Control = /** @class */ (function (_super) {
|
|
32
31
|
__extends(Control, _super);
|
|
@@ -211,11 +210,11 @@ var Control = /** @class */ (function (_super) {
|
|
|
211
210
|
pct: 1 / 2,
|
|
212
211
|
});
|
|
213
212
|
// 限制放大缩小的最大最小范围
|
|
214
|
-
var _c =
|
|
215
|
-
if (size.width <
|
|
216
|
-
|| size.width >
|
|
217
|
-
|| size.height <
|
|
218
|
-
|| size.height >
|
|
213
|
+
var _c = _this.nodeModel, minWidth = _c.minWidth, minHeight = _c.minHeight, maxWidth = _c.maxWidth, maxHeight = _c.maxHeight;
|
|
214
|
+
if (size.width < (minWidth / 2)
|
|
215
|
+
|| size.width > (maxWidth / 2)
|
|
216
|
+
|| size.height < (minHeight / 2)
|
|
217
|
+
|| size.height > (maxHeight / 2)) {
|
|
219
218
|
return;
|
|
220
219
|
}
|
|
221
220
|
// 更新中心点位置,更新文案位置
|
|
@@ -271,6 +270,7 @@ var Control = /** @class */ (function (_super) {
|
|
|
271
270
|
// html和矩形的计算方式是一样的,共用一个方法
|
|
272
271
|
if (modelType === ModelType.RECT_NODE || modelType === ModelType.HTML_NODE) {
|
|
273
272
|
_this.updateRect({ deltaX: deltaX, deltaY: deltaY });
|
|
273
|
+
// this.nodeModel.resize(deltaX, deltaY);
|
|
274
274
|
}
|
|
275
275
|
else if (modelType === ModelType.ELLIPSE_NODE) {
|
|
276
276
|
_this.updateEllipse({ deltaX: deltaX, deltaY: deltaY });
|
|
@@ -313,10 +313,10 @@ var Control = /** @class */ (function (_super) {
|
|
|
313
313
|
return { sourceEdges: sourceEdges, targetEdges: targetEdges };
|
|
314
314
|
};
|
|
315
315
|
Control.prototype.render = function () {
|
|
316
|
-
var _a = this.props, x = _a.x, y = _a.y,
|
|
317
|
-
var
|
|
316
|
+
var _a = this.props, x = _a.x, y = _a.y, index = _a.index, model = _a.model;
|
|
317
|
+
var style = model.getControlPointStyle();
|
|
318
318
|
return (h("g", { className: "lf-resize-control-" + index },
|
|
319
|
-
h(Rect, __assign({ className: "lf-node-control" }, { x: x, y: y }, style, {
|
|
319
|
+
h(Rect, __assign({ className: "lf-node-control" }, { x: x, y: y }, style, { onMouseDown: this.dragHandler }))));
|
|
320
320
|
};
|
|
321
321
|
return Control;
|
|
322
322
|
}(Component));
|
|
@@ -25,7 +25,6 @@ var __assign = (this && this.__assign) || function () {
|
|
|
25
25
|
import { h, Component } from 'preact';
|
|
26
26
|
import Control from './Control';
|
|
27
27
|
import Rect from '../BasicShape/Rect';
|
|
28
|
-
import NodeResize from '../index';
|
|
29
28
|
var ControlGroup = /** @class */ (function (_super) {
|
|
30
29
|
__extends(ControlGroup, _super);
|
|
31
30
|
function ControlGroup() {
|
|
@@ -44,18 +43,22 @@ var ControlGroup = /** @class */ (function (_super) {
|
|
|
44
43
|
};
|
|
45
44
|
var minX = box.minX, minY = box.minY, maxX = box.maxX, maxY = box.maxY;
|
|
46
45
|
var controlList = [
|
|
46
|
+
// 左上角
|
|
47
47
|
{
|
|
48
48
|
x: minX,
|
|
49
49
|
y: minY,
|
|
50
50
|
},
|
|
51
|
+
// 右上角
|
|
51
52
|
{
|
|
52
53
|
x: maxX,
|
|
53
54
|
y: minY,
|
|
54
55
|
},
|
|
56
|
+
// 右下角
|
|
55
57
|
{
|
|
56
58
|
x: maxX,
|
|
57
59
|
y: maxY,
|
|
58
60
|
},
|
|
61
|
+
// 左下角
|
|
59
62
|
{
|
|
60
63
|
x: minX,
|
|
61
64
|
y: maxY,
|
|
@@ -65,9 +68,10 @@ var ControlGroup = /** @class */ (function (_super) {
|
|
|
65
68
|
};
|
|
66
69
|
// 一般节点被选中了会有outline, 先不用这个
|
|
67
70
|
ControlGroup.prototype.getGroupSolid = function () {
|
|
68
|
-
var
|
|
69
|
-
var
|
|
70
|
-
|
|
71
|
+
var model = this.props.model;
|
|
72
|
+
var x = model.x, y = model.y, width = model.width, height = model.height;
|
|
73
|
+
var style = model.getResizeOutlineStyle();
|
|
74
|
+
return (h(Rect, __assign({ fill: "none" }, style, { x: x, y: y, width: width, height: height })));
|
|
71
75
|
};
|
|
72
76
|
ControlGroup.prototype.render = function () {
|
|
73
77
|
return (h("g", { className: "lf-resize-control" },
|
|
@@ -1,6 +1,21 @@
|
|
|
1
1
|
import { h, DiamondNode, DiamondNodeModel } from '@logicflow/core';
|
|
2
2
|
declare class DiamondResizeModel extends DiamondNodeModel {
|
|
3
|
+
minWidth: number;
|
|
4
|
+
minHeight: number;
|
|
5
|
+
maxWidth: number;
|
|
6
|
+
maxHeight: number;
|
|
3
7
|
getOutlineStyle(): import("@logicflow/core/types/constant/DefaultTheme").OutlineTheme;
|
|
8
|
+
getResizeOutlineStyle(): {
|
|
9
|
+
stroke: string;
|
|
10
|
+
strokeWidth: number;
|
|
11
|
+
strokeDasharray: string;
|
|
12
|
+
};
|
|
13
|
+
getControlPointStyle(): {
|
|
14
|
+
width: number;
|
|
15
|
+
height: number;
|
|
16
|
+
fill: string;
|
|
17
|
+
stroke: string;
|
|
18
|
+
};
|
|
4
19
|
setAttributes(): void;
|
|
5
20
|
}
|
|
6
21
|
declare class DiamondResizeView extends DiamondNode {
|
|
@@ -28,7 +28,12 @@ import Polygon from '../BasicShape/Polygon';
|
|
|
28
28
|
var DiamondResizeModel = /** @class */ (function (_super) {
|
|
29
29
|
__extends(DiamondResizeModel, _super);
|
|
30
30
|
function DiamondResizeModel() {
|
|
31
|
-
|
|
31
|
+
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
32
|
+
_this.minWidth = 30;
|
|
33
|
+
_this.minHeight = 30;
|
|
34
|
+
_this.maxWidth = 2000;
|
|
35
|
+
_this.maxHeight = 2000;
|
|
36
|
+
return _this;
|
|
32
37
|
}
|
|
33
38
|
DiamondResizeModel.prototype.getOutlineStyle = function () {
|
|
34
39
|
var style = _super.prototype.getOutlineStyle.call(this);
|
|
@@ -38,6 +43,21 @@ var DiamondResizeModel = /** @class */ (function (_super) {
|
|
|
38
43
|
}
|
|
39
44
|
return style;
|
|
40
45
|
};
|
|
46
|
+
DiamondResizeModel.prototype.getResizeOutlineStyle = function () {
|
|
47
|
+
return {
|
|
48
|
+
stroke: '#000000',
|
|
49
|
+
strokeWidth: 1,
|
|
50
|
+
strokeDasharray: '3,3',
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
DiamondResizeModel.prototype.getControlPointStyle = function () {
|
|
54
|
+
return {
|
|
55
|
+
width: 7,
|
|
56
|
+
height: 7,
|
|
57
|
+
fill: '#FFFFFF',
|
|
58
|
+
stroke: '#000000',
|
|
59
|
+
};
|
|
60
|
+
};
|
|
41
61
|
DiamondResizeModel.prototype.setAttributes = function () {
|
|
42
62
|
// @ts-ignore
|
|
43
63
|
var nodeSize = this.properties.nodeSize;
|