@logicflow/extension 1.1.0-alpha.2 → 1.1.0-alpha.6

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.
Files changed (58) hide show
  1. package/cjs/NodeResize/Control/Control.js +9 -9
  2. package/cjs/NodeResize/Control/ControlGroup.js +8 -4
  3. package/cjs/NodeResize/Node/DiamondResize.js +21 -1
  4. package/cjs/NodeResize/Node/EllipseResize.js +15 -0
  5. package/cjs/NodeResize/Node/HtmlResize.js +15 -0
  6. package/cjs/NodeResize/Node/RectResize.js +19 -0
  7. package/cjs/NodeResize/index.js +2 -36
  8. package/cjs/materials/group/GroupNode.js +197 -23
  9. package/cjs/materials/group/index.js +28 -9
  10. package/cjs/style/index.css +3 -2
  11. package/cjs/tools/snapshot/index.js +7 -2
  12. package/es/NodeResize/Control/Control.js +9 -9
  13. package/es/NodeResize/Control/ControlGroup.js +8 -4
  14. package/es/NodeResize/Node/DiamondResize.d.ts +15 -0
  15. package/es/NodeResize/Node/DiamondResize.js +21 -1
  16. package/es/NodeResize/Node/EllipseResize.d.ts +11 -0
  17. package/es/NodeResize/Node/EllipseResize.js +15 -0
  18. package/es/NodeResize/Node/HtmlResize.d.ts +11 -0
  19. package/es/NodeResize/Node/HtmlResize.js +15 -0
  20. package/es/NodeResize/Node/RectResize.d.ts +13 -0
  21. package/es/NodeResize/Node/RectResize.js +19 -0
  22. package/es/NodeResize/index.d.ts +2 -28
  23. package/es/NodeResize/index.js +1 -36
  24. package/es/materials/group/GroupNode.d.ts +42 -11
  25. package/es/materials/group/GroupNode.js +198 -24
  26. package/es/materials/group/index.d.ts +3 -1
  27. package/es/materials/group/index.js +27 -9
  28. package/es/style/index.css +3 -2
  29. package/es/tools/snapshot/index.js +7 -2
  30. package/lib/AutoLayout.js +1 -1
  31. package/lib/BpmnAdapter.js +1 -1
  32. package/lib/BpmnElement.js +1 -1
  33. package/lib/ContextMenu.js +1 -1
  34. package/lib/Control.js +1 -1
  35. package/lib/CurvedEdge.js +1 -1
  36. package/lib/DndPanel.js +1 -1
  37. package/lib/FlowPath.js +1 -1
  38. package/lib/Group.js +1 -1
  39. package/lib/InsertNodeInPolyline.js +1 -1
  40. package/lib/Menu.js +1 -1
  41. package/lib/MiniMap.js +1 -1
  42. package/lib/NodeResize.js +1 -1
  43. package/lib/RectLabelNode.js +1 -1
  44. package/lib/SelectionSelect.js +1 -1
  45. package/lib/Snapshot.js +1 -1
  46. package/lib/TurboAdapter.js +1 -1
  47. package/lib/lfJson2Xml.js +1 -1
  48. package/lib/lfXml2Json.js +1 -1
  49. package/lib/style/index.css +3 -2
  50. package/package.json +2 -2
  51. package/types/NodeResize/Node/DiamondResize.d.ts +15 -0
  52. package/types/NodeResize/Node/EllipseResize.d.ts +11 -0
  53. package/types/NodeResize/Node/HtmlResize.d.ts +11 -0
  54. package/types/NodeResize/Node/RectResize.d.ts +13 -0
  55. package/types/NodeResize/index.d.ts +2 -28
  56. package/types/group-shrink/index.d.ts +28 -0
  57. package/types/materials/group/GroupNode.d.ts +42 -11
  58. package/types/materials/group/index.d.ts +3 -1
