@logicflow/extension 1.2.0-next.1 → 1.2.0-next.3

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 -64
  19. package/cjs/materials/group/index.js +99 -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 -64
  53. package/es/materials/group/index.d.ts +21 -1
  54. package/es/materials/group/index.js +99 -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 +21 -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
@@ -53,16 +53,70 @@ var Control = /** @class */ (function (_super) {
53
53
  _this.updatePosition = function (_a) {
54
54
  var deltaX = _a.deltaX, deltaY = _a.deltaY;
55
55
  var _b = _this.nodeModel, x = _b.x, y = _b.y;
56
+ _this.nodeModel.x = x + deltaX / 2;
57
+ _this.nodeModel.y = y + deltaY / 2;
56
58
  _this.nodeModel.moveText(deltaX / 2, deltaY / 2);
57
- _this.nodeModel.updateAttributes({
58
- x: x + deltaX / 2,
59
- y: y + deltaY / 2,
60
- });
61
59
  };
62
60
  // 计算control拖动后,节点的宽高
63
61
  _this.getResize = function (_a) {
64
- 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;
65
- var resize = { width: width, height: height };
62
+ 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;
63
+ var resize = { width: width, height: height, deltaX: deltaX, deltaY: deltaY };
64
+ if (PCTResizeInfo) {
65
+ var sensitivity = 4; // 越低越灵敏
66
+ var deltaScale = 0;
67
+ var combineDelta = 0;
68
+ switch (index) {
69
+ case 0:
70
+ combineDelta = (deltaX * -1 - deltaY) / sensitivity;
71
+ break;
72
+ case 1:
73
+ combineDelta = (deltaX - deltaY) / sensitivity;
74
+ break;
75
+ case 2:
76
+ combineDelta = (deltaX + deltaY) / sensitivity;
77
+ break;
78
+ case 3:
79
+ combineDelta = (deltaX * -1 + deltaY) / sensitivity;
80
+ break;
81
+ default:
82
+ break;
83
+ }
84
+ if (combineDelta !== 0) {
85
+ deltaScale = Math.round((combineDelta / PCTResizeInfo.ResizeBasis.basisHeight)
86
+ * 100000) / 1000;
87
+ }
88
+ PCTResizeInfo.ResizePCT.widthPCT = Math.max(Math.min(PCTResizeInfo.ResizePCT.widthPCT + deltaScale, PCTResizeInfo.ScaleLimit.maxScaleLimit), PCTResizeInfo.ScaleLimit.minScaleLimit);
89
+ PCTResizeInfo.ResizePCT.hightPCT = Math.max(Math.min(PCTResizeInfo.ResizePCT.hightPCT + deltaScale, PCTResizeInfo.ScaleLimit.maxScaleLimit), PCTResizeInfo.ScaleLimit.minScaleLimit);
90
+ var spcWidth = Math.round((PCTResizeInfo.ResizePCT.widthPCT
91
+ * PCTResizeInfo.ResizeBasis.basisWidth) / 100);
92
+ var spcHeight = Math.round((PCTResizeInfo.ResizePCT.hightPCT
93
+ * PCTResizeInfo.ResizeBasis.basisHeight) / 100);
94
+ switch (index) {
95
+ case 0:
96
+ deltaX = width - spcWidth;
97
+ deltaY = height - spcHeight;
98
+ break;
99
+ case 1:
100
+ deltaX = spcWidth - width;
101
+ deltaY = height - spcHeight;
102
+ break;
103
+ case 2:
104
+ deltaX = spcWidth - width;
105
+ deltaY = spcHeight - height;
106
+ break;
107
+ case 3:
108
+ deltaX = width - spcWidth;
109
+ deltaY = spcHeight - height;
110
+ break;
111
+ default:
112
+ break;
113
+ }
114
+ resize.width = spcWidth;
115
+ resize.height = spcHeight;
116
+ resize.deltaX = deltaX / pct;
117
+ resize.deltaY = deltaY / pct;
118
+ return resize;
119
+ }
66
120
  switch (index) {
67
121
  case 0:
68
122
  resize.width = width - deltaX * pct;
@@ -88,7 +142,7 @@ var Control = /** @class */ (function (_super) {
88
142
  // 矩形更新
89
143
  _this.updateRect = function (_a) {
90
144
  var deltaX = _a.deltaX, deltaY = _a.deltaY;
91
- var _b = _this.nodeModel, id = _b.id, x = _b.x, y = _b.y, width = _b.width, height = _b.height, radius = _b.radius;
145
+ 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;
92
146
  // 更新中心点位置,更新文案位置
93
147
  var index = _this.index;
94
148
  var size = _this.getResize({
@@ -97,6 +151,7 @@ var Control = /** @class */ (function (_super) {
97
151
  deltaY: deltaY,
98
152
  width: width,
99
153
  height: height,
154
+ PCTResizeInfo: PCTResizeInfo,
100
155
  pct: 1,
101
156
  });
102
157
  // 限制放大缩小的最大最小范围
@@ -109,18 +164,16 @@ var Control = /** @class */ (function (_super) {
109
164
  _this.dragHandler.cancelDrag();
110
165
  return;
111
166
  }
112
- _this.updatePosition({ deltaX: deltaX, deltaY: deltaY });
167
+ _this.updatePosition({ deltaX: size.deltaX, deltaY: size.deltaY });
113
168
  // 更新宽高
169
+ _this.nodeModel.width = size.width;
170
+ _this.nodeModel.height = size.height;
114
171
  _this.nodeModel.setProperties({
115
172
  nodeSize: {
116
173
  width: size.width,
117
174
  height: size.height,
118
175
  },
119
176
  });
120
- _this.nodeModel.updateAttributes({
121
- width: size.width,
122
- height: size.height,
123
- });
124
177
  var edges = _this.getNodeEdges(id);
125
178
  var beforeNode = {
126
179
  x: x,
@@ -158,7 +211,7 @@ var Control = /** @class */ (function (_super) {
158
211
  // 椭圆更新
159
212
  _this.updateEllipse = function (_a) {
160
213
  var deltaX = _a.deltaX, deltaY = _a.deltaY;
161
- var _b = _this.nodeModel, id = _b.id, rx = _b.rx, ry = _b.ry, x = _b.x, y = _b.y;
214
+ var _b = _this.nodeModel, id = _b.id, rx = _b.rx, ry = _b.ry, x = _b.x, y = _b.y, PCTResizeInfo = _b.PCTResizeInfo;
162
215
  var index = _this.index;
163
216
  var width = rx;
164
217
  var height = ry;
@@ -168,6 +221,7 @@ var Control = /** @class */ (function (_super) {
168
221
  deltaY: deltaY,
169
222
  width: width,
170
223
  height: height,
224
+ PCTResizeInfo: PCTResizeInfo,
171
225
  pct: 1 / 2,
172
226
  });
173
227
  // 限制放大缩小的最大最小范围
@@ -180,7 +234,7 @@ var Control = /** @class */ (function (_super) {
180
234
  return;
181
235
  }
182
236
  // 更新中心点位置,更新文案位置
183
- _this.updatePosition({ deltaX: deltaX, deltaY: deltaY });
237
+ _this.updatePosition({ deltaX: size.deltaX, deltaY: size.deltaY });
184
238
  // 更新rx ry,宽高为计算属性自动更新
185
239
  // @ts-ignore
186
240
  _this.nodeModel.rx = size.width;
@@ -222,7 +276,7 @@ var Control = /** @class */ (function (_super) {
222
276
  // 菱形更新
223
277
  _this.updateDiamond = function (_a) {
224
278
  var deltaX = _a.deltaX, deltaY = _a.deltaY;
225
- var _b = _this.nodeModel, id = _b.id, rx = _b.rx, ry = _b.ry, x = _b.x, y = _b.y;
279
+ var _b = _this.nodeModel, id = _b.id, rx = _b.rx, ry = _b.ry, x = _b.x, y = _b.y, PCTResizeInfo = _b.PCTResizeInfo;
226
280
  var index = _this.index;
227
281
  var width = rx;
228
282
  var height = ry;
@@ -232,6 +286,7 @@ var Control = /** @class */ (function (_super) {
232
286
  deltaY: deltaY,
233
287
  width: width,
234
288
  height: height,
289
+ PCTResizeInfo: PCTResizeInfo,
235
290
  pct: 1 / 2,
236
291
  });
237
292
  // 限制放大缩小的最大最小范围
@@ -244,7 +299,7 @@ var Control = /** @class */ (function (_super) {
244
299
  return;
245
300
  }
246
301
  // 更新中心点位置,更新文案位置
247
- _this.updatePosition({ deltaX: deltaX, deltaY: deltaY });
302
+ _this.updatePosition({ deltaX: size.deltaX, deltaY: size.deltaY });
248
303
  // 更新rx ry,宽高为计算属性自动更新
249
304
  // @ts-ignore
250
305
  _this.nodeModel.rx = size.width;
@@ -29,8 +29,14 @@ var ControlGroup_1 = require("../Control/ControlGroup");
29
29
  var Polygon_1 = require("../BasicShape/Polygon");
30
30
  var DiamondResizeModel = /** @class */ (function (_super) {
31
31
  __extends(DiamondResizeModel, _super);
32
- function DiamondResizeModel() {
33
- return _super !== null && _super.apply(this, arguments) || this;
32
+ function DiamondResizeModel(data, graphModel) {
33
+ var _this = _super.call(this, data, graphModel) || this;
34
+ var nodeSize = _this.properties.nodeSize;
35
+ if (nodeSize) {
36
+ _this.rx = nodeSize.rx;
37
+ _this.ry = nodeSize.ry;
38
+ }
39
+ return _this;
34
40
  }
35
41
  DiamondResizeModel.prototype.initNodeData = function (data) {
36
42
  _super.prototype.initNodeData.call(this, data);
@@ -40,14 +46,6 @@ var DiamondResizeModel = /** @class */ (function (_super) {
40
46
  this.maxHeight = 2000;
41
47
  this.gridSize = 1;
42
48
  };
43
- DiamondResizeModel.prototype.init = function () {
44
- _super.prototype.init.call(this);
45
- var nodeSize = this.properties.nodeSize;
46
- if (nodeSize) {
47
- this.rx = nodeSize.rx;
48
- this.ry = nodeSize.ry;
49
- }
50
- };
51
49
  DiamondResizeModel.prototype.getOutlineStyle = function () {
52
50
  var style = _super.prototype.getOutlineStyle.call(this);
53
51
  var isSilentMode = this.graphModel.editConfigModel.isSilentMode;
@@ -74,6 +72,22 @@ var DiamondResizeModel = /** @class */ (function (_super) {
74
72
  stroke: '#000000',
75
73
  };
76
74
  };
75
+ // 该方法需要在重设宽高和最大、最小限制后被调用,不建议在 initNodeData() 方法中使用
76
+ DiamondResizeModel.prototype.enableProportionResize = function (turnOn) {
77
+ if (turnOn === void 0) { turnOn = true; }
78
+ if (turnOn) {
79
+ var ResizePCT = { widthPCT: 100, hightPCT: 100 };
80
+ var ResizeBasis = { basisWidth: this.rx, basisHeight: this.ry };
81
+ var ScaleLimit = {
82
+ maxScaleLimit: Math.min((this.maxWidth / (this.rx * 2)) * 100, (this.maxHeight / (this.ry * 2)) * 100),
83
+ minScaleLimit: Math.max((this.minWidth / (this.rx * 2)) * 100, (this.minHeight / (this.ry * 2)) * 100),
84
+ };
85
+ this.PCTResizeInfo = { ResizePCT: ResizePCT, ResizeBasis: ResizeBasis, ScaleLimit: ScaleLimit };
86
+ }
87
+ else {
88
+ delete this.PCTResizeInfo;
89
+ }
90
+ };
77
91
  return DiamondResizeModel;
78
92
  }(core_1.DiamondNodeModel));
79
93
  var DiamondResizeView = /** @class */ (function (_super) {
@@ -17,8 +17,14 @@ var core_1 = require("@logicflow/core");
17
17
  var ControlGroup_1 = require("../Control/ControlGroup");
18
18
  var EllipseResizeModel = /** @class */ (function (_super) {
19
19
  __extends(EllipseResizeModel, _super);
20
- function EllipseResizeModel() {
21
- return _super !== null && _super.apply(this, arguments) || this;
20
+ function EllipseResizeModel(data, graphModel) {
21
+ var _this = _super.call(this, data, graphModel) || this;
22
+ var nodeSize = _this.properties.nodeSize;
23
+ if (nodeSize) {
24
+ _this.rx = nodeSize.rx;
25
+ _this.ry = nodeSize.ry;
26
+ }
27
+ return _this;
22
28
  }
23
29
  EllipseResizeModel.prototype.initNodeData = function (data) {
24
30
  _super.prototype.initNodeData.call(this, data);
@@ -27,14 +33,6 @@ var EllipseResizeModel = /** @class */ (function (_super) {
27
33
  this.maxWidth = 2000;
28
34
  this.maxHeight = 2000;
29
35
  };
30
- EllipseResizeModel.prototype.init = function () {
31
- _super.prototype.init.call(this);
32
- var nodeSize = this.properties.nodeSize;
33
- if (nodeSize) {
34
- this.rx = nodeSize.rx;
35
- this.ry = nodeSize.ry;
36
- }
37
- };
38
36
  EllipseResizeModel.prototype.getOutlineStyle = function () {
39
37
  var style = _super.prototype.getOutlineStyle.call(this);
40
38
  var isSilentMode = this.graphModel.editConfigModel.isSilentMode;
@@ -61,6 +59,22 @@ var EllipseResizeModel = /** @class */ (function (_super) {
61
59
  stroke: '#000000',
62
60
  };
63
61
  };
62
+ // 该方法需要在重设宽高和最大、最小限制后被调用,不建议在 initNodeData() 方法中使用
63
+ EllipseResizeModel.prototype.enableProportionResize = function (turnOn) {
64
+ if (turnOn === void 0) { turnOn = true; }
65
+ if (turnOn) {
66
+ var ResizePCT = { widthPCT: 100, hightPCT: 100 };
67
+ var ResizeBasis = { basisWidth: this.rx, basisHeight: this.ry };
68
+ var ScaleLimit = {
69
+ maxScaleLimit: Math.min((this.maxWidth / (this.rx * 2)) * 100, (this.maxHeight / (this.ry * 2)) * 100),
70
+ minScaleLimit: Math.max((this.minWidth / (this.rx * 2)) * 100, (this.minHeight / (this.ry * 2)) * 100),
71
+ };
72
+ this.PCTResizeInfo = { ResizePCT: ResizePCT, ResizeBasis: ResizeBasis, ScaleLimit: ScaleLimit };
73
+ }
74
+ else {
75
+ delete this.PCTResizeInfo;
76
+ }
77
+ };
64
78
  return EllipseResizeModel;
65
79
  }(core_1.EllipseNodeModel));
66
80
  var EllipseResizeView = /** @class */ (function (_super) {
@@ -17,8 +17,14 @@ var core_1 = require("@logicflow/core");
17
17
  var ControlGroup_1 = require("../Control/ControlGroup");
18
18
  var HtmlResizeModel = /** @class */ (function (_super) {
19
19
  __extends(HtmlResizeModel, _super);
20
- function HtmlResizeModel() {
21
- return _super !== null && _super.apply(this, arguments) || this;
20
+ function HtmlResizeModel(data, graphModel) {
21
+ var _this = _super.call(this, data, graphModel) || this;
22
+ var nodeSize = _this.properties.nodeSize;
23
+ if (nodeSize) {
24
+ _this.width = nodeSize.width;
25
+ _this.height = nodeSize.height;
26
+ }
27
+ return _this;
22
28
  }
23
29
  HtmlResizeModel.prototype.initNodeData = function (data) {
24
30
  _super.prototype.initNodeData.call(this, data);
@@ -27,14 +33,6 @@ var HtmlResizeModel = /** @class */ (function (_super) {
27
33
  this.maxWidth = 2000;
28
34
  this.maxHeight = 2000;
29
35
  };
30
- HtmlResizeModel.prototype.init = function () {
31
- _super.prototype.init.call(this);
32
- var nodeSize = this.properties.nodeSize;
33
- if (nodeSize) {
34
- this.width = nodeSize.width;
35
- this.height = nodeSize.height;
36
- }
37
- };
38
36
  HtmlResizeModel.prototype.getOutlineStyle = function () {
39
37
  var style = _super.prototype.getOutlineStyle.call(this);
40
38
  var isSilentMode = this.graphModel.editConfigModel.isSilentMode;
@@ -61,6 +59,22 @@ var HtmlResizeModel = /** @class */ (function (_super) {
61
59
  stroke: '#000000',
62
60
  };
63
61
  };
62
+ // 该方法需要在重设宽高和最大、最小限制后被调用,不建议在 initNodeData() 方法中使用
63
+ HtmlResizeModel.prototype.enableProportionResize = function (turnOn) {
64
+ if (turnOn === void 0) { turnOn = true; }
65
+ if (turnOn) {
66
+ var ResizePCT = { widthPCT: 100, hightPCT: 100 };
67
+ var ResizeBasis = { basisWidth: this.width, basisHeight: this.height };
68
+ var ScaleLimit = {
69
+ maxScaleLimit: Math.min((this.maxWidth / this.width) * 100, (this.maxHeight / this.height) * 100),
70
+ minScaleLimit: Math.max((this.minWidth / this.width) * 100, (this.minHeight / this.height) * 100),
71
+ };
72
+ this.PCTResizeInfo = { ResizePCT: ResizePCT, ResizeBasis: ResizeBasis, ScaleLimit: ScaleLimit };
73
+ }
74
+ else {
75
+ delete this.PCTResizeInfo;
76
+ }
77
+ };
64
78
  return HtmlResizeModel;
65
79
  }(core_1.HtmlNodeModel));
66
80
  var HtmlResizeView = /** @class */ (function (_super) {
@@ -17,8 +17,14 @@ var core_1 = require("@logicflow/core");
17
17
  var ControlGroup_1 = require("../Control/ControlGroup");
18
18
  var RectResizeModel = /** @class */ (function (_super) {
19
19
  __extends(RectResizeModel, _super);
20
- function RectResizeModel() {
21
- return _super !== null && _super.apply(this, arguments) || this;
20
+ function RectResizeModel(data, graphModel) {
21
+ var _this = _super.call(this, data, graphModel) || this;
22
+ var nodeSize = _this.properties.nodeSize;
23
+ if (nodeSize) {
24
+ _this.width = nodeSize.width;
25
+ _this.height = nodeSize.height;
26
+ }
27
+ return _this;
22
28
  }
23
29
  RectResizeModel.prototype.initNodeData = function (data) {
24
30
  _super.prototype.initNodeData.call(this, data);
@@ -27,14 +33,6 @@ var RectResizeModel = /** @class */ (function (_super) {
27
33
  this.maxWidth = 2000;
28
34
  this.maxHeight = 2000;
29
35
  };
30
- RectResizeModel.prototype.init = function () {
31
- _super.prototype.init.call(this);
32
- var nodeSize = this.properties.nodeSize;
33
- if (nodeSize) {
34
- this.width = nodeSize.width;
35
- this.height = nodeSize.height;
36
- }
37
- };
38
36
  RectResizeModel.prototype.getOutlineStyle = function () {
39
37
  var style = _super.prototype.getOutlineStyle.call(this);
40
38
  var isSilentMode = this.graphModel.editConfigModel.isSilentMode;
@@ -65,6 +63,22 @@ var RectResizeModel = /** @class */ (function (_super) {
65
63
  RectResizeModel.prototype.resize = function (deltaX, deltaY) {
66
64
  console.log(deltaX, deltaY);
67
65
  };
66
+ // 该方法需要在重设宽高和最大、最小限制后被调用,不建议在 initNodeData() 方法中使用
67
+ RectResizeModel.prototype.enableProportionResize = function (turnOn) {
68
+ if (turnOn === void 0) { turnOn = true; }
69
+ if (turnOn) {
70
+ var ResizePCT = { widthPCT: 100, hightPCT: 100 };
71
+ var ResizeBasis = { basisWidth: this.width, basisHeight: this.height };
72
+ var ScaleLimit = {
73
+ maxScaleLimit: Math.min((this.maxWidth / this.width) * 100, (this.maxHeight / this.height) * 100),
74
+ minScaleLimit: Math.max((this.minWidth / this.width) * 100, (this.minHeight / this.height) * 100),
75
+ };
76
+ this.PCTResizeInfo = { ResizePCT: ResizePCT, ResizeBasis: ResizeBasis, ScaleLimit: ScaleLimit };
77
+ }
78
+ else {
79
+ delete this.PCTResizeInfo;
80
+ }
81
+ };
68
82
  return RectResizeModel;
69
83
  }(core_1.RectNodeModel));
70
84
  var RectResizeView = /** @class */ (function (_super) {
@@ -1,28 +1,4 @@
1
1
  "use strict";
2
- var __extends = (this && this.__extends) || (function () {
3
- var extendStatics = function (d, b) {
4
- extendStatics = Object.setPrototypeOf ||
5
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
7
- return extendStatics(d, b);
8
- };
9
- return function (d, b) {
10
- extendStatics(d, b);
11
- function __() { this.constructor = d; }
12
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
13
- };
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
- };
26
2
  var __read = (this && this.__read) || function (o, n) {
27
3
  var m = typeof Symbol === "function" && o[Symbol.iterator];
28
4
  if (!m) return o;
@@ -141,6 +117,8 @@ function convertLf2ProcessData(bpmnProcessData, data) {
141
117
  var sequenceFlow = data.edges.map(function (edge) {
142
118
  var _a, _b;
143
119
  var targetNode = nodeMap.get(edge.targetNodeId);
120
+ // @see https://github.com/didi/LogicFlow/issues/325
121
+ // 需要保证incomming在outgoing之前
144
122
  if (!targetNode['bpmn:incoming']) {
145
123
  targetNode['bpmn:incoming'] = edge.id;
146
124
  }
@@ -153,34 +131,6 @@ function convertLf2ProcessData(bpmnProcessData, data) {
153
131
  edge.id,
154
132
  ];
155
133
  }
156
- // const sourceNode = nodeMap.get(edge.sourceNodeId);
157
- // if (!sourceNode['bpmn:outgoing']) {
158
- // sourceNode['bpmn:outgoing'] = edge.id;
159
- // } else if (Array.isArray(sourceNode['bpmn:outgoing'])) {
160
- // sourceNode['bpmn:outgoing'].push(edge.id);
161
- // } else { // 字符串转数组
162
- // sourceNode['bpmn:outgoing'] = [
163
- // sourceNode['bpmn:outgoing'],
164
- // edge.id,
165
- // ];
166
- // }
167
- var edgeConfig = {
168
- '-id': edge.id,
169
- '-sourceRef': edge.sourceNodeId,
170
- '-targetRef': edge.targetNodeId,
171
- };
172
- if ((_a = edge.text) === null || _a === void 0 ? void 0 : _a.value) {
173
- edgeConfig['-name'] = (_b = edge.text) === null || _b === void 0 ? void 0 : _b.value;
174
- }
175
- if (edge.properties) {
176
- var properties = toXmlJson(edge.properties);
177
- Object.assign(edgeConfig, properties);
178
- }
179
- return edgeConfig;
180
- });
181
- // @see https://github.com/didi/LogicFlow/issues/325
182
- // 需要保证incoming在outgoing之前
183
- data.edges.forEach(function (edge) {
184
134
  var sourceNode = nodeMap.get(edge.sourceNodeId);
185
135
  if (!sourceNode['bpmn:outgoing']) {
186
136
  sourceNode['bpmn:outgoing'] = edge.id;
@@ -194,6 +144,19 @@ function convertLf2ProcessData(bpmnProcessData, data) {
194
144
  edge.id,
195
145
  ];
196
146
  }
147
+ var edgeConfig = {
148
+ '-id': edge.id,
149
+ '-sourceRef': edge.sourceNodeId,
150
+ '-targetRef': edge.targetNodeId,
151
+ };
152
+ if ((_a = edge.text) === null || _a === void 0 ? void 0 : _a.value) {
153
+ edgeConfig['-name'] = (_b = edge.text) === null || _b === void 0 ? void 0 : _b.value;
154
+ }
155
+ if (edge.properties) {
156
+ var properties = toXmlJson(edge.properties);
157
+ Object.assign(edgeConfig, properties);
158
+ }
159
+ return edgeConfig;
197
160
  });
198
161
  bpmnProcessData[BpmnElements.FLOW] = sequenceFlow;
199
162
  }
@@ -439,59 +402,53 @@ function getEdgeConfig(edgeValue, processValue) {
439
402
  }
440
403
  return edge;
441
404
  }
442
- var BpmnAdapter = /** @class */ (function () {
443
- function BpmnAdapter(_a) {
444
- var _this = this;
445
- var lf = _a.lf;
446
- this.adapterOut = function (data) {
447
- var bpmnProcessData = __assign({}, _this.processAttributes);
448
- convertLf2ProcessData(bpmnProcessData, data);
449
- var bpmnDiagramData = {
450
- '-id': 'BPMNPlane_1',
451
- '-bpmnElement': bpmnProcessData['-id'],
452
- };
453
- convertLf2DiagramData(bpmnDiagramData, data);
454
- var definitions = _this.definitionAttributes;
455
- definitions['bpmn:process'] = bpmnProcessData;
456
- definitions['bpmndi:BPMNDiagram'] = {
457
- '-id': 'BPMNDiagram_1',
458
- 'bpmndi:BPMNPlane': bpmnDiagramData,
459
- };
460
- var bpmnData = {
461
- 'bpmn:definitions': definitions,
462
- };
463
- return bpmnData;
464
- };
465
- this.adapterIn = function (bpmnData) {
466
- if (bpmnData) {
467
- return convertBpmn2LfData(bpmnData);
468
- }
469
- };
470
- lf.adapterIn = function (data) { return _this.adapterIn(data); };
471
- lf.adapterOut = function (data) { return _this.adapterOut(data); };
472
- this.processAttributes = {
473
- '-isExecutable': 'true',
405
+ var BpmnAdapter = {
406
+ pluginName: 'bpmn-adapter',
407
+ install: function (lf) {
408
+ lf.adapterIn = this.adapterIn;
409
+ lf.adapterOut = this.adapterOut;
410
+ },
411
+ shapeConfigMap: new Map(),
412
+ setCustomShape: function (key, val) {
413
+ this.shapeConfigMap.set(key, val);
414
+ },
415
+ adapterOut: function (data) {
416
+ var bpmnProcessData = {
474
417
  '-id': "Process_" + bpmnIds_1.getBpmnId(),
418
+ '-isExecutable': 'false',
475
419
  };
476
- this.definitionAttributes = {
477
- '-id': "Definitions_" + bpmnIds_1.getBpmnId(),
478
- '-xmlns:xsi': 'http://www.w3.org/2001/XMLSchema-instance',
479
- '-xmlns:bpmn': 'http://www.omg.org/spec/BPMN/20100524/MODEL',
480
- '-xmlns:bpmndi': 'http://www.omg.org/spec/BPMN/20100524/DI',
481
- '-xmlns:dc': 'http://www.omg.org/spec/DD/20100524/DC',
482
- '-xmlns:di': 'http://www.omg.org/spec/DD/20100524/DI',
483
- '-targetNamespace': 'http://logic-flow.org',
484
- '-exporter': 'logicflow',
485
- '-exporterVersion': '1.2.0',
420
+ convertLf2ProcessData(bpmnProcessData, data);
421
+ var bpmnDiagramData = {
422
+ '-id': 'BPMNPlane_1',
423
+ '-bpmnElement': bpmnProcessData['-id'],
486
424
  };
487
- }
488
- BpmnAdapter.prototype.setCustomShape = function (key, val) {
489
- BpmnAdapter.shapeConfigMap.set(key, val);
490
- };
491
- BpmnAdapter.pluginName = 'bpmn-adapter';
492
- BpmnAdapter.shapeConfigMap = new Map();
493
- return BpmnAdapter;
494
- }());
425
+ convertLf2DiagramData(bpmnDiagramData, data);
426
+ var bpmnData = {
427
+ 'bpmn:definitions': {
428
+ '-id': "Definitions_" + bpmnIds_1.getBpmnId(),
429
+ '-xmlns:xsi': 'http://www.w3.org/2001/XMLSchema-instance',
430
+ '-xmlns:bpmn': 'http://www.omg.org/spec/BPMN/20100524/MODEL',
431
+ '-xmlns:bpmndi': 'http://www.omg.org/spec/BPMN/20100524/DI',
432
+ '-xmlns:dc': 'http://www.omg.org/spec/DD/20100524/DC',
433
+ '-xmlns:di': 'http://www.omg.org/spec/DD/20100524/DI',
434
+ '-targetNamespace': 'http://bpmn.io/schema/bpmn',
435
+ '-exporter': 'bpmn-js (https://demo.bpmn.io)',
436
+ '-exporterVersion': '7.3.0',
437
+ 'bpmn:process': bpmnProcessData,
438
+ 'bpmndi:BPMNDiagram': {
439
+ '-id': 'BPMNDiagram_1',
440
+ 'bpmndi:BPMNPlane': bpmnDiagramData,
441
+ },
442
+ },
443
+ };
444
+ return bpmnData;
445
+ },
446
+ adapterIn: function (bpmnData) {
447
+ if (bpmnData) {
448
+ return convertBpmn2LfData(bpmnData);
449
+ }
450
+ },
451
+ };
495
452
  exports.BpmnAdapter = BpmnAdapter;
496
453
  BpmnAdapter.shapeConfigMap.set(BpmnElements.START, {
497
454
  width: constant_1.StartEventConfig.width,
@@ -513,25 +470,20 @@ BpmnAdapter.shapeConfigMap.set(BpmnElements.USER, {
513
470
  width: constant_1.UserTaskConfig.width,
514
471
  height: constant_1.UserTaskConfig.height,
515
472
  });
516
- var BpmnXmlAdapter = /** @class */ (function (_super) {
517
- __extends(BpmnXmlAdapter, _super);
518
- function BpmnXmlAdapter(data) {
519
- var _this = _super.call(this, data) || this;
520
- _this.adapterXmlIn = function (bpmnData) {
521
- var json = xml2json_1.lfXml2Json(bpmnData);
522
- return _this.adapterIn(json);
523
- };
524
- _this.adapterXmlOut = function (data) {
525
- var outData = _this.adapterOut(data);
526
- return json2xml_1.lfJson2Xml(outData);
527
- };
528
- var lf = data.lf;
529
- lf.adapterIn = _this.adapterXmlIn;
530
- lf.adapterOut = _this.adapterXmlOut;
531
- return _this;
532
- }
533
- BpmnXmlAdapter.pluginName = 'bpmnXmlAdapter';
534
- return BpmnXmlAdapter;
535
- }(BpmnAdapter));
473
+ var BpmnXmlAdapter = {
474
+ pluginName: 'bpmnXmlAdapter',
475
+ install: function (lf) {
476
+ lf.adapterIn = this.adapterXmlIn;
477
+ lf.adapterOut = this.adapterXmlOut;
478
+ },
479
+ adapterXmlIn: function (bpmnData) {
480
+ var json = xml2json_1.lfXml2Json(bpmnData);
481
+ return BpmnAdapter.adapterIn(json);
482
+ },
483
+ adapterXmlOut: function (data) {
484
+ var outData = BpmnAdapter.adapterOut(data);
485
+ return json2xml_1.lfJson2Xml(outData);
486
+ },
487
+ };
536
488
  exports.BpmnXmlAdapter = BpmnXmlAdapter;
537
489
  exports.default = BpmnAdapter;
@@ -25,12 +25,10 @@ function toXml(v, name, ind, deep) {
25
25
  var hasChild = false;
26
26
  xml += addIndSpace(ind, deep) + "<" + name;
27
27
  for (var m in v) {
28
- if (m.charAt(0) == "-") {
28
+ if (m.charAt(0) == "-")
29
29
  xml += " " + m.substr(1) + "=\"" + v[m].toString() + "\"";
30
- }
31
- else {
30
+ else
32
31
  hasChild = true;
33
- }
34
32
  }
35
33
  xml += hasChild ? ">" : " />";
36
34
  if (hasChild) {