@logicflow/extension 1.1.28 → 1.1.30

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 (55) hide show
  1. package/cjs/NodeResize/Control/Control.js +72 -13
  2. package/cjs/NodeResize/Node/DiamondResize.js +16 -0
  3. package/cjs/NodeResize/Node/EllipseResize.js +16 -0
  4. package/cjs/NodeResize/Node/HtmlResize.js +16 -0
  5. package/cjs/NodeResize/Node/RectResize.js +16 -0
  6. package/cjs/materials/curved-edge/index.js +47 -40
  7. package/cjs/materials/group/GroupNode.js +11 -4
  8. package/cjs/materials/group/index.js +75 -19
  9. package/cjs/turbo-adapter/index.js +4 -6
  10. package/es/NodeResize/Control/Control.d.ts +4 -1
  11. package/es/NodeResize/Control/Control.js +72 -13
  12. package/es/NodeResize/Node/DiamondResize.d.ts +2 -0
  13. package/es/NodeResize/Node/DiamondResize.js +16 -0
  14. package/es/NodeResize/Node/EllipseResize.d.ts +2 -0
  15. package/es/NodeResize/Node/EllipseResize.js +16 -0
  16. package/es/NodeResize/Node/HtmlResize.d.ts +2 -0
  17. package/es/NodeResize/Node/HtmlResize.js +16 -0
  18. package/es/NodeResize/Node/RectResize.d.ts +2 -0
  19. package/es/NodeResize/Node/RectResize.js +16 -0
  20. package/es/materials/curved-edge/index.d.ts +7 -6
  21. package/es/materials/curved-edge/index.js +47 -39
  22. package/es/materials/group/GroupNode.d.ts +5 -1
  23. package/es/materials/group/GroupNode.js +11 -4
  24. package/es/materials/group/index.d.ts +13 -1
  25. package/es/materials/group/index.js +75 -19
  26. package/es/turbo-adapter/index.js +4 -6
  27. package/lib/AutoLayout.js +1 -1
  28. package/lib/BpmnAdapter.js +1 -1
  29. package/lib/BpmnElement.js +1 -1
  30. package/lib/ContextMenu.js +1 -1
  31. package/lib/Control.js +1 -1
  32. package/lib/CurvedEdge.js +1 -1
  33. package/lib/DndPanel.js +1 -1
  34. package/lib/FlowPath.js +1 -1
  35. package/lib/Group.js +1 -1
  36. package/lib/Highlight.js +1 -1
  37. package/lib/InsertNodeInPolyline.js +1 -1
  38. package/lib/Menu.js +1 -1
  39. package/lib/MiniMap.js +1 -1
  40. package/lib/NodeResize.js +1 -1
  41. package/lib/RectLabelNode.js +1 -1
  42. package/lib/SelectionSelect.js +1 -1
  43. package/lib/Snapshot.js +1 -1
  44. package/lib/TurboAdapter.js +1 -1
  45. package/lib/lfJson2Xml.js +1 -1
  46. package/lib/lfXml2Json.js +1 -1
  47. package/package.json +2 -2
  48. package/types/NodeResize/Control/Control.d.ts +4 -1
  49. package/types/NodeResize/Node/DiamondResize.d.ts +2 -0
  50. package/types/NodeResize/Node/EllipseResize.d.ts +2 -0
  51. package/types/NodeResize/Node/HtmlResize.d.ts +2 -0
  52. package/types/NodeResize/Node/RectResize.d.ts +2 -0
  53. package/types/materials/curved-edge/index.d.ts +7 -6
  54. package/types/materials/group/GroupNode.d.ts +5 -1
  55. package/types/materials/group/index.d.ts +13 -1
