@logicflow/extension 1.2.0-next.0 → 1.2.0-next.2

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 (104) hide show
  1. package/cjs/NodeResize/Control/Control.js +71 -16
  2. package/cjs/NodeResize/Node/DiamondResize.js +24 -10
  3. package/cjs/NodeResize/Node/EllipseResize.js +24 -10
  4. package/cjs/NodeResize/Node/HtmlResize.js +24 -10
  5. package/cjs/NodeResize/Node/RectResize.js +24 -10
  6. package/cjs/bpmn-adapter/index.js +74 -122
  7. package/cjs/bpmn-adapter/json2xml.js +2 -4
  8. package/cjs/bpmn-adapter/xml2json.js +247 -2
  9. package/cjs/components/control/index.js +16 -16
  10. package/cjs/components/dnd-panel/index.js +21 -0
  11. package/cjs/components/highlight/index.js +0 -1
  12. package/cjs/components/menu/index.js +9 -9
  13. package/cjs/components/mini-map/index.js +223 -138
  14. package/cjs/components/selection-select/index.js +6 -19
  15. package/cjs/index.js +0 -1
  16. package/cjs/materials/curved-edge/index.js +19 -5
  17. package/cjs/materials/curved-edge/searchMiddleIndex.js +17 -0
  18. package/cjs/materials/group/GroupNode.js +34 -65
  19. package/cjs/materials/group/index.js +80 -70
  20. package/cjs/style/index.css +10 -0
  21. package/cjs/tools/auto-layout/index.js +1 -1
  22. package/es/NodeResize/Control/Control.d.ts +4 -1
  23. package/es/NodeResize/Control/Control.js +71 -16
  24. package/es/NodeResize/Node/DiamondResize.d.ts +3 -1
  25. package/es/NodeResize/Node/DiamondResize.js +24 -10
  26. package/es/NodeResize/Node/EllipseResize.d.ts +3 -1
  27. package/es/NodeResize/Node/EllipseResize.js +24 -10
  28. package/es/NodeResize/Node/HtmlResize.d.ts +3 -1
  29. package/es/NodeResize/Node/HtmlResize.js +24 -10
  30. package/es/NodeResize/Node/RectResize.d.ts +3 -1
  31. package/es/NodeResize/Node/RectResize.js +24 -10
  32. package/es/bpmn-adapter/index.d.ts +33 -41
  33. package/es/bpmn-adapter/index.js +74 -122
  34. package/es/bpmn-adapter/json2xml.js +2 -4
  35. package/es/bpmn-adapter/xml2json.js +247 -2
  36. package/es/components/control/index.d.ts +3 -2
  37. package/es/components/control/index.js +16 -16
  38. package/es/components/dnd-panel/index.js +21 -0
  39. package/es/components/highlight/index.js +0 -1
  40. package/es/components/menu/index.d.ts +3 -2
  41. package/es/components/menu/index.js +9 -9
  42. package/es/components/mini-map/index.d.ts +57 -45
  43. package/es/components/mini-map/index.js +223 -138
  44. package/es/components/selection-select/index.d.ts +0 -1
  45. package/es/components/selection-select/index.js +6 -19
  46. package/es/index.d.ts +0 -1
  47. package/es/index.js +0 -1
  48. package/es/materials/curved-edge/index.js +19 -5
  49. package/es/materials/curved-edge/searchMiddleIndex.d.ts +1 -0
  50. package/es/materials/curved-edge/searchMiddleIndex.js +14 -0
  51. package/es/materials/group/GroupNode.d.ts +5 -7
  52. package/es/materials/group/GroupNode.js +34 -65
  53. package/es/materials/group/index.d.ts +19 -1
  54. package/es/materials/group/index.js +80 -70
  55. package/es/style/index.css +10 -0
  56. package/es/tools/auto-layout/index.d.ts +1 -1
  57. package/es/tools/auto-layout/index.js +1 -1
  58. package/lib/AutoLayout.js +1 -1
  59. package/lib/BpmnAdapter.js +1 -1
  60. package/lib/BpmnElement.js +1 -1
  61. package/lib/ContextMenu.js +1 -1
  62. package/lib/Control.js +1 -1
  63. package/lib/CurvedEdge.js +1 -1
  64. package/lib/DndPanel.js +1 -1
  65. package/lib/FlowPath.js +1 -1
  66. package/lib/Group.js +1 -1
  67. package/lib/Highlight.js +1 -1
  68. package/lib/InsertNodeInPolyline.js +1 -1
  69. package/lib/Menu.js +1 -1
  70. package/lib/MiniMap.js +1 -1
  71. package/lib/NodeResize.js +1 -1
  72. package/lib/RectLabelNode.js +1 -1
  73. package/lib/SelectionSelect.js +1 -1
  74. package/lib/Snapshot.js +1 -1
  75. package/lib/TurboAdapter.js +1 -1
  76. package/lib/lfJson2Xml.js +1 -1
  77. package/lib/lfXml2Json.js +1 -1
  78. package/lib/style/index.css +10 -0
  79. package/package.json +3 -2
  80. package/types/NodeResize/Control/Control.d.ts +4 -1
  81. package/types/NodeResize/Node/DiamondResize.d.ts +3 -1
  82. package/types/NodeResize/Node/EllipseResize.d.ts +3 -1
  83. package/types/NodeResize/Node/HtmlResize.d.ts +3 -1
  84. package/types/NodeResize/Node/RectResize.d.ts +3 -1
  85. package/types/bpmn-adapter/index.d.ts +33 -41
  86. package/types/components/control/index.d.ts +3 -2
  87. package/types/components/menu/index.d.ts +3 -2
  88. package/types/components/mini-map/index.d.ts +57 -45
  89. package/types/components/selection-select/index.d.ts +0 -1
  90. package/types/index.d.ts +0 -1
  91. package/types/materials/curved-edge/searchMiddleIndex.d.ts +1 -0
  92. package/types/materials/group/GroupNode.d.ts +5 -7
  93. package/types/materials/group/index.d.ts +19 -1
  94. package/types/tools/auto-layout/index.d.ts +1 -1
  95. package/cjs/locale/en-locale/en.js +0 -22
  96. package/cjs/locale/en-locale/index.js +0 -29
  97. package/cjs/locale/locale.js +0 -19
  98. package/es/locale/en-locale/en.d.ts +0 -19
  99. package/es/locale/en-locale/en.js +0 -19
  100. package/es/locale/en-locale/index.d.ts +0 -9
  101. package/es/locale/en-locale/index.js +0 -26
  102. package/es/locale/locale.d.ts +0 -6
  103. package/es/locale/locale.js +0 -16
  104. package/lib/EnLocale.js +0 -1
