@logicflow/extension 1.2.0-alpha.0 → 1.2.0-alpha.11

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 (89) hide show
  1. package/cjs/NodeResize/Control/Control.js +13 -9
  2. package/cjs/NodeResize/Node/DiamondResize.js +10 -8
  3. package/cjs/NodeResize/Node/EllipseResize.js +10 -8
  4. package/cjs/NodeResize/Node/HtmlResize.js +10 -8
  5. package/cjs/NodeResize/Node/RectResize.js +10 -8
  6. package/cjs/bpmn-adapter/index.js +1 -1
  7. package/cjs/components/control/index.js +16 -16
  8. package/cjs/components/highlight/index.js +187 -0
  9. package/cjs/components/menu/index.js +9 -9
  10. package/cjs/components/mini-map/index.js +5 -0
  11. package/cjs/components/selection-select/index.js +22 -2
  12. package/cjs/index.js +2 -0
  13. package/cjs/locale/en-locale/en.js +22 -0
  14. package/cjs/locale/en-locale/index.js +29 -0
  15. package/cjs/locale/locale.js +19 -0
  16. package/cjs/materials/group/GroupNode.js +22 -12
  17. package/cjs/tools/snapshot/index.js +47 -46
  18. package/cjs/turbo-adapter/index.js +71 -41
  19. package/es/NodeResize/Control/Control.js +13 -9
  20. package/es/NodeResize/Node/DiamondResize.d.ts +1 -1
  21. package/es/NodeResize/Node/DiamondResize.js +10 -8
  22. package/es/NodeResize/Node/EllipseResize.d.ts +1 -1
  23. package/es/NodeResize/Node/EllipseResize.js +10 -8
  24. package/es/NodeResize/Node/HtmlResize.d.ts +1 -1
  25. package/es/NodeResize/Node/HtmlResize.js +10 -8
  26. package/es/NodeResize/Node/RectResize.d.ts +1 -1
  27. package/es/NodeResize/Node/RectResize.js +10 -8
  28. package/es/bpmn-adapter/index.js +1 -1
  29. package/es/components/control/index.d.ts +2 -3
  30. package/es/components/control/index.js +16 -16
  31. package/es/components/highlight/index.d.ts +21 -0
  32. package/es/components/highlight/index.js +184 -0
  33. package/es/components/menu/index.d.ts +2 -3
  34. package/es/components/menu/index.js +9 -9
  35. package/es/components/mini-map/index.js +5 -0
  36. package/es/components/selection-select/index.d.ts +1 -0
  37. package/es/components/selection-select/index.js +22 -2
  38. package/es/index.d.ts +2 -0
  39. package/es/index.js +2 -0
  40. package/es/locale/en-locale/en.d.ts +19 -0
  41. package/es/locale/en-locale/en.js +19 -0
  42. package/es/locale/en-locale/index.d.ts +9 -0
  43. package/es/locale/en-locale/index.js +26 -0
  44. package/es/locale/locale.d.ts +6 -0
  45. package/es/locale/locale.js +16 -0
  46. package/es/materials/group/GroupNode.js +22 -12
  47. package/es/tools/snapshot/index.d.ts +15 -7
  48. package/es/tools/snapshot/index.js +47 -46
  49. package/es/turbo-adapter/index.d.ts +6 -7
  50. package/es/turbo-adapter/index.js +70 -40
  51. package/lib/AutoLayout.js +1 -1
  52. package/lib/BpmnAdapter.js +1 -1
  53. package/lib/BpmnElement.js +1 -1
  54. package/lib/ContextMenu.js +1 -1
  55. package/lib/Control.js +1 -1
  56. package/lib/CurvedEdge.js +1 -1
  57. package/lib/DndPanel.js +1 -1
  58. package/lib/EnLocale.js +1 -0
  59. package/lib/FlowPath.js +1 -1
  60. package/lib/Group.js +1 -1
  61. package/lib/Highlight.js +1 -0
  62. package/lib/InsertNodeInPolyline.js +1 -1
  63. package/lib/Menu.js +1 -1
  64. package/lib/MiniMap.js +1 -1
  65. package/lib/NodeResize.js +1 -1
  66. package/lib/RectLabelNode.js +1 -1
  67. package/lib/SelectionSelect.js +1 -1
  68. package/lib/Snapshot.js +1 -1
  69. package/lib/TurboAdapter.js +1 -1
  70. package/lib/lfJson2Xml.js +1 -1
  71. package/lib/lfXml2Json.js +1 -1
  72. package/package.json +2 -2
  73. package/types/NodeResize/Node/DiamondResize.d.ts +1 -1
  74. package/types/NodeResize/Node/EllipseResize.d.ts +1 -1
  75. package/types/NodeResize/Node/HtmlResize.d.ts +1 -1
  76. package/types/NodeResize/Node/RectResize.d.ts +1 -1
  77. package/types/components/control/index.d.ts +2 -3
  78. package/types/components/highlight/index.d.ts +21 -0
  79. package/types/components/menu/index.d.ts +2 -3
  80. package/types/components/selection-select/index.d.ts +1 -0
  81. package/types/index.d.ts +2 -0
  82. package/types/locale/en-locale/en.d.ts +19 -0
  83. package/types/locale/en-locale/index.d.ts +9 -0
  84. package/types/locale/locale.d.ts +6 -0
  85. package/types/tools/snapshot/index.d.ts +15 -7
  86. package/types/turbo-adapter/index.d.ts +6 -7
  87. package/types/NodeResize/BasicShape/Ellipse.d.ts +0 -2
  88. package/types/curved.d.ts +0 -0
  89. package/types/group-shrink/index.d.ts +0 -28