@@ -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;
@@ -57,8 +57,64 @@ var Control = /** @class */ (function (_super) {
57
57
  };
58
58
  // 计算control拖动后,节点的宽高
59
59
  _this.getResize = function (_a) {
60
- 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;
61
- 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 combineDleta = 0;
66
+ switch (index) {
67
+ case 0:
68
+ combineDleta = (deltaX * -1 - deltaY) / sensitivity;
69
+ break;
70
+ case 1:
71
+ combineDleta = (deltaX - deltaY) / sensitivity;
72
+ break;
73
+ case 2:
74
+ combineDleta = (deltaX + deltaY) / sensitivity;
75
+ break;
76
+ case 3:
77
+ combineDleta = (deltaX * -1 + deltaY) / sensitivity;
78
+ break;
79
+ default:
80
+ break;
81
+ }
82
+ if (combineDleta !== 0) {
83
+ deltaScale = Math.round((combineDleta / 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
+ }
62
118
  switch (index) {
63
119
  case 0:
64
120
  resize.width = width - deltaX * pct;
@@ -69,7 +125,7 @@ var Control = /** @class */ (function (_super) {
69
125
  resize.height = height - deltaY * pct;
70
126
  break;
71
127
  case 2:
72
- resize.width = width + deltaX;
128
+ resize.width = width + deltaX * pct;
73
129
  resize.height = height + deltaY * pct;
74
130
  break;
75
131
  case 3:
@@ -84,7 +140,7 @@ var Control = /** @class */ (function (_super) {
84
140
  // 矩形更新
85
141
  _this.updateRect = function (_a) {
86
142
  var deltaX = _a.deltaX, deltaY = _a.deltaY;
87
- 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;
88
144
  // 更新中心点位置,更新文案位置
89
145
  var index = _this.index;
90
146
  var size = _this.getResize({
@@ -93,6 +149,7 @@ var Control = /** @class */ (function (_super) {
93
149
  deltaY: deltaY,
94
150
  width: width,
95
151
  height: height,
152
+ PCTResizeInfo: PCTResizeInfo,
96
153
  pct: 1,
97
154
  });
98
155
  // 限制放大缩小的最大最小范围
@@ -105,7 +162,7 @@ var Control = /** @class */ (function (_super) {
105
162
  _this.dragHandler.cancelDrag();
106
163
  return;
107
164
  }
108
- _this.updatePosition({ deltaX: deltaX, deltaY: deltaY });
165
+ _this.updatePosition({ deltaX: size.deltaX, deltaY: size.deltaY });
109
166
  // 更新宽高
110
167
  _this.nodeModel.width = size.width;
111
168
  _this.nodeModel.height = size.height;
@@ -152,7 +209,7 @@ var Control = /** @class */ (function (_super) {
152
209
  // 椭圆更新
153
210
  _this.updateEllipse = function (_a) {
154
211
  var deltaX = _a.deltaX, deltaY = _a.deltaY;
155
- 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;
156
213
  var index = _this.index;
157
214
  var width = rx;
158
215
  var height = ry;
@@ -162,6 +219,7 @@ var Control = /** @class */ (function (_super) {
162
219
  deltaY: deltaY,
163
220
  width: width,
164
221
  height: height,
222
+ PCTResizeInfo: PCTResizeInfo,
165
223
  pct: 1 / 2,
166
224
  });
167
225
  // 限制放大缩小的最大最小范围
@@ -174,12 +232,12 @@ var Control = /** @class */ (function (_super) {
174
232
  return;
175
233
  }
176
234
  // 更新中心点位置,更新文案位置
177
- _this.updatePosition({ deltaX: deltaX, deltaY: deltaY });
235
+ _this.updatePosition({ deltaX: size.deltaX, deltaY: size.deltaY });
178
236
  // 更新rx ry,宽高为计算属性自动更新
179
237
  // @ts-ignore
180
- _this.nodeModel.rx = _this.nodeModel.rx + deltaX / 2;
238
+ _this.nodeModel.rx = size.width;
181
239
  // @ts-ignore
182
- _this.nodeModel.ry = _this.nodeModel.ry + deltaY / 2;
240
+ _this.nodeModel.ry = size.height;
183
241
  _this.nodeModel.setProperties({
184
242
  nodeSize: {
185
243
  rx: size.width,
@@ -216,7 +274,7 @@ var Control = /** @class */ (function (_super) {
216
274
  // 菱形更新
217
275
  _this.updateDiamond = function (_a) {
218
276
  var deltaX = _a.deltaX, deltaY = _a.deltaY;
219
- 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;
220
278
  var index = _this.index;
221
279
  var width = rx;
222
280
  var height = ry;
@@ -226,6 +284,7 @@ var Control = /** @class */ (function (_super) {
226
284
  deltaY: deltaY,
227
285
  width: width,
228
286
  height: height,
287
+ PCTResizeInfo: PCTResizeInfo,
229
288
  pct: 1 / 2,
230
289
  });
231
290
  // 限制放大缩小的最大最小范围
@@ -238,12 +297,12 @@ var Control = /** @class */ (function (_super) {
238
297
  return;
239
298
  }
240
299
  // 更新中心点位置,更新文案位置
241
- _this.updatePosition({ deltaX: deltaX, deltaY: deltaY });
300
+ _this.updatePosition({ deltaX: size.deltaX, deltaY: size.deltaY });
242
301
  // 更新rx ry,宽高为计算属性自动更新
243
302
  // @ts-ignore
244
- _this.nodeModel.rx = _this.nodeModel.rx + deltaX / 2;
303
+ _this.nodeModel.rx = size.width;
245
304
  // @ts-ignore
246
- _this.nodeModel.ry = _this.nodeModel.ry + deltaY / 2;
305
+ _this.nodeModel.ry = size.height;
247
306
  _this.nodeModel.setProperties({
248
307
  nodeSize: {
249
308
  rx: size.width,
@@ -1,5 +1,6 @@
1
1
  import { h, DiamondNode, DiamondNodeModel } from '@logicflow/core';
2
2
  declare class DiamondResizeModel extends DiamondNodeModel {
3
+ private PCTResizeInfo;
3
4
  constructor(data: any, graphModel: any);
4
5
  initNodeData(data: any): void;
5
6
  getOutlineStyle(): import("@logicflow/core/types/constant/DefaultTheme").OutlineTheme;
@@ -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;
@@ -70,6 +70,22 @@ var DiamondResizeModel = /** @class */ (function (_super) {
70
70
  stroke: '#000000',
71
71
  };
72
72
  };
73
+ // 该方法需要在重设宽高和最大、最小限制后被调用,不建议在 initNodeData() 方法中使用
74
+ DiamondResizeModel.prototype.enableProportionResize = function (turnOn) {
75
+ if (turnOn === void 0) { turnOn = true; }
76
+ if (turnOn) {
77
+ var ResizePCT = { widthPCT: 100, hightPCT: 100 };
78
+ var ResizeBasis = { basisWidth: this.rx, basisHeight: this.ry };
79
+ var ScaleLimit = {
80
+ maxScaleLimit: Math.min((this.maxWidth / (this.rx * 2)) * 100, (this.maxHeight / (this.ry * 2)) * 100),
81
+ minScaleLimit: Math.max((this.minWidth / (this.rx * 2)) * 100, (this.minHeight / (this.ry * 2)) * 100),
82
+ };
83
+ this.PCTResizeInfo = { ResizePCT: ResizePCT, ResizeBasis: ResizeBasis, ScaleLimit: ScaleLimit };
84
+ }
85
+ else {
86
+ delete this.PCTResizeInfo;
87
+ }
88
+ };
73
89
  return DiamondResizeModel;
74
90
  }(DiamondNodeModel));
75
91
  var DiamondResizeView = /** @class */ (function (_super) {
@@ -1,5 +1,6 @@
1
1
  import { h, EllipseNode, EllipseNodeModel } from '@logicflow/core';
2
2
  declare class EllipseResizeModel extends EllipseNodeModel {
3
+ private PCTResizeInfo;
3
4
  constructor(data: any, graphModel: any);
4
5
  initNodeData(data: any): void;
5
6
  getOutlineStyle(): import("@logicflow/core/types/constant/DefaultTheme").OutlineTheme;
@@ -14,6 +15,7 @@ declare class EllipseResizeModel extends EllipseNodeModel {
14
15
  fill: string;
15
16
  stroke: string;
16
17
  };
18
+ enableProportionResize(turnOn?: boolean): void;
17
19
  }
18
20
  declare class EllipseResizeView extends EllipseNode {
19
21
  getControlGroup(): h.JSX.Element;
@@ -57,6 +57,22 @@ var EllipseResizeModel = /** @class */ (function (_super) {
57
57
  stroke: '#000000',
58
58
  };
59
59
  };
60
+ // 该方法需要在重设宽高和最大、最小限制后被调用,不建议在 initNodeData() 方法中使用
61
+ EllipseResizeModel.prototype.enableProportionResize = function (turnOn) {
62
+ if (turnOn === void 0) { turnOn = true; }
63
+ if (turnOn) {
64
+ var ResizePCT = { widthPCT: 100, hightPCT: 100 };
65
+ var ResizeBasis = { basisWidth: this.rx, basisHeight: this.ry };
66
+ var ScaleLimit = {
67
+ maxScaleLimit: Math.min((this.maxWidth / (this.rx * 2)) * 100, (this.maxHeight / (this.ry * 2)) * 100),
68
+ minScaleLimit: Math.max((this.minWidth / (this.rx * 2)) * 100, (this.minHeight / (this.ry * 2)) * 100),
69
+ };
70
+ this.PCTResizeInfo = { ResizePCT: ResizePCT, ResizeBasis: ResizeBasis, ScaleLimit: ScaleLimit };
71
+ }
72
+ else {
73
+ delete this.PCTResizeInfo;
74
+ }
75
+ };
60
76
  return EllipseResizeModel;
61
77
  }(EllipseNodeModel));
62
78
  var EllipseResizeView = /** @class */ (function (_super) {
@@ -1,5 +1,6 @@
1
1
  import { h, HtmlNode, HtmlNodeModel } from '@logicflow/core';
2
2
  declare class HtmlResizeModel extends HtmlNodeModel {
3
+ private PCTResizeInfo;
3
4
  constructor(data: any, graphModel: any);
4
5
  initNodeData(data: any): void;
5
6
  getOutlineStyle(): import("@logicflow/core/types/constant/DefaultTheme").OutlineTheme;
@@ -14,6 +15,7 @@ declare class HtmlResizeModel extends HtmlNodeModel {
14
15
  fill: string;
15
16
  stroke: string;
16
17
  };
18
+ enableProportionResize(turnOn?: boolean): void;
17
19
  }
18
20
  declare class HtmlResizeView extends HtmlNode {
19
21
  getControlGroup(): h.JSX.Element;
@@ -57,6 +57,22 @@ var HtmlResizeModel = /** @class */ (function (_super) {
57
57
  stroke: '#000000',
58
58
  };
59
59
  };
60
+ // 该方法需要在重设宽高和最大、最小限制后被调用,不建议在 initNodeData() 方法中使用
61
+ HtmlResizeModel.prototype.enableProportionResize = function (turnOn) {
62
+ if (turnOn === void 0) { turnOn = true; }
63
+ if (turnOn) {
64
+ var ResizePCT = { widthPCT: 100, hightPCT: 100 };
65
+ var ResizeBasis = { basisWidth: this.width, basisHeight: this.height };
66
+ var ScaleLimit = {
67
+ maxScaleLimit: Math.min((this.maxWidth / this.width) * 100, (this.maxHeight / this.height) * 100),
68
+ minScaleLimit: Math.max((this.minWidth / this.width) * 100, (this.minHeight / this.height) * 100),
69
+ };
70
+ this.PCTResizeInfo = { ResizePCT: ResizePCT, ResizeBasis: ResizeBasis, ScaleLimit: ScaleLimit };
71
+ }
72
+ else {
73
+ delete this.PCTResizeInfo;
74
+ }
75
+ };
60
76
  return HtmlResizeModel;
61
77
  }(HtmlNodeModel));
62
78
  var HtmlResizeView = /** @class */ (function (_super) {
@@ -1,5 +1,6 @@
1
1
  import { h, RectNode, RectNodeModel } from '@logicflow/core';
2
2
  declare class RectResizeModel extends RectNodeModel {
3
+ private PCTResizeInfo;
3
4
  constructor(data: any, graphModel: any);
4
5
  initNodeData(data: any): void;
5
6
  getOutlineStyle(): import("@logicflow/core/types/constant/DefaultTheme").OutlineTheme;
@@ -16,6 +17,7 @@ declare class RectResizeModel extends RectNodeModel {
16
17
  stroke: string;
17
18
  };
18
19
  resize(deltaX: any, deltaY: any): void;
20
+ enableProportionResize(turnOn?: boolean): void;
19
21
  }
20
22
  declare class RectResizeView extends RectNode {
21
23
  getControlGroup(): h.JSX.Element;
@@ -61,6 +61,22 @@ var RectResizeModel = /** @class */ (function (_super) {
61
61
  RectResizeModel.prototype.resize = function (deltaX, deltaY) {
62
62
  console.log(deltaX, deltaY);
63
63
  };
64
+ // 该方法需要在重设宽高和最大、最小限制后被调用,不建议在 initNodeData() 方法中使用
65
+ RectResizeModel.prototype.enableProportionResize = function (turnOn) {
66
+ if (turnOn === void 0) { turnOn = true; }
67
+ if (turnOn) {
68
+ var ResizePCT = { widthPCT: 100, hightPCT: 100 };
69
+ var ResizeBasis = { basisWidth: this.width, basisHeight: this.height };
70
+ var ScaleLimit = {
71
+ maxScaleLimit: Math.min((this.maxWidth / this.width) * 100, (this.maxHeight / this.height) * 100),
72
+ minScaleLimit: Math.max((this.minWidth / this.width) * 100, (this.minHeight / this.height) * 100),
73
+ };
74
+ this.PCTResizeInfo = { ResizePCT: ResizePCT, ResizeBasis: ResizeBasis, ScaleLimit: ScaleLimit };
75
+ }
76
+ else {
77
+ delete this.PCTResizeInfo;
78
+ }
79
+ };
64
80
  return RectResizeModel;
65
81
  }(RectNodeModel));
66
82
  var RectResizeView = /** @class */ (function (_super) {
@@ -1,7 +1,8 @@
1
- import { Extension } from '@logicflow/core';
2
- interface CurvedEdgePlugin extends Extension {
3
- [x: string]: any;
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 const CurvedEdge: CurvedEdgePlugin;
6
- export default CurvedEdge;
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 CurvedEdgeView = /** @class */ (function (_super) {
32
- __extends(CurvedEdgeView, _super);
33
- function CurvedEdgeView() {
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
- CurvedEdgeView.prototype.getEdge = function () {
37
- var _a = this.props.model.getEdgeStyle(), strokeWidth = _a.strokeWidth, stroke = _a.stroke, strokeDashArray = _a.strokeDashArray;
38
- var points = this.props.model.points;
39
- var points2 = points.split(' ').map(function (p) { return p.split(',').map(function (a) { return Number(a); }); });
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 - space : currentY + space;
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 - space : currentX + space;
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 - space : currentY + space;
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 - space : currentX + space;
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
- return h('path', {
74
- d: d,
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
- CurvedEdgeView.extendKey = 'curvedEdge';
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
- var CurvedEdge = {
92
- pluginName: 'curved-edge',
93
- curvedSpace: 5,
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, };
@@ -102,10 +102,14 @@ declare class GroupNodeModel extends RectResize.model {
102
102
  * 是否允许此节点添加到此分组中
103
103
  */
104
104
  isAllowAppendIn(nodeData: any): boolean;
105
+ /**
106
+ * 当groupA被添加到groupB中时,将groupB及groupB所属的group的zIndex减1
107
+ */
108
+ toBack(): void;
105
109
  }
106
110
  declare class GroupNode extends RectResize.view {
107
111
  getControlGroup(): h.JSX.Element;
108
- getAddedableShape(): import("preact").VNode<any>;
112
+ getAddableShape(): import("preact").VNode<any>;
109
113
  getFoldIcon(): import("preact").VNode<any>;
110
114
  getResizeShape(): import("preact").VNode<any>;
111
115
  }
@@ -46,6 +46,7 @@ import { h } from '@logicflow/core';
46
46
  import { RectResize } from '../../NodeResize';
47
47
  var defaultWidth = 500;
48
48
  var defaultHeight = 300;
49
+ var DEFAULT_BOTTOM_Z_INDEX = -10000;
49
50
  var GroupNodeModel = /** @class */ (function (_super) {
50
51
  __extends(GroupNodeModel, _super);
51
52
  function GroupNodeModel() {
@@ -68,8 +69,7 @@ var GroupNodeModel = /** @class */ (function (_super) {
68
69
  this.height = defaultHeight;
69
70
  this.foldedWidth = 80;
70
71
  this.foldedHeight = 60;
71
- // todo: 参考bpmn.js, 分组和未加入分组的节点重合时,未加入分组的节点在分组之下。方便标识。
72
- this.zIndex = -1;
72
+ this.zIndex = DEFAULT_BOTTOM_Z_INDEX;
73
73
  this.radius = 0;
74
74
  this.text.editable = false;
75
75
  this.text.draggable = false;
@@ -274,6 +274,7 @@ var GroupNodeModel = /** @class */ (function (_super) {
274
274
  GroupNodeModel.prototype.getHistoryData = function () {
275
275
  var data = _super.prototype.getData.call(this);
276
276
  data.children = __spread(this.children);
277
+ data.isGroup = true;
277
278
  var properties = data.properties;
278
279
  delete properties.groupAddable;
279
280
  if (properties.isFolded) { // 如果分组被折叠
@@ -288,6 +289,12 @@ var GroupNodeModel = /** @class */ (function (_super) {
288
289
  GroupNodeModel.prototype.isAllowAppendIn = function (nodeData) {
289
290
  return true;
290
291
  };
292
+ /**
293
+ * 当groupA被添加到groupB中时,将groupB及groupB所属的group的zIndex减1
294
+ */
295
+ GroupNodeModel.prototype.toBack = function () {
296
+ this.zIndex--;
297
+ };
291
298
  return GroupNodeModel;
292
299
  }(RectResize.model));
293
300
  var GroupNode = /** @class */ (function (_super) {
@@ -299,7 +306,7 @@ var GroupNode = /** @class */ (function (_super) {
299
306
  var _a = this.props.model, resizable = _a.resizable, properties = _a.properties;
300
307
  return resizable && !properties.isFolded ? _super.prototype.getControlGroup.call(this) : null;
301
308
  };
302
- GroupNode.prototype.getAddedableShape = function () {
309
+ GroupNode.prototype.getAddableShape = function () {
303
310
  var _a = this.props.model, width = _a.width, height = _a.height, x = _a.x, y = _a.y, radius = _a.radius, properties = _a.properties;
304
311
  if (!properties.groupAddable)
305
312
  return null;
@@ -345,7 +352,7 @@ var GroupNode = /** @class */ (function (_super) {
345
352
  };
346
353
  GroupNode.prototype.getResizeShape = function () {
347
354
  return h('g', {}, [
348
- this.getAddedableShape(),
355
+ this.getAddableShape(),
349
356
  _super.prototype.getResizeShape.call(this),
350
357
  this.getFoldIcon(),
351
358
  ]);
@@ -11,6 +11,7 @@ declare type Bounds = {
11
11
  declare class Group {
12
12
  static pluginName: string;
13
13
  lf: LogicFlow;
14
+ topGroupZIndex: number;
14
15
  activeGroup: any;
15
16
  nodeGroupMap: Map<BaseNodeId, GroupId>;
16
17
  constructor({ lf }: {
@@ -30,10 +31,21 @@ declare class Group {
30
31
  setActiveGroup: ({ data }: {
31
32
  data: any;
32
33
  }) => void;
34
+ /**
35
+ * 1. 分组节点默认在普通节点下面。
36
+ * 2. 分组节点被选中后,会将分组节点以及其内部的其他分组节点放到其余分组节点的上面。
37
+ * 3. 分组节点取消选中后,不会将分组节点重置为原来的高度。
38
+ * 4. 由于LogicFlow核心目标是支持用户手动绘制流程图,所以不考虑一张流程图超过1000个分组节点的情况。
39
+ */
40
+ nodeSelected: ({ data }: {
41
+ data: any;
42
+ }) => void;
43
+ toFrontGroup: (model: any) => void;
33
44
  /**
34
45
  * 获取自定位置其所属分组
46
+ * 当分组重合时,优先返回最上层的分组
35
47
  */
36
- getGroup(bounds: Bounds): BaseNodeModel | undefined;
48
+ getGroup(bounds: Bounds, nodeData: BaseNodeModel): BaseNodeModel | undefined;
37
49
  /**
38
50
  * 获取某个节点所属的groupModel
39
51
  */