@@ -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 = index_1.default.sizeRange.ellipse, minRx = _c.minRx, minRy = _c.minRy, maxRx = _c.maxRx, maxRy = _c.maxRy;
217
- if (size.width < minRx
218
- || size.width > maxRx
219
- || size.height < minRy
220
- || size.height > maxRy) {
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, style = _a.style, index = _a.index;
319
- var _b = index_1.default.style.controlPoint, width = _b.width, height = _b.height, fill = _b.fill, stroke = _b.stroke;
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, { width: width, height: height, fill: fill, stroke: stroke, onMouseDown: this.dragHandler }))));
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 _a = this.props.model, x = _a.x, y = _a.y, width = _a.width, height = _a.height;
71
- var _b = index_1.default.style.outline, stroke = _b.stroke, strokeWidth = _b.strokeWidth, strokeDasharray = _b.strokeDasharray;
72
- return (preact_1.h(Rect_1.default, { fill: "none", x: x, y: y, width: width, height: height, stroke: stroke, strokeWidth: strokeWidth, strokeDasharray: strokeDasharray }));
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
- return _super !== null && _super.apply(this, arguments) || this;
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) {
@@ -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,
@@ -12,6 +12,17 @@ var __extends = (this && this.__extends) || (function () {
12
12
  d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
13
13
  };
14
14
  })();