@@ -48,6 +48,7 @@ var core_1 = require("@logicflow/core");
48
48
  var NodeResize_1 = require("../../NodeResize");
49
49
  var defaultWidth = 500;
50
50
  var defaultHeight = 300;
51
+ var DEFAULT_BOTTOM_Z_INDEX = -10000;
51
52
  var GroupNodeModel = /** @class */ (function (_super) {
52
53
  __extends(GroupNodeModel, _super);
53
54
  function GroupNodeModel() {
@@ -70,8 +71,7 @@ var GroupNodeModel = /** @class */ (function (_super) {
70
71
  this.height = defaultHeight;
71
72
  this.foldedWidth = 80;
72
73
  this.foldedHeight = 60;
73
- // todo: 参考bpmn.js, 分组和未加入分组的节点重合时,未加入分组的节点在分组之下。方便标识。
74
- this.zIndex = -1;
74
+ this.zIndex = DEFAULT_BOTTOM_Z_INDEX;
75
75
  this.radius = 0;
76
76
  this.text.editable = false;
77
77
  this.text.draggable = false;
@@ -79,8 +79,6 @@ var GroupNodeModel = /** @class */ (function (_super) {
79
79
  this.resizable = false;
80
80
  this.autoToFront = false;
81
81
  this.foldable = false;
82
- // 是否可以被嵌套
83
- this.nestable = false;
84
82
  if (this.properties.isFolded === undefined) {
85
83
  this.properties.isFolded = false;
86
84
  }
@@ -104,60 +102,41 @@ var GroupNodeModel = /** @class */ (function (_super) {
104
102
  * 3. 处理连线
105
103
  */
106
104
  GroupNodeModel.prototype.foldGroup = function (isFolded) {
105
+ var _this = this;
107
106
  this.setProperty('isFolded', isFolded);
108
107
  this.isFolded = isFolded;
109
108
  // step 1
110
- this.foldRect(isFolded);
111
- // step 2
112
- var allEdges = this.foldChildren(isFolded);
113
- // step 3
114
- console.log({ allEdges: allEdges });
115
- this.foldEdge(isFolded, allEdges);
116
- };
117
- GroupNodeModel.prototype.getAnchorStyle = function (anchorInfo) {
118
- var style = _super.prototype.getAnchorStyle.call(this, anchorInfo);
119
- style.stroke = 'transparent';
120
- style.fill = 'transparent';
121
- style.hover.fill = 'transparent';
122
- style.hover.stroke = 'transparent';
123
- return style;
124
- };
125
- GroupNodeModel.prototype.foldRect = function (isFolded) {
126
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;
127
112
  this.unfoldedWidth = this.width;
128
113
  this.unfoldedHight = this.height;
129
- this.updateAttributes({
130
- x: this.x - this.width / 2 + this.foldedWidth / 2,
131
- y: this.y - this.height / 2 + this.foldedHeight / 2,
132
- width: this.foldedWidth,
133
- height: this.foldedHeight,
134
- });
114
+ this.width = this.foldedWidth;
115
+ this.height = this.foldedHeight;
135
116
  }
136
117
  else {
137
- this.updateAttributes({
138
- width: this.unfoldedWidth,
139
- height: this.unfoldedHight,
140
- x: this.x + this.unfoldedWidth / 2 - this.foldedWidth / 2,
141
- y: this.y + this.unfoldedHight / 2 - this.foldedHeight / 2,
142
- });
118
+ this.width = this.unfoldedWidth;
119
+ this.height = this.unfoldedHight;
120
+ this.x = this.x + this.width / 2 - this.foldedWidth / 2;
121
+ this.y = this.y + this.height / 2 - this.foldedHeight / 2;
143
122
  }
144
- };
145
- GroupNodeModel.prototype.foldChildren = function (isFolded) {
146
- var _this = this;
123
+ // step 2
147
124
  var allEdges = this.incoming.edges.concat(this.outgoing.edges);
148
125
  this.children.forEach(function (elementId) {
149
126
  var nodeModel = _this.graphModel.getElement(elementId);
150
- if (nodeModel.isGroup) {
151
- var childEdges = nodeModel.foldChildren(isFolded || nodeModel.isFolded);
152
- allEdges = allEdges.concat(childEdges);
153
- nodeModel.foldEdge(isFolded, childEdges);
154
- }
127
+ nodeModel.visible = !isFolded;
155
128
  allEdges = allEdges.concat(nodeModel.incoming.edges.concat(nodeModel.outgoing.edges));
156
- nodeModel.updateAttributes({
157
- visible: !isFolded,
158
- });
159
129
  });
160
- return allEdges;
130
+ // step 3
131
+ this.foldEdge(isFolded, allEdges);
132
+ };
133
+ GroupNodeModel.prototype.getAnchorStyle = function (anchorInfo) {
134
+ var style = _super.prototype.getAnchorStyle.call(this, anchorInfo);
135
+ style.stroke = 'transparent';
136
+ style.fill = 'transparent';
137
+ style.hover.fill = 'transparent';
138
+ style.hover.stroke = 'transparent';
139
+ return style;
161
140
  };
162
141
  /**
163
142
  * 折叠分组的时候,处理分组自身的连线和分组内部子节点上的连线
@@ -217,9 +196,7 @@ var GroupNodeModel = /** @class */ (function (_super) {
217
196
  if (targetNodeIdGroup.id !== _this.id || sourceNodeIdGroup.id !== _this.id) {
218
197
  _this.createVirtualEdge(data);
219
198
  }
220
- edgeModel.updateAttributes({
221
- visible: false,
222
- });
199
+ edgeModel.visible = false;
223
200
  }
224
201
  // 展开时,处理被隐藏的边的逻辑
225
202
  if (!isFolded && edgeModel.visible === false) {
@@ -235,9 +212,7 @@ var GroupNodeModel = /** @class */ (function (_super) {
235
212
  _this.createVirtualEdge(data);
236
213
  }
237
214
  else {
238
- edgeModel.updateAttributes({
239
- visible: true,
240
- });
215
+ edgeModel.visible = true;
241
216
  }
242
217
  }
243
218
  });
@@ -282,19 +257,6 @@ var GroupNodeModel = /** @class */ (function (_super) {
282
257
  GroupNodeModel.prototype.removeChild = function (id) {
283
258
  this.children.delete(id);
284
259
  };
285
- /**
286
- * 获得包含嵌套组的所有子节点
287
- */
288
- GroupNodeModel.prototype.getChildren = function () {
289
- var _this = this;
290
- return __spread(this.children).flatMap(function (child) {
291
- var model = _this.graphModel.getElement(child);
292
- if (model.isGroup) {
293
- return __spread([child], model.getChildren());
294
- }
295
- return child;
296
- });
297
- };
298
260
  GroupNodeModel.prototype.getAddableOutlineStyle = function () {
299
261
  return {
300
262
  stroke: '#FEB663',
@@ -314,6 +276,7 @@ var GroupNodeModel = /** @class */ (function (_super) {
314
276
  GroupNodeModel.prototype.getHistoryData = function () {
315
277
  var data = _super.prototype.getData.call(this);
316
278
  data.children = __spread(this.children);
279
+ data.isGroup = true;
317
280
  var properties = data.properties;
318
281
  delete properties.groupAddable;
319
282
  if (properties.isFolded) { // 如果分组被折叠
@@ -328,6 +291,12 @@ var GroupNodeModel = /** @class */ (function (_super) {
328
291
  GroupNodeModel.prototype.isAllowAppendIn = function (nodeData) {
329
292
  return true;
330
293
  };
294
+ /**
295
+ * 当groupA被添加到groupB中时,将groupB及groupB所属的group的zIndex减1
296
+ */
297
+ GroupNodeModel.prototype.toBack = function () {
298
+ this.zIndex--;
299
+ };
331
300
  return GroupNodeModel;
332
301
  }(NodeResize_1.RectResize.model));
333
302
  var GroupNode = /** @class */ (function (_super) {
@@ -339,7 +308,7 @@ var GroupNode = /** @class */ (function (_super) {
339
308
  var _a = this.props.model, resizable = _a.resizable, properties = _a.properties;
340
309
  return resizable && !properties.isFolded ? _super.prototype.getControlGroup.call(this) : null;
341
310
  };
342
- GroupNode.prototype.getAddAbleShape = function () {
311
+ GroupNode.prototype.getAddableShape = function () {
343
312
  var _a = this.props.model, width = _a.width, height = _a.height, x = _a.x, y = _a.y, radius = _a.radius, properties = _a.properties;
344
313
  if (!properties.groupAddable)
345
314
  return null;
@@ -385,7 +354,7 @@ var GroupNode = /** @class */ (function (_super) {
385
354
  };
386
355
  GroupNode.prototype.getResizeShape = function () {
387
356
  return core_1.h('g', {}, [
388
- this.getAddAbleShape(),
357
+ this.getAddableShape(),
389
358
  _super.prototype.getResizeShape.call(this),
390
359
  this.getFoldIcon(),
391
360
  ]);
@@ -1,32 +1,15 @@
1
1
  "use strict";
2
- var __read = (this && this.__read) || function (o, n) {
3
- var m = typeof Symbol === "function" && o[Symbol.iterator];
4
- if (!m) return o;
5
- var i = m.call(o), r, ar = [], e;
6
- try {
7
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
8
- }
9
- catch (error) { e = { error: error }; }
10
- finally {
11
- try {
12
- if (r && !r.done && (m = i["return"])) m.call(i);
13
- }
14
- finally { if (e) throw e.error; }
15
- }
16
- return ar;
17
- };
18
- var __spread = (this && this.__spread) || function () {
19
- for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i]));
20
- return ar;
21
- };
22
2
  Object.defineProperty(exports, "__esModule", { value: true });
23
3
  exports.GroupNode = exports.Group = void 0;
24
4
  var GroupNode_1 = require("./GroupNode");
25
5
  exports.GroupNode = GroupNode_1.default;
6
+ var DEFAULT_TOP_Z_INDEX = -1000;
7
+ var DEFAULT_BOTTOM_Z_INDEX = -10000;
26
8
  var Group = /** @class */ (function () {
27
9
  function Group(_a) {
28
10
  var _this = this;
29
11
  var lf = _a.lf;
12
+ this.topGroupZIndex = DEFAULT_BOTTOM_Z_INDEX;
30
13
  this.nodeGroupMap = new Map();
31
14
  this.graphRendered = function (data) {
32
15
  // 如果节点
@@ -51,7 +34,9 @@ var Group = /** @class */ (function () {
51
34
  preGroup.setAllowAppendChild(false);
52
35
  }
53
36
  // 然后再判断这个节点是否在某个group中,如果在,则将其添加到对应的group中
54
- var group = _this.getGroup(_this.lf.getNodeModelById(data.id));
37
+ var nodeModel = _this.lf.getNodeModelById(data.id);
38
+ var bounds = nodeModel.getBounds();
39
+ var group = _this.getGroup(bounds, data);
55
40
  if (!group)
56
41
  return;
57
42
  var isAllowAppendIn = group.isAllowAppendIn(data);
@@ -62,20 +47,26 @@ var Group = /** @class */ (function () {
62
47
  });
63
48
  return;
64
49
  }
65
- if (data.id !== group.id) {
66
- group.addChild(data.id);
67
- _this.nodeGroupMap.set(data.id, group.id);
68
- group.setAllowAppendChild(false);
69
- }
70
- else if (data.children && data.children.length > 0) {
71
- // 表示当前添加的节点是一个新增的group
50
+ group.addChild(data.id);
51
+ _this.nodeGroupMap.set(data.id, group.id);
52
+ group.setAllowAppendChild(false);
53
+ // 如果这个节点是分组,那么将其子节点也记录下来
54
+ if (nodeModel.isGroup) {
72
55
  data.children.forEach(function (nodeId) {
73
56
  _this.nodeGroupMap.set(nodeId, data.id);
74
57
  });
58
+ _this.nodeSelected({ data: data });
75
59
  }
76
60
  };
77
61
  this.deleteGroupChild = function (_a) {
78
62
  var data = _a.data;
63
+ // 如果删除的是分组节点,则同时删除分组的子节点
64
+ if (data.children) {
65
+ data.children.forEach(function (nodeId) {
66
+ _this.nodeGroupMap.delete(nodeId);
67
+ _this.lf.deleteNode(nodeId);
68
+ });
69
+ }
79
70
  var groupId = _this.nodeGroupMap.get(data.id);
80
71
  if (groupId) {
81
72
  var group = _this.lf.getNodeModelById(groupId);
@@ -86,7 +77,8 @@ var Group = /** @class */ (function () {
86
77
  this.setActiveGroup = function (_a) {
87
78
  var data = _a.data;
88
79
  var nodeModel = _this.lf.getNodeModelById(data.id);
89
- var newGroup = _this.getGroup(nodeModel);
80
+ var bounds = nodeModel.getBounds();
81
+ var newGroup = _this.getGroup(bounds, data);
90
82
  if (_this.activeGroup) {
91
83
  _this.activeGroup.setAllowAppendChild(false);
92
84
  }
@@ -99,6 +91,46 @@ var Group = /** @class */ (function () {
99
91
  _this.activeGroup = newGroup;
100
92
  _this.activeGroup.setAllowAppendChild(true);
101
93
  };
94
+ /**
95
+ * 1. 分组节点默认在普通节点下面。
96
+ * 2. 分组节点被选中后,会将分组节点以及其内部的其他分组节点放到其余分组节点的上面。
97
+ * 3. 分组节点取消选中后,不会将分组节点重置为原来的高度。
98
+ * 4. 由于LogicFlow核心目标是支持用户手动绘制流程图,所以不考虑一张流程图超过1000个分组节点的情况。
99
+ */
100
+ this.nodeSelected = function (_a) {
101
+ var data = _a.data;
102
+ var nodeModel = _this.lf.getNodeModelById(data.id);
103
+ _this.toFrontGroup(nodeModel);
104
+ // 重置所有的group zIndex,防止group节点zIndex增长为正。
105
+ if (_this.topGroupZIndex > DEFAULT_TOP_Z_INDEX) {
106
+ _this.topGroupZIndex = DEFAULT_BOTTOM_Z_INDEX;
107
+ var allGroups = _this.lf.graphModel.nodes
108
+ .filter(function (node) { return node.isGroup; })
109
+ .sort(function (a, b) { return a.zIndex - b.zIndex; });
110
+ var preZIndex = 0;
111
+ for (var i = 0; i < allGroups.length; i++) {
112
+ var group = allGroups[i];
113
+ if (group.zIndex !== preZIndex) {
114
+ _this.topGroupZIndex++;
115
+ preZIndex = group.zIndex;
116
+ }
117
+ group.setZIndex(_this.topGroupZIndex);
118
+ }
119
+ }
120
+ };
121
+ this.toFrontGroup = function (model) {
122
+ if (!model || !model.isGroup) {
123
+ return;
124
+ }
125
+ _this.topGroupZIndex++;
126
+ model.setZIndex(_this.topGroupZIndex);
127
+ if (model.children) {
128
+ model.children.forEach(function (nodeId) {
129
+ var node = _this.lf.getNodeModelById(nodeId);
130
+ _this.toFrontGroup(node);
131
+ });
132
+ }
133
+ };
102
134
  lf.register(GroupNode_1.default);
103
135
  this.lf = lf;
104
136
  lf.graphModel.addNodeMoveRules(function (model, deltaX, deltaY) {
@@ -108,34 +140,23 @@ var Group = /** @class */ (function () {
108
140
  return true;
109
141
  }
110
142
  var groupModel = lf.getNodeModelById(_this.nodeGroupMap.get(model.id));
111
- var allowMove = true;
112
- if (groupModel && groupModel.isRestrict) {
113
- // 如果移动的节点存在分组中,且这个分组禁止子节点移出去。
143
+ if (groupModel && groupModel.isRestrict) { // 如果移动的节点存在分组中,且这个分组禁止子节点移出去。
114
144
  var _a = model.getBounds(), x1 = _a.x1, y1 = _a.y1, x2 = _a.x2, y2 = _a.y2;
115
- allowMove = groupModel.isAllowMoveTo({
145
+ var r = groupModel.isAllowMoveTo({
116
146
  x1: x1 + deltaX,
117
147
  y1: y1 + deltaY,
118
148
  x2: x2 + deltaX,
119
149
  y2: y2 + deltaY,
120
150
  });
151
+ return r;
121
152
  }
122
- if (model.isGroup) {
123
- // 如果移动的是分组,那么分组的子节点也跟着移动。
124
- if (allowMove === true) {
125
- lf.graphModel.moveNodes(__spread(model.getChildren()), deltaX, deltaY, true);
126
- }
127
- else if (typeof allowMove !== 'boolean') {
128
- lf.graphModel.moveNodes(__spread(model.getChildren()), allowMove.x ? deltaX : 0, allowMove.y ? deltaY : 0, true);
129
- }
130
- }
131
- return allowMove;
153
+ return true;
132
154
  });
133
155
  lf.graphModel.group = this;
134
- lf.on('node:add', this.appendNodeToGroup);
156
+ lf.on('node:add,node:drop', this.appendNodeToGroup);
135
157
  lf.on('node:delete', this.deleteGroupChild);
136
- lf.on('node:drop', this.appendNodeToGroup);
137
- lf.on('node:dnd-drag', this.setActiveGroup);
138
- lf.on('node:drag', this.setActiveGroup);
158
+ lf.on('node:dnd-drag,node:drag', this.setActiveGroup);
159
+ lf.on('node:click', this.nodeSelected);
139
160
  lf.on('graph:rendered', this.graphRendered);
140
161
  }
141
162
  /**
@@ -157,33 +178,22 @@ var Group = /** @class */ (function () {
157
178
  };
158
179
  /**
159
180
  * 获取自定位置其所属分组
181
+ * 当分组重合时,优先返回最上层的分组
160
182
  */
161
- Group.prototype.getGroup = function (nodeModel) {
162
- if (nodeModel.nestable === false) {
163
- return null;
164
- }
165
- var bounds = nodeModel.getBounds();
183
+ Group.prototype.getGroup = function (bounds, nodeData) {
166
184
  var nodes = this.lf.graphModel.nodes;
167
- var selectedModel = null;
168
- for (var i = 0; i < nodes.length; i++) {
169
- var model = nodes[i];
170
- if (model !== nodeModel && model.isGroup && model.isInRange(bounds)) {
171
- if (selectedModel) {
172
- if (selectedModel.zIndex > model.zIndex) {
173
- selectedModel = model;
174
- }
175
- else if (selectedModel.zIndex === model.zIndex) {
176
- if (!model.isInRange(selectedModel.getBounds())) {
177
- selectedModel = model;
178
- }
179
- }
180
- }
181
- else {
182
- selectedModel = model;
183
- }
185
+ var groups = nodes.filter(function (node) { return node.isGroup && node.isInRange(bounds) && node.id !== nodeData.id; });
186
+ if (groups.length === 0)
187
+ return;
188
+ if (groups.length === 1)
189
+ return groups[0];
190
+ var topGroup = groups[groups.length - 1];
191
+ for (var i = groups.length - 2; i >= 0; i--) {
192
+ if (groups[i].zIndex > topGroup.zIndex) {
193
+ topGroup = groups[i];
184
194
  }
185
195
  }
186
- return selectedModel;
196
+ return topGroup;
187
197
  };
188
198
  /**
189
199
  * 获取某个节点所属的groupModel
@@ -164,6 +164,16 @@
164
164
  background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAACL0lEQVRoQ+1YT2vUQBT/vS+Smc3u0ZtfwA+hUKEttIIVbMEWrGAL3UItqKCCCipooS3Ynu29ePfqLcnO5Nov0NsrWbc0myxtJpNmGZw9LZk37/3+vCTzQnD8R47jhycwbQe9A94BSwV8C1kKaL3dO2AtoWWC/8+BMJB9ItwHcM6MX0mqtm1EzOU7Y8bvJFV9k3zGDnSFPAVw76oIb8ZavzIpehnbE+Ilg/J7/8Za3THJVYfAHwB3x4owXsSpemNSuCs6zwEu7rl9AmEgt4hQspkIa5FS76uQCKV8RoxSLDP6pi1p7EAGsCvEBkA7ZbC0EuvBp+tI9IR4yqBSDIE3Iq13qwiQj6lFYEgikOsgvC4VJDyJlfo6CUg3kI9BmLBG67EevDUFn8XXJpBt7km5yox3xcIMfpRo/SN/PZRygRhj17J1JqwmSn2oA96awL926iwD/LEIgJjmo3RwMCQadGaZePh/3H5ejrT+XBd8IwSGJKRcAuPLhHZ6mIkMxlFpjbEUp+qbDfjGCGSJQiEWCfS9CiAmLCZK7VWJvSnG6h4oJu8FnTkm3r+uKDHNReng8CZgVdcbJTBqpxkwfk4EQJiJlTquCq5KnCeQV8npFnL6Jnb6Mer0i8zpo4TThzmnj9OjGXardDBrZqDZbmMmdnukdH6oL3xWOTG1vNh6oxn7AYB2PqtUOWC1GdP4Ya5N8I0ONG0Dv6znHZiW8t6BaSvvHfAONKSAf4w2JGTtNBey0xBAkjSEzwAAAABJRU5ErkJggg==');
165
165
  }
166
166
 
167
+ .lf-mini-map-no-header {
168
+ padding-top: 0;
169
+ }
170
+ .lf-mini-map-no-header .lf-mini-map-header {
171
+ display: none;
172
+ }
173
+ .lf-mini-map-no-close-icon .lf-mini-map-close{
174
+ display: none;
175
+ }
176
+
167
177
  /* 节点调整 */
168
178
 
169
179
  .lf-resize-control-0{
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  /**
3
3
  * 自动布局插件
4
- * 依赖flow-path插件
4
+ * 依赖flowPath插件
5
5
  * 未完善
6
6
  */
7
7
  var __assign = (this && this.__assign) || function () {
@@ -22,16 +22,19 @@ declare class Control extends Component<IProps> {
22
22
  deltaX: any;
23
23
  deltaY: any;
24
24
  }) => void;
25
- getResize: ({ index, deltaX, deltaY, width, height, pct }: {
25
+ getResize: ({ index, deltaX, deltaY, width, height, PCTResizeInfo, pct }: {
26
26
  index: any;
27
27
  deltaX: any;
28
28
  deltaY: any;
29
29
  width: any;
30
30
  height: any;
31
+ PCTResizeInfo: any;
31
32
  pct?: number;
32
33
  }) => {
33
34
  width: any;
34
35
  height: any;
36
+ deltaX: any;
37
+ deltaY: any;
35
38
  };
36
39
  updateRect: ({ deltaX, deltaY }: {
37
40
  deltaX: any;
@@ -51,16 +51,70 @@ var Control = /** @class */ (function (_super) {
51
51
  _this.updatePosition = function (_a) {
52
52
  var deltaX = _a.deltaX, deltaY = _a.deltaY;
53
53
  var _b = _this.nodeModel, x = _b.x, y = _b.y;
54
+ _this.nodeModel.x = x + deltaX / 2;
55
+ _this.nodeModel.y = y + deltaY / 2;
54
56
  _this.nodeModel.moveText(deltaX / 2, deltaY / 2);
55
- _this.nodeModel.updateAttributes({
56
- x: x + deltaX / 2,
57
- y: y + deltaY / 2,
58
- });
59
57
  };
60
58
  // 计算control拖动后,节点的宽高
61
59
  _this.getResize = function (_a) {
62
- var index = _a.index, deltaX = _a.deltaX, deltaY = _a.deltaY, width = _a.width, height = _a.height, _b = _a.pct, pct = _b === void 0 ? 1 : _b;
63
- var resize = { width: width, height: height };
60
+ var index = _a.index, deltaX = _a.deltaX, deltaY = _a.deltaY, width = _a.width, height = _a.height, PCTResizeInfo = _a.PCTResizeInfo, _b = _a.pct, pct = _b === void 0 ? 1 : _b;
61
+ var resize = { width: width, height: height, deltaX: deltaX, deltaY: deltaY };
62
+ if (PCTResizeInfo) {
63
+ var sensitivity = 4; // 越低越灵敏
64
+ var deltaScale = 0;
65
+ var combineDelta = 0;
66
+ switch (index) {
67
+ case 0:
68
+ combineDelta = (deltaX * -1 - deltaY) / sensitivity;
69
+ break;
70
+ case 1:
71
+ combineDelta = (deltaX - deltaY) / sensitivity;
72
+ break;
73
+ case 2:
74
+ combineDelta = (deltaX + deltaY) / sensitivity;
75
+ break;
76
+ case 3:
77
+ combineDelta = (deltaX * -1 + deltaY) / sensitivity;
78
+ break;
79
+ default:
80
+ break;
81
+ }
82
+ if (combineDelta !== 0) {
83
+ deltaScale = Math.round((combineDelta / PCTResizeInfo.ResizeBasis.basisHeight)
84
+ * 100000) / 1000;
85
+ }
86
+ PCTResizeInfo.ResizePCT.widthPCT = Math.max(Math.min(PCTResizeInfo.ResizePCT.widthPCT + deltaScale, PCTResizeInfo.ScaleLimit.maxScaleLimit), PCTResizeInfo.ScaleLimit.minScaleLimit);
87
+ PCTResizeInfo.ResizePCT.hightPCT = Math.max(Math.min(PCTResizeInfo.ResizePCT.hightPCT + deltaScale, PCTResizeInfo.ScaleLimit.maxScaleLimit), PCTResizeInfo.ScaleLimit.minScaleLimit);
88
+ var spcWidth = Math.round((PCTResizeInfo.ResizePCT.widthPCT
89
+ * PCTResizeInfo.ResizeBasis.basisWidth) / 100);
90
+ var spcHeight = Math.round((PCTResizeInfo.ResizePCT.hightPCT
91
+ * PCTResizeInfo.ResizeBasis.basisHeight) / 100);
92
+ switch (index) {
93
+ case 0:
94
+ deltaX = width - spcWidth;
95
+ deltaY = height - spcHeight;
96
+ break;
97
+ case 1:
98
+ deltaX = spcWidth - width;
99
+ deltaY = height - spcHeight;
100
+ break;
101
+ case 2:
102
+ deltaX = spcWidth - width;
103
+ deltaY = spcHeight - height;
104
+ break;
105
+ case 3:
106
+ deltaX = width - spcWidth;
107
+ deltaY = spcHeight - height;
108
+ break;
109
+ default:
110
+ break;
111
+ }
112
+ resize.width = spcWidth;
113
+ resize.height = spcHeight;
114
+ resize.deltaX = deltaX / pct;
115
+ resize.deltaY = deltaY / pct;
116
+ return resize;
117
+ }
64
118
  switch (index) {
65
119
  case 0:
66
120
  resize.width = width - deltaX * pct;
@@ -86,7 +140,7 @@ var Control = /** @class */ (function (_super) {
86
140
  // 矩形更新
87
141
  _this.updateRect = function (_a) {
88
142
  var deltaX = _a.deltaX, deltaY = _a.deltaY;
89
- var _b = _this.nodeModel, id = _b.id, x = _b.x, y = _b.y, width = _b.width, height = _b.height, radius = _b.radius;
143
+ var _b = _this.nodeModel, id = _b.id, x = _b.x, y = _b.y, width = _b.width, height = _b.height, radius = _b.radius, PCTResizeInfo = _b.PCTResizeInfo;
90
144
  // 更新中心点位置,更新文案位置
91
145
  var index = _this.index;
92
146
  var size = _this.getResize({
@@ -95,6 +149,7 @@ var Control = /** @class */ (function (_super) {
95
149
  deltaY: deltaY,
96
150
  width: width,
97
151
  height: height,
152
+ PCTResizeInfo: PCTResizeInfo,
98
153
  pct: 1,
99
154
  });
100
155
  // 限制放大缩小的最大最小范围
@@ -107,18 +162,16 @@ var Control = /** @class */ (function (_super) {
107
162
  _this.dragHandler.cancelDrag();
108
163
  return;
109
164
  }
110
- _this.updatePosition({ deltaX: deltaX, deltaY: deltaY });
165
+ _this.updatePosition({ deltaX: size.deltaX, deltaY: size.deltaY });
111
166
  // 更新宽高
167
+ _this.nodeModel.width = size.width;
168
+ _this.nodeModel.height = size.height;
112
169
  _this.nodeModel.setProperties({
113
170
  nodeSize: {
114
171
  width: size.width,
115
172
  height: size.height,
116
173
  },
117
174
  });
118
- _this.nodeModel.updateAttributes({
119
- width: size.width,
120
- height: size.height,
121
- });
122
175
  var edges = _this.getNodeEdges(id);
123
176
  var beforeNode = {
124
177
  x: x,
@@ -156,7 +209,7 @@ var Control = /** @class */ (function (_super) {
156
209
  // 椭圆更新
157
210
  _this.updateEllipse = function (_a) {
158
211
  var deltaX = _a.deltaX, deltaY = _a.deltaY;
159
- var _b = _this.nodeModel, id = _b.id, rx = _b.rx, ry = _b.ry, x = _b.x, y = _b.y;
212
+ var _b = _this.nodeModel, id = _b.id, rx = _b.rx, ry = _b.ry, x = _b.x, y = _b.y, PCTResizeInfo = _b.PCTResizeInfo;
160
213
  var index = _this.index;
161
214
  var width = rx;
162
215
  var height = ry;
@@ -166,6 +219,7 @@ var Control = /** @class */ (function (_super) {
166
219
  deltaY: deltaY,
167
220
  width: width,
168
221
  height: height,
222
+ PCTResizeInfo: PCTResizeInfo,
169
223
  pct: 1 / 2,
170
224
  });
171
225
  // 限制放大缩小的最大最小范围
@@ -178,7 +232,7 @@ var Control = /** @class */ (function (_super) {
178
232
  return;
179
233
  }
180
234
  // 更新中心点位置,更新文案位置
181
- _this.updatePosition({ deltaX: deltaX, deltaY: deltaY });
235
+ _this.updatePosition({ deltaX: size.deltaX, deltaY: size.deltaY });
182
236
  // 更新rx ry,宽高为计算属性自动更新
183
237
  // @ts-ignore
184
238
  _this.nodeModel.rx = size.width;
@@ -220,7 +274,7 @@ var Control = /** @class */ (function (_super) {
220
274
  // 菱形更新
221
275
  _this.updateDiamond = function (_a) {
222
276
  var deltaX = _a.deltaX, deltaY = _a.deltaY;
223
- var _b = _this.nodeModel, id = _b.id, rx = _b.rx, ry = _b.ry, x = _b.x, y = _b.y;
277
+ var _b = _this.nodeModel, id = _b.id, rx = _b.rx, ry = _b.ry, x = _b.x, y = _b.y, PCTResizeInfo = _b.PCTResizeInfo;
224
278
  var index = _this.index;
225
279
  var width = rx;
226
280
  var height = ry;
@@ -230,6 +284,7 @@ var Control = /** @class */ (function (_super) {
230
284
  deltaY: deltaY,
231
285
  width: width,
232
286
  height: height,
287
+ PCTResizeInfo: PCTResizeInfo,
233
288
  pct: 1 / 2,
234
289
  });
235
290
  // 限制放大缩小的最大最小范围
@@ -242,7 +297,7 @@ var Control = /** @class */ (function (_super) {
242
297
  return;
243
298
  }
244
299
  // 更新中心点位置,更新文案位置
245
- _this.updatePosition({ deltaX: deltaX, deltaY: deltaY });
300
+ _this.updatePosition({ deltaX: size.deltaX, deltaY: size.deltaY });
246
301
  // 更新rx ry,宽高为计算属性自动更新
247
302
  // @ts-ignore
248
303
  _this.nodeModel.rx = size.width;
@@ -1,7 +1,8 @@
1
1
  import { h, DiamondNode, DiamondNodeModel } from '@logicflow/core';
2
2
  declare class DiamondResizeModel extends DiamondNodeModel {
3
+ private PCTResizeInfo;
4
+ constructor(data: any, graphModel: any);
3
5
  initNodeData(data: any): void;
4
- init(): void;
5
6
  getOutlineStyle(): import("@logicflow/core/types/constant/DefaultTheme").OutlineTheme;
6
7
  getResizeOutlineStyle(): {
7
8
  stroke: string;
@@ -14,6 +15,7 @@ declare class DiamondResizeModel extends DiamondNodeModel {
14
15
  fill: string;
15
16
  stroke: string;
16
17
  };
18
+ enableProportionResize(turnOn?: boolean): void;
17
19
  }
18
20
  declare class DiamondResizeView extends DiamondNode {
19
21
  getControlGroup(): h.JSX.Element;