@@ -107,24 +107,30 @@ var GroupNodeModel = /** @class */ (function (_super) {
107
107
  this.isFolded = isFolded;
108
108
  // step 1
109
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;
112
110
  this.unfoldedWidth = this.width;
113
111
  this.unfoldedHight = this.height;
114
- this.width = this.foldedWidth;
115
- this.height = this.foldedHeight;
112
+ this.updateAttributes({
113
+ x: this.x - this.width / 2 + this.foldedWidth / 2,
114
+ y: this.y - this.height / 2 + this.foldedHeight / 2,
115
+ width: this.foldedWidth,
116
+ height: this.foldedHeight,
117
+ });
116
118
  }
117
119
  else {
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;
120
+ this.updateAttributes({
121
+ width: this.unfoldedWidth,
122
+ height: this.unfoldedHight,
123
+ x: this.x + this.unfoldedWidth / 2 - this.foldedWidth / 2,
124
+ y: this.y + this.unfoldedHight / 2 - this.foldedHeight / 2,
125
+ });
122
126
  }
123
127
  // step 2
124
128
  var allEdges = this.incoming.edges.concat(this.outgoing.edges);
125
129
  this.children.forEach(function (elementId) {
126
130
  var nodeModel = _this.graphModel.getElement(elementId);
127
- nodeModel.visible = !isFolded;
131
+ nodeModel.updateAttributes({
132
+ visible: !isFolded,
133
+ });
128
134
  allEdges = allEdges.concat(nodeModel.incoming.edges.concat(nodeModel.outgoing.edges));
129
135
  });
130
136
  // step 3
@@ -196,7 +202,9 @@ var GroupNodeModel = /** @class */ (function (_super) {
196
202
  if (targetNodeIdGroup.id !== _this.id || sourceNodeIdGroup.id !== _this.id) {
197
203
  _this.createVirtualEdge(data);
198
204
  }
199
- edgeModel.visible = false;
205
+ edgeModel.updateAttributes({
206
+ visible: false,
207
+ });
200
208
  }
201
209
  // 展开时,处理被隐藏的边的逻辑
202
210
  if (!isFolded && edgeModel.visible === false) {
@@ -212,7 +220,9 @@ var GroupNodeModel = /** @class */ (function (_super) {
212
220
  _this.createVirtualEdge(data);
213
221
  }
214
222
  else {
215
- edgeModel.visible = true;
223
+ edgeModel.updateAttributes({
224
+ visible: true,
225
+ });
216
226
  }
217
227
  }
218
228
  });
@@ -222,7 +232,7 @@ var GroupNodeModel = /** @class */ (function (_super) {
222
232
  var model = this.graphModel.addEdge(edgeData);
223
233
  model.virtual = true;
224
234
  // 强制不保存group连线数据
225
- model.getData = function () { return null; };
235
+ // model.getData = () => null;
226
236
  model.text.editable = false;
227
237
  model.isFoldedEdge = true;
228
238
  };
@@ -4,37 +4,27 @@
4
4
  */
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.Snapshot = void 0;
7
- var Snapshot = {
8
- pluginName: 'snapshot',
9
- install: function (lf) {
7
+ var Snapshot = /** @class */ (function () {
8
+ function Snapshot(_a) {
10
9
  var _this = this;
10
+ var lf = _a.lf;
11
11
  this.lf = lf;
12
+ this.customCssRules = '';
13
+ this.useGlobalRules = true;
12
14
  /* 下载快照 */
13
15
  lf.getSnapshot = function (fileName, backgroundColor) {
14
- _this.offsetX = Number.MAX_SAFE_INTEGER;
15
- _this.offsetY = Number.MAX_SAFE_INTEGER;
16
- _this.fileName = fileName || "logic-flow." + Date.now() + ".png";
17
- var svgRootElement = _this.getSvgRootElement(lf);
18
- _this.downloadSvg(svgRootElement, _this.fileName, backgroundColor);
16
+ _this.getSnapshot(fileName, backgroundColor);
19
17
  };
20
18
  /* 获取Blob对象,用户图片上传 */
21
- lf.getSnapshotBlob = function (backgroundColor) {
22
- _this.offsetX = Number.MAX_SAFE_INTEGER;
23
- _this.offsetY = Number.MAX_SAFE_INTEGER;
24
- var svgRootElement = _this.getSvgRootElement(lf);
25
- return _this.getBlob(svgRootElement, backgroundColor);
26
- };
19
+ lf.getSnapshotBlob = function (backgroundColor) { return _this.getSnapshotBlob(backgroundColor); };
27
20
  /* 获取Base64对象,用户图片上传 */
28
- lf.getSnapshotBase64 = function (backgroundColor) {
29
- _this.offsetX = Number.MAX_SAFE_INTEGER;
30
- _this.offsetY = Number.MAX_SAFE_INTEGER;
31
- var svgRootElement = _this.getSvgRootElement(lf);
32
- return _this.getBase64(svgRootElement, backgroundColor);
33
- };
34
- },
21
+ lf.getSnapshotBase64 = function (backgroundColor) { return _this.getSnapshotBase64(backgroundColor); };
22
+ }
35
23
  /* 获取svgRoot对象 */
36
- getSvgRootElement: function (lf) {
24
+ Snapshot.prototype.getSvgRootElement = function (lf) {
37
25
  var _this = this;
26
+ this.offsetX = Number.MAX_SAFE_INTEGER;
27
+ this.offsetY = Number.MAX_SAFE_INTEGER;
38
28
  lf.graphModel.nodes.forEach(function (item) {
39
29
  var x = item.x, width = item.width, y = item.y, height = item.height;
40
30
  var offsetX = x - width / 2;
@@ -61,8 +51,8 @@ var Snapshot = {
61
51
  });
62
52
  var svgRootElement = lf.container.querySelector('.lf-canvas-overlay');
63
53
  return svgRootElement;
64
- },
65
- triggerDownload: function (imgURI) {
54
+ };
55
+ Snapshot.prototype.triggerDownload = function (imgURI) {
66
56
  var evt = new MouseEvent('click', {
67
57
  view: window,
68
58
  bubbles: false,
@@ -73,8 +63,8 @@ var Snapshot = {
73
63
  a.setAttribute('href', imgURI);
74
64
  a.setAttribute('target', '_blank');
75
65
  a.dispatchEvent(evt);
76
- },
77
- removeAnchor: function (element) {
66
+ };
67
+ Snapshot.prototype.removeAnchor = function (element) {
78
68
  var childNodes = element.childNodes;
79
69
  var childLength = element.childNodes && element.childNodes.length;
80
70
  for (var i = 0; i < childLength; i++) {
@@ -86,20 +76,22 @@ var Snapshot = {
86
76
  i--;
87
77
  }
88
78
  }
89
- },
79
+ };
90
80
  /* 下载图片 */
91
- downloadSvg: function (svg, fileName, backgroundColor) {
81
+ Snapshot.prototype.getSnapshot = function (fileName, backgroundColor) {
92
82
  var _this = this;
83
+ this.fileName = fileName || "logic-flow." + Date.now() + ".png";
84
+ var svg = this.getSvgRootElement(this.lf);
93
85
  this.getCanvasData(svg, backgroundColor).then(function (canvas) {
94
- var imgURI = canvas
95
- .toDataURL('image/png')
86
+ var imgURI = canvas.toDataURL('image/png')
96
87
  .replace('image/png', 'image/octet-stream');
97
- _this.triggerDownload(imgURI, fileName);
88
+ _this.triggerDownload(imgURI);
98
89
  });
99
- },
90
+ };
100
91
  /* 获取base64对象 */
101
- getBase64: function (svg, backgroundColor) {
92
+ Snapshot.prototype.getSnapshotBase64 = function (backgroundColor) {
102
93
  var _this = this;
94
+ var svg = this.getSvgRootElement(this.lf);
103
95
  return new Promise(function (resolve) {
104
96
  _this.getCanvasData(svg, backgroundColor).then(function (canvas) {
105
97
  var base64 = canvas.toDataURL('image/png');
@@ -107,10 +99,11 @@ var Snapshot = {
107
99
  resolve({ data: base64, width: canvas.width, height: canvas.height });
108
100
  });
109
101
  });
110
- },
102
+ };
111
103
  /* 获取Blob对象 */
112
- getBlob: function (svg, backgroundColor) {
104
+ Snapshot.prototype.getSnapshotBlob = function (backgroundColor) {
113
105
  var _this = this;
106
+ var svg = this.getSvgRootElement(this.lf);
114
107
  return new Promise(function (resolve) {
115
108
  _this.getCanvasData(svg, backgroundColor).then(function (canvas) {
116
109
  canvas.toBlob(function (blob) {
@@ -119,20 +112,25 @@ var Snapshot = {
119
112
  }, 'image/png');
120
113
  });
121
114
  });
122
- },
123
- getClassRules: function () {
115
+ };
116
+ Snapshot.prototype.getClassRules = function () {
124
117
  var rules = '';
125
- var styleSheets = document.styleSheets;
126
- for (var i = 0; i < styleSheets.length; i++) {
127
- var sheet = styleSheets[i];
128
- for (var j = 0; j < sheet.cssRules.length; j++) {
129
- rules += sheet.cssRules[j].cssText;
118
+ if (this.useGlobalRules) {
119
+ var styleSheets = document.styleSheets;
120
+ for (var i = 0; i < styleSheets.length; i++) {
121
+ var sheet = styleSheets[i];
122
+ for (var j = 0; j < sheet.cssRules.length; j++) {
123
+ rules += sheet.cssRules[j].cssText;
124
+ }
130
125
  }
131
126
  }
127
+ if (this.customCssRules) {
128
+ rules += this.customCssRules;
129
+ }
132
130
  return rules;
133
- },
131
+ };
134
132
  // 获取图片生成中中间产物canvas对象,用户转换为其他需要的格式
135
- getCanvasData: function (svg, backgroundColor) {
133
+ Snapshot.prototype.getCanvasData = function (svg, backgroundColor) {
136
134
  var _this = this;
137
135
  var copy = svg.cloneNode(true);
138
136
  var graph = copy.lastChild;
@@ -204,12 +202,15 @@ var Snapshot = {
204
202
  因为svg中存在dom存放在foreignObject元素中
205
203
  SVG图形转成img对象
206
204
  todo: 会导致一些清晰度问题这个需要再解决
205
+ fixme: XMLSerializer的中的css background url不会下载图片
207
206
  */
208
207
  var svg2Img = "data:image/svg+xml;charset=utf-8," + new XMLSerializer().serializeToString(copy);
209
208
  var imgSrc = svg2Img.replace(/\n/g, '').replace(/\t/g, '').replace(/#/g, '%23');
210
209
  img.src = imgSrc;
211
210
  });
212
- },
213
- };
211
+ };
212
+ Snapshot.pluginName = 'snapshot';
213
+ return Snapshot;
214
+ }());
214
215
  exports.Snapshot = Snapshot;
215
216
  exports.default = Snapshot;
@@ -10,17 +10,39 @@ var __assign = (this && this.__assign) || function () {
10
10
  };
11
11
  return __assign.apply(this, arguments);
12
12
  };
13
+ var __read = (this && this.__read) || function (o, n) {
14
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
15
+ if (!m) return o;
16
+ var i = m.call(o), r, ar = [], e;
17
+ try {
18
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
19
+ }
20
+ catch (error) { e = { error: error }; }
21
+ finally {
22
+ try {
23
+ if (r && !r.done && (m = i["return"])) m.call(i);
24
+ }
25
+ finally { if (e) throw e.error; }
26
+ }
27
+ return ar;
28
+ };
13
29
  Object.defineProperty(exports, "__esModule", { value: true });
14
- exports.TurboAdapter = exports.toLogicflowData = exports.toTurboData = void 0;
15
- var TurboType;
16
- (function (TurboType) {
17
- TurboType[TurboType["SEQUENCE_FLOW"] = 1] = "SEQUENCE_FLOW";
18
- TurboType[TurboType["START_EVENT"] = 2] = "START_EVENT";
19
- TurboType[TurboType["END_EVENT"] = 3] = "END_EVENT";
20
- TurboType[TurboType["USER_TASK"] = 4] = "USER_TASK";
30
+ exports.toLogicflowData = exports.toTurboData = void 0;
31
+ var TurboType = {
32
+ SEQUENCE_FLOW: 1,
33
+ START_EVENT: 2,
34
+ END_EVENT: 3,
35
+ USER_TASK: 4,
21
36
  // SERVICE_TASK = 5, 暂不支持
22
- TurboType[TurboType["EXCLUSIVE_GATEWAY"] = 6] = "EXCLUSIVE_GATEWAY";
23
- })(TurboType || (TurboType = {}));
37
+ EXCLUSIVE_GATEWAY: 6,
38
+ };
39
+ var TurboTypeMap = {
40
+ 1: 'bpmn:sequenceFlow',
41
+ 2: 'bpmn:startEvent',
42
+ 3: 'bpmn:endEvent',
43
+ 4: 'bpmn:userTask',
44
+ 6: 'bpmn:exclusiveGateway',
45
+ };
24
46
  // 转换Turbo识别的类型
25
47
  function getTurboType(type) {
26
48
  switch (type) {
@@ -50,7 +72,7 @@ function convertNodeToTurboElement(node) {
50
72
  type: getTurboType(node.type),
51
73
  properties: __assign(__assign({}, properties), { name: (text && text.value) || '', x: x,
52
74
  y: y,
53
- text: text, logicFlowType: type }),
75
+ text: text }),
54
76
  key: id,
55
77
  };
56
78
  }
@@ -62,10 +84,7 @@ function convertEdgeToTurboElement(edge) {
62
84
  outgoing: [targetNodeId],
63
85
  type: getTurboType(type),
64
86
  dockers: [],
65
- properties: __assign(__assign({}, properties), { name: (text && text.value) || '', text: text,
66
- startPoint: startPoint,
67
- endPoint: endPoint,
68
- pointsList: pointsList, logicFlowType: type }),
87
+ properties: __assign(__assign({}, properties), { name: (text && text.value) || '', text: text, startPoint: JSON.stringify(startPoint), endPoint: JSON.stringify(endPoint), pointsList: JSON.stringify(text) }),
69
88
  key: id,
70
89
  };
71
90
  }
@@ -93,21 +112,30 @@ function toTurboData(data) {
93
112
  exports.toTurboData = toTurboData;
94
113
  // 将Turbo元素数据转换为LogicFlow中的Edge数据
95
114
  function convertFlowElementToEdge(element) {
96
- var incoming = element.incoming, outgoing = element.outgoing, properties = element.properties, key = element.key;
97
- var text = properties.text, startPoint = properties.startPoint, endPoint = properties.endPoint, pointsList = properties.pointsList, logicFlowType = properties.logicFlowType;
115
+ var incoming = element.incoming, outgoing = element.outgoing, properties = element.properties, key = element.key, type = element.type;
116
+ var text = properties.text, name = properties.name, startPoint = properties.startPoint, endPoint = properties.endPoint, pointsList = properties.pointsList;
98
117
  var edge = {
99
118
  id: key,
100
- type: logicFlowType,
119
+ type: TurboTypeMap[type],
101
120
  sourceNodeId: incoming[0],
102
121
  targetNodeId: outgoing[0],
103
- text: text,
104
- startPoint: startPoint,
105
- endPoint: endPoint,
106
- pointsList: pointsList,
122
+ text: text || name,
107
123
  properties: {},
108
124
  };
125
+ if (startPoint) {
126
+ // @ts-ignore
127
+ edge.startPoint = JSON.parse(startPoint);
128
+ }
129
+ if (endPoint) {
130
+ // @ts-ignore
131
+ edge.endPoint = JSON.parse(endPoint);
132
+ }
133
+ if (pointsList) {
134
+ // @ts-ignore
135
+ edge.endPoint = JSON.parse(pointsList);
136
+ }
109
137
  // 这种转换方式,在自定义属性中不能与excludeProperties中的属性重名,否则将在转换过程中丢失
110
- var excludeProperties = ['startPoint', 'endPoint', 'pointsList', 'text', 'logicFlowType'];
138
+ var excludeProperties = ['startPoint', 'endPoint', 'pointsList', 'text'];
111
139
  Object.keys(element.properties).forEach(function (property) {
112
140
  if (excludeProperties.indexOf(property) === -1) {
113
141
  edge.properties[property] = element.properties[property];
@@ -117,18 +145,23 @@ function convertFlowElementToEdge(element) {
117
145
  }
118
146
  // 将Turbo元素数据转换为LogicFlow中的Node数据
119
147
  function convertFlowElementToNode(element) {
120
- var properties = element.properties, key = element.key;
121
- var x = properties.x, y = properties.y, text = properties.text, logicFlowType = properties.logicFlowType;
148
+ var properties = element.properties, key = element.key, type = element.type, bounds = element.bounds;
149
+ var x = properties.x, y = properties.y;
150
+ if (x === undefined) {
151
+ var _a = __read(bounds, 2), _b = _a[0], x1 = _b.x, y1 = _b.y, _c = _a[1], x2 = _c.x, y2 = _c.y;
152
+ x = (x1 + x2) / 2;
153
+ y = (y1 + y2) / 2;
154
+ }
122
155
  var node = {
123
156
  id: key,
124
- type: logicFlowType,
157
+ type: TurboTypeMap[type],
125
158
  x: x,
126
159
  y: y,
127
- text: text,
160
+ text: properties.text,
128
161
  properties: {},
129
162
  };
130
163
  // 这种转换方式,在自定义属性中不能与excludeProperties中的属性重名,否则将在转换过程中丢失
131
- var excludeProperties = ['x', 'y', 'text', 'logicFlowType'];
164
+ var excludeProperties = ['x', 'y', 'text'];
132
165
  Object.keys(element.properties).forEach(function (property) {
133
166
  if (excludeProperties.indexOf(property) === -1) {
134
167
  node.properties[property] = element.properties[property];
@@ -156,26 +189,23 @@ function toLogicflowData(data) {
156
189
  return lfData;
157
190
  }
158
191
  exports.toLogicflowData = toLogicflowData;
159
- var TurboAdapter = {
160
- pluginName: 'turboAdapter',
161
- install: function (lf) {
192
+ var TurboAdapter = /** @class */ (function () {
193
+ function TurboAdapter(_a) {
194
+ var lf = _a.lf;
162
195
  lf.adapterIn = this.adapterIn;
163
196
  lf.adapterOut = this.adapterOut;
164
- },
165
- shapeConfigMap: new Map(),
166
- setCustomShape: function (key, val) {
167
- this.shapeConfigMap.set(key, val);
168
- },
169
- adapterOut: function (logicflowData) {
197
+ }
198
+ TurboAdapter.prototype.adapterOut = function (logicflowData) {
170
199
  if (logicflowData) {
171
200
  return toTurboData(logicflowData);
172
201
  }
173
- },
174
- adapterIn: function (turboData) {
202
+ };
203
+ TurboAdapter.prototype.adapterIn = function (turboData) {
175
204
  if (turboData) {
176
205
  return toLogicflowData(turboData);
177
206
  }
178
- },
179
- };
180
- exports.TurboAdapter = TurboAdapter;
207
+ };
208
+ TurboAdapter.pluginName = 'turboAdapter';
209
+ return TurboAdapter;
210
+ }());
181
211
  exports.default = TurboAdapter;
@@ -35,9 +35,11 @@ var Control = /** @class */ (function (_super) {
35
35
  _this.updatePosition = function (_a) {
36
36
  var deltaX = _a.deltaX, deltaY = _a.deltaY;
37
37
  var _b = _this.nodeModel, x = _b.x, y = _b.y;
38
- _this.nodeModel.x = x + deltaX / 2;
39
- _this.nodeModel.y = y + deltaY / 2;
40
38
  _this.nodeModel.moveText(deltaX / 2, deltaY / 2);
39
+ _this.nodeModel.updateAttributes({
40
+ x: x + deltaX / 2,
41
+ y: y + deltaY / 2,
42
+ });
41
43
  };
42
44
  // 计算control拖动后,节点的宽高
43
45
  _this.getResize = function (_a) {
@@ -53,7 +55,7 @@ var Control = /** @class */ (function (_super) {
53
55
  resize.height = height - deltaY * pct;
54
56
  break;
55
57
  case 2:
56
- resize.width = width + deltaX;
58
+ resize.width = width + deltaX * pct;
57
59
  resize.height = height + deltaY * pct;
58
60
  break;
59
61
  case 3:
@@ -91,14 +93,16 @@ var Control = /** @class */ (function (_super) {
91
93
  }
92
94
  _this.updatePosition({ deltaX: deltaX, deltaY: deltaY });
93
95
  // 更新宽高
94
- _this.nodeModel.width = size.width;
95
- _this.nodeModel.height = size.height;
96
96
  _this.nodeModel.setProperties({
97
97
  nodeSize: {
98
98
  width: size.width,
99
99
  height: size.height,
100
100
  },
101
101
  });
102
+ _this.nodeModel.updateAttributes({
103
+ width: size.width,
104
+ height: size.height,
105
+ });
102
106
  var edges = _this.getNodeEdges(id);
103
107
  var beforeNode = {
104
108
  x: x,
@@ -161,9 +165,9 @@ var Control = /** @class */ (function (_super) {
161
165
  _this.updatePosition({ deltaX: deltaX, deltaY: deltaY });
162
166
  // 更新rx ry,宽高为计算属性自动更新
163
167
  // @ts-ignore
164
- _this.nodeModel.rx = _this.nodeModel.rx + deltaX / 2;
168
+ _this.nodeModel.rx = size.width;
165
169
  // @ts-ignore
166
- _this.nodeModel.ry = _this.nodeModel.ry + deltaY / 2;
170
+ _this.nodeModel.ry = size.height;
167
171
  _this.nodeModel.setProperties({
168
172
  nodeSize: {
169
173
  rx: size.width,
@@ -225,9 +229,9 @@ var Control = /** @class */ (function (_super) {
225
229
  _this.updatePosition({ deltaX: deltaX, deltaY: deltaY });
226
230
  // 更新rx ry,宽高为计算属性自动更新
227
231
  // @ts-ignore
228
- _this.nodeModel.rx = _this.nodeModel.rx + deltaX / 2;
232
+ _this.nodeModel.rx = size.width;
229
233
  // @ts-ignore
230
- _this.nodeModel.ry = _this.nodeModel.ry + deltaY / 2;
234
+ _this.nodeModel.ry = size.height;
231
235
  _this.nodeModel.setProperties({
232
236
  nodeSize: {
233
237
  rx: size.width,
@@ -1,7 +1,7 @@
1
1
  import { h, DiamondNode, DiamondNodeModel } from '@logicflow/core';
2
2
  declare class DiamondResizeModel extends DiamondNodeModel {
3
- constructor(data: any, graphModel: any);
4
3
  initNodeData(data: any): void;
4
+ init(): void;
5
5
  getOutlineStyle(): import("@logicflow/core/types/constant/DefaultTheme").OutlineTheme;
6
6
  getResizeOutlineStyle(): {
7
7
  stroke: string;
@@ -27,14 +27,8 @@ import ControlGroup from '../Control/ControlGroup';
27
27
  import Polygon from '../BasicShape/Polygon';
28
28
  var DiamondResizeModel = /** @class */ (function (_super) {
29
29
  __extends(DiamondResizeModel, _super);
30
- function DiamondResizeModel(data, graphModel) {
31
- var _this = _super.call(this, data, graphModel) || this;
32
- var nodeSize = _this.properties.nodeSize;
33
- if (nodeSize) {
34
- _this.rx = nodeSize.rx;
35
- _this.ry = nodeSize.ry;
36
- }
37
- return _this;
30
+ function DiamondResizeModel() {
31
+ return _super !== null && _super.apply(this, arguments) || this;
38
32
  }
39
33
  DiamondResizeModel.prototype.initNodeData = function (data) {
40
34
  _super.prototype.initNodeData.call(this, data);
@@ -44,6 +38,14 @@ var DiamondResizeModel = /** @class */ (function (_super) {
44
38
  this.maxHeight = 2000;
45
39
  this.gridSize = 1;
46
40
  };
41
+ DiamondResizeModel.prototype.init = function () {
42
+ _super.prototype.init.call(this);
43
+ var nodeSize = this.properties.nodeSize;
44
+ if (nodeSize) {
45
+ this.rx = nodeSize.rx;
46
+ this.ry = nodeSize.ry;
47
+ }
48
+ };
47
49
  DiamondResizeModel.prototype.getOutlineStyle = function () {
48
50
  var style = _super.prototype.getOutlineStyle.call(this);
49
51
  style.stroke = 'none';
@@ -1,7 +1,7 @@
1
1
  import { h, EllipseNode, EllipseNodeModel } from '@logicflow/core';
2
2
  declare class EllipseResizeModel extends EllipseNodeModel {
3
- constructor(data: any, graphModel: any);
4
3
  initNodeData(data: any): void;
4
+ init(): void;
5
5
  getOutlineStyle(): import("@logicflow/core/types/constant/DefaultTheme").OutlineTheme;
6
6
  getResizeOutlineStyle(): {
7
7
  stroke: string;
@@ -15,14 +15,8 @@ import { h, EllipseNode, EllipseNodeModel } from '@logicflow/core';
15
15
  import ControlGroup from '../Control/ControlGroup';
16
16
  var EllipseResizeModel = /** @class */ (function (_super) {
17
17
  __extends(EllipseResizeModel, _super);
18
- function EllipseResizeModel(data, graphModel) {
19
- var _this = _super.call(this, data, graphModel) || this;
20
- var nodeSize = _this.properties.nodeSize;
21
- if (nodeSize) {
22
- _this.rx = nodeSize.rx;
23
- _this.ry = nodeSize.ry;
24
- }
25
- return _this;
18
+ function EllipseResizeModel() {
19
+ return _super !== null && _super.apply(this, arguments) || this;
26
20
  }
27
21
  EllipseResizeModel.prototype.initNodeData = function (data) {
28
22
  _super.prototype.initNodeData.call(this, data);
@@ -31,6 +25,14 @@ var EllipseResizeModel = /** @class */ (function (_super) {
31
25
  this.maxWidth = 2000;
32
26
  this.maxHeight = 2000;
33
27
  };
28
+ EllipseResizeModel.prototype.init = function () {
29
+ _super.prototype.init.call(this);
30
+ var nodeSize = this.properties.nodeSize;
31
+ if (nodeSize) {
32
+ this.rx = nodeSize.rx;
33
+ this.ry = nodeSize.ry;
34
+ }
35
+ };
34
36
  EllipseResizeModel.prototype.getOutlineStyle = function () {
35
37
  var style = _super.prototype.getOutlineStyle.call(this);
36
38
  style.stroke = 'none';
@@ -1,7 +1,7 @@
1
1
  import { h, HtmlNode, HtmlNodeModel } from '@logicflow/core';
2
2
  declare class HtmlResizeModel extends HtmlNodeModel {
3
- constructor(data: any, graphModel: any);
4
3
  initNodeData(data: any): void;
4
+ init(): void;
5
5
  getOutlineStyle(): import("@logicflow/core/types/constant/DefaultTheme").OutlineTheme;
6
6
  getResizeOutlineStyle(): {
7
7
  stroke: string;
@@ -15,14 +15,8 @@ import { h, HtmlNode, HtmlNodeModel } from '@logicflow/core';
15
15
  import ControlGroup from '../Control/ControlGroup';
16
16
  var HtmlResizeModel = /** @class */ (function (_super) {
17
17
  __extends(HtmlResizeModel, _super);
18
- function HtmlResizeModel(data, graphModel) {
19
- var _this = _super.call(this, data, graphModel) || this;
20
- var nodeSize = _this.properties.nodeSize;
21
- if (nodeSize) {
22
- _this.width = nodeSize.width;
23
- _this.height = nodeSize.height;
24
- }
25
- return _this;
18
+ function HtmlResizeModel() {
19
+ return _super !== null && _super.apply(this, arguments) || this;
26
20
  }
27
21
  HtmlResizeModel.prototype.initNodeData = function (data) {
28
22
  _super.prototype.initNodeData.call(this, data);
@@ -31,6 +25,14 @@ var HtmlResizeModel = /** @class */ (function (_super) {
31
25
  this.maxWidth = 2000;
32
26
  this.maxHeight = 2000;
33
27
  };
28
+ HtmlResizeModel.prototype.init = function () {
29
+ _super.prototype.init.call(this);
30
+ var nodeSize = this.properties.nodeSize;
31
+ if (nodeSize) {
32
+ this.width = nodeSize.width;
33
+ this.height = nodeSize.height;
34
+ }
35
+ };
34
36
  HtmlResizeModel.prototype.getOutlineStyle = function () {
35
37
  var style = _super.prototype.getOutlineStyle.call(this);
36
38
  style.stroke = 'none';
@@ -1,7 +1,7 @@
1
1
  import { h, RectNode, RectNodeModel } from '@logicflow/core';
2
2
  declare class RectResizeModel extends RectNodeModel {
3
- constructor(data: any, graphModel: any);
4
3
  initNodeData(data: any): void;
4
+ init(): void;
5
5
  getOutlineStyle(): import("@logicflow/core/types/constant/DefaultTheme").OutlineTheme;
6
6
  getResizeOutlineStyle(): {
7
7
  fill: string;
@@ -15,14 +15,8 @@ import { h, RectNode, RectNodeModel } from '@logicflow/core';
15
15
  import ControlGroup from '../Control/ControlGroup';
16
16
  var RectResizeModel = /** @class */ (function (_super) {
17
17
  __extends(RectResizeModel, _super);
18
- function RectResizeModel(data, graphModel) {
19
- var _this = _super.call(this, data, graphModel) || this;
20
- var nodeSize = _this.properties.nodeSize;
21
- if (nodeSize) {
22
- _this.width = nodeSize.width;
23
- _this.height = nodeSize.height;
24
- }
25
- return _this;
18
+ function RectResizeModel() {
19
+ return _super !== null && _super.apply(this, arguments) || this;
26
20
  }
27
21
  RectResizeModel.prototype.initNodeData = function (data) {
28
22
  _super.prototype.initNodeData.call(this, data);
@@ -31,6 +25,14 @@ var RectResizeModel = /** @class */ (function (_super) {
31
25
  this.maxWidth = 2000;
32
26
  this.maxHeight = 2000;
33
27
  };
28
+ RectResizeModel.prototype.init = function () {
29
+ _super.prototype.init.call(this);
30
+ var nodeSize = this.properties.nodeSize;
31
+ if (nodeSize) {
32
+ this.width = nodeSize.width;
33
+ this.height = nodeSize.height;
34
+ }
35
+ };
34
36
  RectResizeModel.prototype.getOutlineStyle = function () {
35
37
  var style = _super.prototype.getOutlineStyle.call(this);
36
38
  style.stroke = 'none';
@@ -176,7 +176,7 @@ function convertLf2ProcessData(bpmnProcessData, data) {
176
176
  return edgeConfig;
177
177
  });
178
178
  // @see https://github.com/didi/LogicFlow/issues/325
179
- // 需要保证incomming在outgoing之前
179
+ // 需要保证incoming在outgoing之前
180
180
  data.edges.forEach(function (edge) {
181
181
  var sourceNode = nodeMap.get(edge.sourceNodeId);
182
182
  if (!sourceNode['bpmn:outgoing']) {