15
+ var __assign = (this && this.__assign) || function () {
16
+ __assign = Object.assign || function(t) {
17
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
18
+ s = arguments[i];
19
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
20
+ t[p] = s[p];
21
+ }
22
+ return t;
23
+ };
24
+ return __assign.apply(this, arguments);
25
+ };
15
26
  var __read = (this && this.__read) || function (o, n) {
16
27
  var m = typeof Symbol === "function" && o[Symbol.iterator];
17
28
  if (!m) return o;
@@ -34,27 +45,126 @@ var __spread = (this && this.__spread) || function () {
34
45
  };
35
46
  Object.defineProperty(exports, "__esModule", { value: true });
36
47
  var core_1 = require("@logicflow/core");
48
+ var NodeResize_1 = require("../../NodeResize");
49
+ var defaultWidth = 500;
50
+ var defaultHeight = 300;
37
51
  var GroupNodeModel = /** @class */ (function (_super) {
38
52
  __extends(GroupNodeModel, _super);
39
53
  function GroupNodeModel() {
40
54
  var _this = _super !== null && _super.apply(this, arguments) || this;
41
55
  _this.isGroup = true;
42
- _this.children = new Set();
43
- _this.isRestrict = true; // 其子节点是否被禁止通过拖拽移出分组。 默认false,允许拖拽移除分组。
56
+ _this.unfoldedWidth = defaultWidth;
57
+ _this.unfoldedHight = defaultHeight;
44
58
  return _this;
45
59
  }
46
- GroupNodeModel.prototype.setAttributes = function () {
47
- this.width = 500;
48
- this.height = 200;
49
- this.strokeWidth = 1;
50
- this.zIndex = 0;
60
+ GroupNodeModel.prototype.initNodeData = function (data) {
61
+ _super.prototype.initNodeData.call(this, data);
62
+ var children = [];
63
+ if (Array.isArray(data.children)) {
64
+ children = data.children;
65
+ }
66
+ // 初始化组的子节点
67
+ this.children = new Set(children);
68
+ this.width = defaultWidth;
69
+ this.height = defaultHeight;
70
+ this.foldedWidth = 80;
71
+ this.foldedHeight = 60;
72
+ // todo: 参考bpmn.js, 分组和未加入分组的节点重合时,未加入分组的节点在分组之下。方便标识。
73
+ this.zIndex = -1;
51
74
  this.radius = 0;
75
+ this.text.editable = false;
76
+ this.text.draggable = false;
77
+ this.isRestrict = false;
78
+ this.resizable = false;
79
+ this.autoToFront = false;
80
+ this.foldable = false;
81
+ this.properties.isFolded = false;
82
+ };
83
+ GroupNodeModel.prototype.getResizeOutlineStyle = function () {
84
+ var style = _super.prototype.getResizeOutlineStyle.call(this);
85
+ style.stroke = 'none';
86
+ return style;
87
+ };
88
+ GroupNodeModel.prototype.foldGroup = function (isFolded) {
89
+ var _this = this;
90
+ this.setProperty('isFolded', isFolded);
91
+ if (isFolded) {
92
+ this.x = this.x - this.width / 2 + this.foldedWidth / 2;
93
+ this.y = this.y - this.height / 2 + this.foldedHeight / 2;
94
+ this.unfoldedWidth = this.width;
95
+ this.unfoldedHight = this.height;
96
+ this.width = this.foldedWidth;
97
+ this.height = this.foldedHeight;
98
+ }
99
+ else {
100
+ this.width = this.unfoldedWidth;
101
+ this.height = this.unfoldedHight;
102
+ this.x = this.x + this.width / 2 - this.foldedWidth / 2;
103
+ this.y = this.y + this.height / 2 - this.foldedHeight / 2;
104
+ }
105
+ // 移动分组上的连线
106
+ var inCommingEdges = this.graphModel.getNodeIncomingEdge(this.id);
107
+ var outgoingEdges = this.graphModel.getNodeOutgoingEdge(this.id);
108
+ inCommingEdges.concat(outgoingEdges).forEach(function (edgeModel) {
109
+ _this.graphModel.deleteEdgeById(edgeModel.id);
110
+ if (!edgeModel.isFoldedEdge) {
111
+ var isCommingEdge = edgeModel.targetNodeId === _this.id;
112
+ var data = edgeModel.getData();
113
+ if (isCommingEdge) {
114
+ data.endPoint = undefined;
115
+ }
116
+ else {
117
+ data.startPoint = undefined;
118
+ }
119
+ data.pointsList = undefined;
120
+ _this.graphModel.addEdge(data);
121
+ }
122
+ });
123
+ this.children.forEach(function (elementId) {
124
+ var nodeModel = _this.graphModel.getElement(elementId);
125
+ nodeModel.visible = !isFolded;
126
+ _this.foldEdge(elementId, isFolded);
127
+ });
52
128
  };
53
129
  /**
54
- * 设置是否允许子节点被拖动移除分组
130
+ * 折叠分组的时候,处理分组内部子节点上的连线
131
+ * 1. 为了保证校验规则不被打乱,所以只隐藏子节点上面的连线。
132
+ * 2. 重新创建一个属性一样的边。
133
+ * 3. 这个边拥有virtual=true的属性,表示不支持直接修改此边内容。
55
134
  */
56
- GroupNodeModel.prototype.setIsRestrict = function (isRestrict) {
57
- this.isRestrict = isRestrict;
135
+ GroupNodeModel.prototype.foldEdge = function (nodeId, isFolded) {
136
+ var _this = this;
137
+ var inCommingEdges = this.graphModel.getNodeIncomingEdge(nodeId);
138
+ var outgoingEdges = this.graphModel.getNodeOutgoingEdge(nodeId);
139
+ inCommingEdges.concat(outgoingEdges).forEach(function (edgeModel, index) {
140
+ var _a;
141
+ edgeModel.visible = !isFolded;
142
+ if (isFolded
143
+ && (!_this.children.has(edgeModel.targetNodeId)
144
+ || !_this.children.has(edgeModel.sourceNodeId))) {
145
+ var isCommingEdge = edgeModel.targetNodeId === nodeId;
146
+ if (isFolded) {
147
+ var data = edgeModel.getData();
148
+ data.id = data.id + "__" + index;
149
+ if (isCommingEdge) {
150
+ data.endPoint = undefined;
151
+ data.targetNodeId = _this.id;
152
+ }
153
+ else {
154
+ data.startPoint = undefined;
155
+ data.sourceNodeId = _this.id;
156
+ }
157
+ data.text = (_a = data.text) === null || _a === void 0 ? void 0 : _a.value;
158
+ data.pointsList = undefined;
159
+ var model = _this.graphModel.addEdge(data);
160
+ model.virtual = true;
161
+ // 强制不保存group连线数据
162
+ model.getData = function () { return null; };
163
+ model.text.editable = false;
164
+ model.isFoldedEdge = true;
165
+ }
166
+ }
167
+ });
58
168
  };
59
169
  GroupNodeModel.prototype.isInRange = function (_a) {
60
170
  var x1 = _a.x1, y1 = _a.y1, x2 = _a.x2, y2 = _a.y2;
@@ -63,39 +173,103 @@ var GroupNodeModel = /** @class */ (function (_super) {
63
173
  && y1 >= (this.y - this.height / 2)
64
174
  && y2 <= (this.y + this.height / 2);
65
175
  };
66
- // todo: 更好的方式定义分组的样式
67
176
  GroupNodeModel.prototype.setAllowAppendChild = function (isAllow) {
68
- if (isAllow) {
69
- this.stroke = 'red';
70
- }
71
- else {
72
- this.stroke = 'rgb(24, 125, 255)';
73
- }
177
+ this.setProperty('groupAddable', isAllow);
74
178
  };
179
+ /**
180
+ * 添加分组子节点
181
+ * @param id 节点id
182
+ */
75
183
  GroupNodeModel.prototype.addChild = function (id) {
76
184
  this.children.add(id);
77
185
  };
186
+ /**
187
+ * 删除分组子节点
188
+ * @param id 节点id
189
+ */
78
190
  GroupNodeModel.prototype.removeChild = function (id) {
79
191
  this.children.delete(id);
80
192
  };
193
+ GroupNodeModel.prototype.getAddableOutlineStyle = function () {
194
+ return {
195
+ stroke: '#FEB663',
196
+ strokeWidth: 2,
197
+ strokeDasharray: '4 4',
198
+ fill: 'transparent',
199
+ };
200
+ };
81
201
  GroupNodeModel.prototype.getData = function () {
82
202
  var data = _super.prototype.getData.call(this);
83
203
  data.children = __spread(this.children);
204
+ var properties = data.properties;
205
+ delete properties.groupAddable;
206
+ delete properties.isFolded;
84
207
  return data;
85
208
  };
86
209
  return GroupNodeModel;
87
- }(core_1.RectNodeModel));
210
+ }(NodeResize_1.RectResize.model));
88
211
  var GroupNode = /** @class */ (function (_super) {
89
212
  __extends(GroupNode, _super);
90
213
  function GroupNode() {
91
214
  return _super !== null && _super.apply(this, arguments) || this;
92
215
  }
93
- /**
94
- * 重新toFront,阻止其置顶
95
- */
96
- GroupNode.prototype.toFront = function () { };
216
+ GroupNode.prototype.getControlGroup = function () {
217
+ var _a = this.props.model, resizable = _a.resizable, properties = _a.properties;
218
+ return resizable && !properties.isFolded ? _super.prototype.getControlGroup.call(this) : null;
219
+ };
220
+ GroupNode.prototype.getAddedableShape = function () {
221
+ var _a = this.props.model, width = _a.width, height = _a.height, x = _a.x, y = _a.y, radius = _a.radius, properties = _a.properties;
222
+ if (!properties.groupAddable)
223
+ return null;
224
+ var strokeWidth = this.props.model.getNodeStyle().strokeWidth;
225
+ var style = this.props.model.getAddableOutlineStyle();
226
+ var newWidth = width + strokeWidth + 8;
227
+ var newHeight = height + strokeWidth + 8;
228
+ return core_1.h('rect', __assign(__assign({}, style), { width: newWidth, height: newHeight, x: x - newWidth / 2, y: y - newHeight / 2, rx: radius, ry: radius }));
229
+ };
230
+ GroupNode.prototype.getFoldIcon = function () {
231
+ var model = this.props.model;
232
+ var foldX = model.x - model.width / 2 + 5;
233
+ var foldY = model.y - model.height / 2 + 5;
234
+ if (!model.foldable)
235
+ return null;
236
+ var iconIcon = core_1.h('path', {
237
+ fill: 'none',
238
+ stroke: '#818281',
239
+ strokeWidth: 2,
240
+ 'pointer-events': 'none',
241
+ d: model.properties.isFolded
242
+ ? "M " + (foldX + 3) + "," + (foldY + 6) + " " + (foldX + 11) + "," + (foldY + 6) + " M" + (foldX + 7) + "," + (foldY + 2) + " " + (foldX + 7) + "," + (foldY + 10)
243
+ : "M " + (foldX + 3) + "," + (foldY + 6) + " " + (foldX + 11) + "," + (foldY + 6) + " ",
244
+ });
245
+ return core_1.h('g', {}, [
246
+ core_1.h('rect', {
247
+ height: 12,
248
+ width: 14,
249
+ rx: 2,
250
+ ry: 2,
251
+ strokeWidth: 1,
252
+ fill: '#F4F5F6',
253
+ stroke: '#CECECE',
254
+ cursor: 'pointer',
255
+ x: model.x - model.width / 2 + 5,
256
+ y: model.y - model.height / 2 + 5,
257
+ onClick: function () {
258
+ model.foldGroup(!model.properties.isFolded);
259
+ },
260
+ }),
261
+ iconIcon,
262
+ ]);
263
+ };
264
+ GroupNode.prototype.getResizeShape = function () {
265
+ return core_1.h('g', {}, [
266
+ this.getAddedableShape(),
267
+ _super.prototype.getResizeShape.call(this),
268
+ this.getFoldIcon(),
269
+ ]);
270
+ };
97
271
  return GroupNode;
98
- }(core_1.RectNode));
272
+ }(NodeResize_1.RectResize.view));
99
273
  exports.default = {
100
274
  type: 'group',
101
275
  view: GroupNode,
@@ -20,13 +20,26 @@ var __spread = (this && this.__spread) || function () {
20
20
  return ar;
21
21
  };
22
22
  Object.defineProperty(exports, "__esModule", { value: true });
23
- exports.Group = void 0;
23
+ exports.GroupNode = exports.Group = void 0;
24
24
  var GroupNode_1 = require("./GroupNode");
25
+ exports.GroupNode = GroupNode_1.default;
25
26
  var Group = /** @class */ (function () {
26
27
  function Group(_a) {
27
28
  var _this = this;
28
29
  var lf = _a.lf;
29
30
  this.nodeGroupMap = new Map();
31
+ this.graphRendered = function (data) {
32
+ // 如果节点
33
+ if (data && data.nodes) {
34
+ data.nodes.forEach(function (node) {
35
+ if (node.children) {
36
+ node.children.forEach(function (nodeId) {
37
+ _this.nodeGroupMap.set(nodeId, node.id);
38
+ });
39
+ }
40
+ });
41
+ }
42
+ };
30
43
  this.appendNodeToGrop = function (_a) {
31
44
  var data = _a.data;
32
45
  // 如果这个节点之前已经在group中了,则将其从之前的group中移除
@@ -48,14 +61,19 @@ var Group = /** @class */ (function () {
48
61
  };
49
62
  this.setActiveGroup = function (_a) {
50
63
  var data = _a.data;
51
- if (_this.activeGroup) {
52
- _this.activeGroup.setAllowAppendChild(false);
53
- _this.activeGroup = undefined;
54
- }
55
- var bounds = _this.lf.getNodeModelById(data.id).getBounds();
56
- _this.activeGroup = _this.getGroup(bounds);
57
- if (_this.activeGroup && _this.activeGroup.id !== data.id) {
58
- _this.activeGroup.setAllowAppendChild(true);
64
+ var nodeModel = _this.lf.getNodeModelById(data.id);
65
+ if (nodeModel.isGroup)
66
+ return;
67
+ var bounds = nodeModel.getBounds();
68
+ var newGroup = _this.getGroup(bounds);
69
+ if (newGroup || newGroup !== _this.activeGroup) {
70
+ if (_this.activeGroup) {
71
+ _this.activeGroup.setAllowAppendChild(false);
72
+ }
73
+ if (newGroup) {
74
+ _this.activeGroup = newGroup;
75
+ _this.activeGroup.setAllowAppendChild(true);
76
+ }
59
77
  }
60
78
  };
61
79
  lf.register(GroupNode_1.default);
@@ -82,6 +100,7 @@ var Group = /** @class */ (function () {
82
100
  lf.on('node:drop', this.appendNodeToGrop);
83
101
  lf.on('node:dnd-move', this.setActiveGroup);
84
102
  lf.on('node:drag', this.setActiveGroup);
103
+ lf.on('graph:rendered', this.graphRendered);
85
104
  }
86
105
  Group.prototype.getGroups = function () {
87
106
  var groups = [];
@@ -22,8 +22,9 @@
22
22
  background: #efefef;
23
23
  }
24
24
  .lf-control-item.disabled {
25
- filter: opacity(0.6);
26
- cursor: not-allowed;
25
+ filter: opacity(0.5);
26
+ /* cursor: not-allowed; */
27
+ pointer-events: none;
27
28
  }
28
29
  .lf-control-item.disabled:hover {
29
30
  background: #fff;
@@ -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) {