@logicflow/extension 1.0.7 → 1.1.0-alpha.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 (87) hide show
  1. package/cjs/NodeResize/Control/Control.js +2 -1
  2. package/cjs/NodeResize/Control/Util.js +1 -0
  3. package/cjs/NodeResize/Node/EllipseResize.js +1 -17
  4. package/cjs/NodeResize/Node/HtmlResize.js +72 -0
  5. package/cjs/NodeResize/index.js +7 -1
  6. package/cjs/bpmn/index.js +1 -1
  7. package/cjs/bpmn-adapter/index.js +1 -1
  8. package/cjs/components/context-menu/index.js +38 -23
  9. package/cjs/components/control/index.js +0 -14
  10. package/cjs/components/dnd-panel/index.js +9 -6
  11. package/cjs/components/menu/index.js +7 -7
  12. package/cjs/components/mini-map/index.js +159 -156
  13. package/cjs/components/selection-select/index.js +27 -14
  14. package/cjs/insert-node-in-polyline/index.js +1 -1
  15. package/cjs/materials/curved-edge/index.js +1 -1
  16. package/cjs/materials/group/GroupNode.js +66 -20
  17. package/cjs/materials/group/index.js +28 -9
  18. package/cjs/style/index.css +3 -2
  19. package/cjs/tools/flow-path/index.js +1 -1
  20. package/cjs/turbo-adapter/index.js +1 -1
  21. package/es/NodeResize/Control/Control.js +2 -1
  22. package/es/NodeResize/Control/Util.d.ts +1 -0
  23. package/es/NodeResize/Control/Util.js +1 -0
  24. package/es/NodeResize/Node/EllipseResize.js +1 -17
  25. package/es/NodeResize/Node/HtmlResize.d.ts +20 -0
  26. package/es/NodeResize/Node/HtmlResize.js +70 -0
  27. package/es/NodeResize/index.js +7 -1
  28. package/es/bpmn/index.js +1 -1
  29. package/es/bpmn-adapter/index.js +1 -1
  30. package/es/components/context-menu/index.d.ts +11 -1
  31. package/es/components/context-menu/index.js +38 -23
  32. package/es/components/control/index.d.ts +4 -5
  33. package/es/components/control/index.js +0 -14
  34. package/es/components/dnd-panel/index.d.ts +1 -0
  35. package/es/components/dnd-panel/index.js +9 -6
  36. package/es/components/menu/index.d.ts +2 -2
  37. package/es/components/menu/index.js +7 -7
  38. package/es/components/mini-map/index.d.ts +73 -2
  39. package/es/components/mini-map/index.js +159 -156
  40. package/es/components/selection-select/index.d.ts +8 -0
  41. package/es/components/selection-select/index.js +27 -14
  42. package/es/insert-node-in-polyline/index.js +1 -1
  43. package/es/materials/curved-edge/index.js +1 -1
  44. package/es/materials/group/GroupNode.d.ts +24 -9
  45. package/es/materials/group/GroupNode.js +67 -21
  46. package/es/materials/group/index.d.ts +3 -1
  47. package/es/materials/group/index.js +27 -9
  48. package/es/style/index.css +3 -2
  49. package/es/tools/flow-path/index.js +1 -1
  50. package/es/turbo-adapter/index.js +1 -1
  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/FlowPath.js +1 -1
  59. package/lib/Group.js +1 -1
  60. package/lib/InsertNodeInPolyline.js +1 -1
  61. package/lib/Menu.js +1 -1
  62. package/lib/MiniMap.js +1 -1
  63. package/lib/NodeResize.js +1 -1
  64. package/lib/RectLabelNode.js +1 -1
  65. package/lib/SelectionSelect.js +1 -1
  66. package/lib/Snapshot.js +1 -1
  67. package/lib/TurboAdapter.js +1 -1
  68. package/lib/lfJson2Xml.js +1 -1
  69. package/lib/lfXml2Json.js +1 -1
  70. package/lib/style/index.css +3 -2
  71. package/package.json +2 -2
  72. package/types/NodeResize/Control/Util.d.ts +1 -0
  73. package/types/NodeResize/Node/HtmlResize.d.ts +20 -0
  74. package/types/components/context-menu/index.d.ts +11 -1
  75. package/types/components/control/index.d.ts +4 -5
  76. package/types/components/dnd-panel/index.d.ts +1 -0
  77. package/types/components/menu/index.d.ts +2 -2
  78. package/types/components/mini-map/index.d.ts +73 -2
  79. package/types/components/selection-select/index.d.ts +8 -0
  80. package/types/materials/group/GroupNode.d.ts +24 -9
  81. package/types/materials/group/index.d.ts +3 -1
  82. package/cjs/NodeResize/BasicShape/Ellipse.js +0 -21
  83. package/cjs/curved.js +0 -0
  84. package/es/NodeResize/BasicShape/Ellipse.d.ts +0 -2
  85. package/es/NodeResize/BasicShape/Ellipse.js +0 -18
  86. package/es/curved.d.ts +0 -0
  87. package/es/curved.js +0 -0
@@ -12,48 +12,92 @@ var __values = (this && this.__values) || function(o) {
12
12
  };
13
13
  Object.defineProperty(exports, "__esModule", { value: true });
14
14
  exports.MiniMap = void 0;
15
- // interface MiniMapPlugin extends Extension {
16
- // init: (option) => void;
17
- // show: (leftPosition?: number, topPosition?: number) => void;
18
- // hide: () => void;
19
- // [x: string]: any;
20
- // }
21
- var MiniMap = {
22
- pluginName: 'minimap',
23
- __lf: null,
24
- __container: null,
25
- __miniMapWrap: null,
26
- __miniMapContainer: null,
27
- __lfMap: null,
28
- __viewport: null,
29
- __width: 150,
30
- __height: 220,
31
- __miniMapWidth: 450,
32
- __miniMapHeight: 660,
33
- __viewPortTop: 0,
34
- __viewPortLeft: 0,
35
- __startPosition: null,
36
- __viewPortScale: 1,
37
- __viewPortWidth: 150,
38
- __viewPortHeight: 75,
39
- __resetDataX: 0,
40
- __resetDataY: 0,
41
- __LogicFlow: null,
42
- __disabledPlugins: ['minimap', 'control', 'selection-select'],
43
- install: function (lf, LogicFlow) {
44
- MiniMap.__lf = lf;
45
- MiniMap.__miniMapWidth = lf.graphModel.width;
46
- MiniMap.__miniMapHeight = (lf.graphModel.width * 220) / 150;
47
- MiniMap.__LogicFlow = LogicFlow;
15
+ var MiniMap = /** @class */ (function () {
16
+ function MiniMap(_a) {
17
+ var _this = this;
18
+ var lf = _a.lf, LogicFlow = _a.LogicFlow;
19
+ this.__lf = null;
20
+ this.__container = null;
21
+ this.__miniMapWrap = null;
22
+ this.__miniMapContainer = null;
23
+ this.__lfMap = null;
24
+ this.__viewport = null;
25
+ this.__width = 150;
26
+ this.__height = 220;
27
+ this.__miniMapWidth = 450;
28
+ this.__miniMapHeight = 660;
29
+ this.__viewPortTop = 0;
30
+ this.__viewPortLeft = 0;
31
+ this.__startPosition = null;
32
+ this.__viewPortScale = 1;
33
+ this.__viewPortWidth = 150;
34
+ this.__viewPortHeight = 75;
35
+ this.__resetDataX = 0;
36
+ this.__resetDataY = 0;
37
+ this.__LogicFlow = null;
38
+ this.__isShow = false;
39
+ this.__disabledPlugins = ['miniMap', 'control', 'selectionSelect'];
40
+ /**
41
+ * 显示mini map
42
+ */
43
+ this.show = function (leftPosition, topPosition) {
44
+ _this.__setView();
45
+ if (!_this.__isShow) {
46
+ _this.__createMiniMap(leftPosition, topPosition);
47
+ }
48
+ _this.__isShow = true;
49
+ };
50
+ /**
51
+ * 隐藏mini map
52
+ */
53
+ this.hide = function () {
54
+ if (_this.__isShow) {
55
+ _this.__removeMiniMap();
56
+ }
57
+ _this.__isShow = false;
58
+ };
59
+ this.__startDrag = function (e) {
60
+ document.addEventListener('mousemove', _this.__drag);
61
+ document.addEventListener('mouseup', _this.__drop);
62
+ _this.__startPosition = {
63
+ x: e.x,
64
+ y: e.y,
65
+ };
66
+ };
67
+ this.__drag = function (e) {
68
+ var viewStyle = _this.__viewport.style;
69
+ _this.__viewPortTop += e.y - _this.__startPosition.y;
70
+ _this.__viewPortLeft += e.x - _this.__startPosition.x;
71
+ viewStyle.top = _this.__viewPortTop + "px";
72
+ viewStyle.left = _this.__viewPortLeft + "px";
73
+ _this.__startPosition = {
74
+ x: e.x,
75
+ y: e.y,
76
+ };
77
+ var centerX = (_this.__viewPortLeft + _this.__viewPortWidth / 2)
78
+ / _this.__viewPortScale;
79
+ var centerY = (_this.__viewPortTop + _this.__viewPortHeight / 2)
80
+ / _this.__viewPortScale;
81
+ _this.__lf.focusOn({
82
+ coordinate: {
83
+ x: centerX + _this.__resetDataX,
84
+ y: centerY + _this.__resetDataY,
85
+ },
86
+ });
87
+ };
88
+ this.__drop = function () {
89
+ document.removeEventListener('mousemove', _this.__drag);
90
+ document.removeEventListener('mouseup', _this.__drop);
91
+ };
92
+ this.__lf = lf;
93
+ this.__miniMapWidth = lf.graphModel.width;
94
+ this.__miniMapHeight = (lf.graphModel.width * 220) / 150;
95
+ this.__LogicFlow = LogicFlow;
48
96
  this.__init();
49
- // 避免多次install的时候, _isShow状态被修改了
50
- MiniMap.__isShow = false;
51
- },
52
- init: function (option) {
53
- this.__disabledPlugins = this.__disabledPlugins.concat(option.disabledPlugins || []);
54
- },
55
- render: function (lf, container) {
56
- MiniMap.__container = container;
97
+ }
98
+ MiniMap.prototype.render = function (lf, container) {
99
+ var _this = this;
100
+ this.__container = container;
57
101
  var events = [
58
102
  'node:add',
59
103
  'node:delete',
@@ -63,34 +107,24 @@ var MiniMap = {
63
107
  'blank:drop',
64
108
  ];
65
109
  events.forEach(function (eventName) {
66
- MiniMap.__lf.on(eventName, function () {
67
- if (MiniMap.__isShow) {
68
- MiniMap.__setView();
110
+ _this.__lf.on(eventName, function () {
111
+ if (_this.__isShow) {
112
+ _this.__setView();
69
113
  }
70
114
  });
71
115
  });
72
- },
73
- show: function (leftPosition, topPosition) {
74
- MiniMap.__setView();
75
- if (!MiniMap.__isShow) {
76
- MiniMap.__createMiniMap(leftPosition, topPosition);
77
- }
78
- MiniMap.__isShow = true;
79
- },
80
- hide: function () {
81
- if (MiniMap.__isShow) {
82
- MiniMap.__removeMiniMap();
83
- }
84
- MiniMap.__isShow = false;
85
- },
86
- __init: function () {
116
+ };
117
+ MiniMap.prototype.init = function (option) {
118
+ this.__disabledPlugins = this.__disabledPlugins.concat(option.disabledPlugins || []);
119
+ };
120
+ MiniMap.prototype.__init = function () {
87
121
  var miniMapWrap = document.createElement('div');
88
122
  miniMapWrap.className = 'lf-mini-map-graph';
89
- miniMapWrap.style.width = MiniMap.__width + "px";
90
- miniMapWrap.style.height = MiniMap.__height + "px";
91
- MiniMap.__lfMap = new MiniMap.__LogicFlow({
92
- width: MiniMap.__lf.graphModel.width,
93
- height: (MiniMap.__lf.graphModel.width * 220) / 150,
123
+ miniMapWrap.style.width = this.__width + "px";
124
+ miniMapWrap.style.height = this.__height + "px";
125
+ this.__lfMap = new this.__LogicFlow({
126
+ width: this.__lf.graphModel.width,
127
+ height: (this.__lf.graphModel.width * 220) / 150,
94
128
  container: miniMapWrap,
95
129
  isSilentMode: true,
96
130
  stopZoomGraph: true,
@@ -98,17 +132,17 @@ var MiniMap = {
98
132
  stopMoveGraph: true,
99
133
  hideAnchors: true,
100
134
  hoverOutline: false,
101
- disabledPlugins: MiniMap.__disabledPlugins,
135
+ disabledPlugins: this.__disabledPlugins,
102
136
  });
103
137
  // minimap中禁用adapter。
104
- MiniMap.__lfMap.adapterIn = function (a) { return a; };
105
- MiniMap.__lfMap.adapterOut = function (a) { return a; };
106
- MiniMap.__miniMapWrap = miniMapWrap;
107
- MiniMap.__createViewPort();
108
- },
109
- __createMiniMap: function (left, top) {
138
+ this.__lfMap.adapterIn = function (a) { return a; };
139
+ this.__lfMap.adapterOut = function (a) { return a; };
140
+ this.__miniMapWrap = miniMapWrap;
141
+ this.__createViewPort();
142
+ };
143
+ MiniMap.prototype.__createMiniMap = function (left, top) {
110
144
  var miniMapContainer = document.createElement('div');
111
- var miniMapWrap = MiniMap.__miniMapWrap;
145
+ var miniMapWrap = this.__miniMapWrap;
112
146
  miniMapContainer.appendChild(miniMapWrap);
113
147
  if (typeof left !== 'undefined' && typeof top !== 'undefined') {
114
148
  miniMapContainer.style.left = left + "px";
@@ -116,30 +150,30 @@ var MiniMap = {
116
150
  }
117
151
  miniMapContainer.style.position = 'absolute';
118
152
  miniMapContainer.className = 'lf-mini-map';
119
- MiniMap.__container.appendChild(miniMapContainer);
120
- MiniMap.__miniMapWrap.appendChild(MiniMap.__viewport);
153
+ this.__container.appendChild(miniMapContainer);
154
+ this.__miniMapWrap.appendChild(this.__viewport);
121
155
  var header = document.createElement('div');
122
156
  header.className = 'lf-mini-map-header';
123
157
  header.innerText = '导航';
124
158
  miniMapContainer.appendChild(header);
125
159
  var close = document.createElement('span');
126
160
  close.className = 'lf-mini-map-close';
127
- close.addEventListener('click', MiniMap.hide);
161
+ close.addEventListener('click', this.hide);
128
162
  miniMapContainer.appendChild(close);
129
- MiniMap.__miniMapContainer = miniMapContainer;
130
- },
131
- __removeMiniMap: function () {
132
- MiniMap.__container.removeChild(MiniMap.__miniMapContainer);
133
- },
163
+ this.__miniMapContainer = miniMapContainer;
164
+ };
165
+ MiniMap.prototype.__removeMiniMap = function () {
166
+ this.__container.removeChild(this.__miniMapContainer);
167
+ };
134
168
  /**
135
169
  * 计算所有图形一起,占领的区域范围。
136
170
  * @param data
137
171
  */
138
- __getBounds: function (data) {
172
+ MiniMap.prototype.__getBounds = function (data) {
139
173
  var left = 0;
140
- var right = MiniMap.__miniMapWidth;
174
+ var right = this.__miniMapWidth;
141
175
  var top = 0;
142
- var bottom = MiniMap.__miniMapHeight;
176
+ var bottom = this.__miniMapHeight;
143
177
  var nodes = data.nodes;
144
178
  if (nodes && nodes.length > 0) {
145
179
  // 因为获取的节点不知道真实的宽高,这里需要补充一点数值
@@ -161,13 +195,13 @@ var MiniMap = {
161
195
  bottom: bottom,
162
196
  right: right,
163
197
  };
164
- },
198
+ };
165
199
  /**
166
200
  * 将负值的平移转换为正值。
167
201
  * 保证渲染的时候,minimap能完全展示。
168
202
  * 获取将画布所有元素平移到0,0开始时,所有节点数据
169
203
  */
170
- __resetData: function (data) {
204
+ MiniMap.prototype.__resetData = function (data) {
171
205
  var nodes = data.nodes, edges = data.edges;
172
206
  var left = 0;
173
207
  var top = 0;
@@ -181,8 +215,8 @@ var MiniMap = {
181
215
  top = nodeTop < top ? nodeTop : top;
182
216
  });
183
217
  if (left < 0 || top < 0) {
184
- MiniMap.__resetDataX = left;
185
- MiniMap.__resetDataY = top;
218
+ this.__resetDataX = left;
219
+ this.__resetDataY = top;
186
220
  nodes.forEach(function (node) {
187
221
  node.x = node.x - left;
188
222
  node.y = node.y - top;
@@ -214,27 +248,27 @@ var MiniMap = {
214
248
  }
215
249
  }
216
250
  return data;
217
- },
251
+ };
218
252
  /**
219
253
  * 显示导航
220
254
  * 显示视口范围
221
255
  * 1. 基于画布的范围比例,设置视口范围比例。宽度默认为导航宽度。
222
256
  */
223
- __setView: function () {
257
+ MiniMap.prototype.__setView = function () {
224
258
  var e_1, _a;
225
259
  // 1. 获取到图中所有的节点中的位置,将其偏移到原点开始(避免节点位置为负的时候无法展示问题)。
226
- var data = MiniMap.__resetData(MiniMap.__lf.getGraphRawData());
260
+ var data = this.__resetData(this.__lf.getGraphRawData());
227
261
  // 由于随时都会有新节点注册进来,需要同步将注册的
228
- var viewMap = MiniMap.__lf.viewMap;
229
- var modelMap = MiniMap.__lf.graphModel.modelMap;
230
- var minimapViewMap = MiniMap.__lfMap.viewMap;
262
+ var viewMap = this.__lf.viewMap;
263
+ var modelMap = this.__lf.graphModel.modelMap;
264
+ var minimapViewMap = this.__lfMap.viewMap;
231
265
  try {
232
266
  // todo: no-restricted-syntax
233
267
  for (var _b = __values(viewMap.keys()), _c = _b.next(); !_c.done; _c = _b.next()) {
234
268
  var key = _c.value;
235
269
  if (!minimapViewMap.has(key)) {
236
- MiniMap.__lfMap.setView(key, viewMap.get(key));
237
- MiniMap.__lfMap.graphModel.modelMap.set(key, modelMap.get(key));
270
+ this.__lfMap.setView(key, viewMap.get(key));
271
+ this.__lfMap.graphModel.modelMap.set(key, modelMap.get(key));
238
272
  }
239
273
  }
240
274
  }
@@ -245,91 +279,60 @@ var MiniMap = {
245
279
  }
246
280
  finally { if (e_1) throw e_1.error; }
247
281
  }
248
- MiniMap.__lfMap.render(data);
282
+ this.__lfMap.render(data);
249
283
  // 2. 将偏移后的数据渲染到minimap画布上
250
284
  // 3. 计算出所有节点在一起的边界。
251
- var _d = MiniMap.__getBounds(data), left = _d.left, top = _d.top, right = _d.right, bottom = _d.bottom;
285
+ var _d = this.__getBounds(data), left = _d.left, top = _d.top, right = _d.right, bottom = _d.bottom;
252
286
  // 4. 计算所有节点的边界与minimap看板的边界的比例.
253
- var realWidthScale = MiniMap.__width / (right - left);
254
- var realHeightScale = MiniMap.__height / (bottom - top);
287
+ var realWidthScale = this.__width / (right - left);
288
+ var realHeightScale = this.__height / (bottom - top);
255
289
  // 5. 取比例最小的值,将渲染的画布缩小对应比例。
256
- var innerStyle = MiniMap.__miniMapWrap.firstChild.style;
290
+ var innerStyle = this.__miniMapWrap.firstChild.style;
257
291
  var scale = Math.min(realWidthScale, realHeightScale);
258
292
  innerStyle.transform = "matrix(" + scale + ", 0, 0, " + scale + ", 0, 0)";
259
293
  innerStyle.transformOrigin = 'left top';
260
294
  innerStyle.height = bottom - Math.min(top, 0) + "px";
261
295
  innerStyle.width = right - Math.min(left, 0) + "px";
262
- MiniMap.__viewPortScale = scale;
263
- MiniMap.__setViewPort(scale, {
296
+ this.__viewPortScale = scale;
297
+ this.__setViewPort(scale, {
264
298
  left: left,
265
299
  top: top,
266
300
  right: right,
267
301
  bottom: bottom,
268
302
  });
269
- },
303
+ };
270
304
  // 设置视口
271
- __setViewPort: function (scale, _a) {
272
- var left = _a.left, right = _a.right;
273
- var viewStyle = MiniMap.__viewport.style;
274
- viewStyle.width = MiniMap.__width - 4 + "px";
275
- viewStyle.height = (MiniMap.__width - 4) / (MiniMap.__lf.graphModel.width / MiniMap.__lf.graphModel.height) + "px";
305
+ MiniMap.prototype.__setViewPort = function (scale, _a) {
306
+ var left = _a.left, right = _a.right, top = _a.top, bottom = _a.bottom;
307
+ var viewStyle = this.__viewport.style;
308
+ viewStyle.width = this.__width - 4 + "px";
309
+ viewStyle.height = (this.__width - 4) / (this.__lf.graphModel.width / this.__lf.graphModel.height) + "px";
276
310
  // top
277
- var _b = MiniMap.__lf.getTransform(), TRANSLATE_X = _b.TRANSLATE_X, TRANSLATE_Y = _b.TRANSLATE_Y;
311
+ var _b = this.__lf.getTransform(), TRANSLATE_X = _b.TRANSLATE_X, TRANSLATE_Y = _b.TRANSLATE_Y;
278
312
  var realWidth = right - left;
279
313
  // 视口实际宽 = 视口默认宽 / (所有元素一起占据的真实宽 / 绘布宽)
280
- var realViewPortWidth = (MiniMap.__width - 4) / (realWidth / MiniMap.__lf.graphModel.width);
314
+ var realViewPortWidth = (this.__width - 4) / (realWidth / this.__lf.graphModel.width);
281
315
  // 视口实际高 = 视口实际宽 / (绘布宽 / 绘布高)
282
- var graphRatio = (MiniMap.__lf.graphModel.width / MiniMap.__lf.graphModel.height);
316
+ var graphRatio = (this.__lf.graphModel.width / this.__lf.graphModel.height);
283
317
  var realViewPortHeight = realViewPortWidth / graphRatio;
284
- MiniMap.__viewPortTop = TRANSLATE_Y > 0 ? 0 : -TRANSLATE_Y * scale;
285
- MiniMap.__viewPortLeft = -TRANSLATE_X * scale;
286
- MiniMap.__viewPortWidth = realViewPortWidth;
287
- MiniMap.__viewPortHeight = realViewPortHeight;
288
- viewStyle.top = MiniMap.__viewPortTop + "px";
289
- viewStyle.left = MiniMap.__viewPortLeft + "px";
318
+ this.__viewPortTop = TRANSLATE_Y > 0 ? 0 : -TRANSLATE_Y * scale;
319
+ this.__viewPortLeft = -TRANSLATE_X * scale;
320
+ this.__viewPortWidth = realViewPortWidth;
321
+ this.__viewPortHeight = realViewPortHeight;
322
+ viewStyle.top = this.__viewPortTop + "px";
323
+ viewStyle.left = this.__viewPortLeft + "px";
290
324
  viewStyle.width = realViewPortWidth + "px";
291
325
  viewStyle.height = realViewPortHeight + "px";
292
- },
326
+ };
293
327
  // 预览视窗
294
- __createViewPort: function () {
328
+ MiniMap.prototype.__createViewPort = function () {
295
329
  var div = document.createElement('div');
296
330
  div.className = 'lf-minimap-viewport';
297
- div.addEventListener('mousedown', MiniMap.__startDrag);
298
- MiniMap.__viewport = div;
299
- },
300
- __startDrag: function (e) {
301
- document.addEventListener('mousemove', MiniMap.__drag);
302
- document.addEventListener('mouseup', MiniMap.__drop);
303
- MiniMap.__startPosition = {
304
- x: e.x,
305
- y: e.y,
306
- };
307
- },
308
- __drag: function (e) {
309
- var viewStyle = MiniMap.__viewport.style;
310
- MiniMap.__viewPortTop += e.y - MiniMap.__startPosition.y;
311
- MiniMap.__viewPortLeft += e.x - MiniMap.__startPosition.x;
312
- viewStyle.top = MiniMap.__viewPortTop + "px";
313
- viewStyle.left = MiniMap.__viewPortLeft + "px";
314
- MiniMap.__startPosition = {
315
- x: e.x,
316
- y: e.y,
317
- };
318
- var centerX = (MiniMap.__viewPortLeft + MiniMap.__viewPortWidth / 2)
319
- / MiniMap.__viewPortScale;
320
- var centerY = (MiniMap.__viewPortTop + MiniMap.__viewPortHeight / 2)
321
- / MiniMap.__viewPortScale;
322
- MiniMap.__lf.focusOn({
323
- coordinate: {
324
- x: centerX + MiniMap.__resetDataX,
325
- y: centerY + MiniMap.__resetDataY,
326
- },
327
- });
328
- },
329
- __drop: function () {
330
- document.removeEventListener('mousemove', MiniMap.__drag);
331
- document.removeEventListener('mouseup', MiniMap.__drop);
332
- },
333
- };
331
+ div.addEventListener('mousedown', this.__startDrag);
332
+ this.__viewport = div;
333
+ };
334
+ MiniMap.pluginName = 'miniMap';
335
+ return MiniMap;
336
+ }());
334
337
  exports.MiniMap = MiniMap;
335
338
  exports.default = MiniMap;
@@ -48,21 +48,10 @@ var SelectionSelect = /** @class */ (function () {
48
48
  var stopMoveGraph = lf.getEditConfig().stopMoveGraph;
49
49
  this.isDefalutStopMoveGraph = stopMoveGraph;
50
50
  lf.openSelectionSelect = function () {
51
- if (!stopMoveGraph) {
52
- _this.isDefalutStopMoveGraph = false;
53
- lf.updateEditConfig({
54
- stopMoveGraph: true,
55
- });
56
- }
57
- _this.open();
51
+ _this.openSelectionSelect();
58
52
  };
59
53
  lf.closeSelectionSelect = function () {
60
- if (!_this.isDefalutStopMoveGraph) {
61
- lf.updateEditConfig({
62
- stopMoveGraph: false,
63
- });
64
- }
65
- _this.close();
54
+ _this.closeSelectionSelect();
66
55
  };
67
56
  }
68
57
  SelectionSelect.prototype.render = function (lf, domContainer) {
@@ -88,13 +77,37 @@ var SelectionSelect = /** @class */ (function () {
88
77
  document.addEventListener('mouseup', _this.__drawOff);
89
78
  });
90
79
  };
80
+ /**
81
+ * 开启选区
82
+ */
83
+ SelectionSelect.prototype.openSelectionSelect = function () {
84
+ var stopMoveGraph = this.lf.getEditConfig().stopMoveGraph;
85
+ if (!stopMoveGraph) {
86
+ this.isDefalutStopMoveGraph = false;
87
+ this.lf.updateEditConfig({
88
+ stopMoveGraph: true,
89
+ });
90
+ }
91
+ this.open();
92
+ };
93
+ /**
94
+ * 关闭选区
95
+ */
96
+ SelectionSelect.prototype.closeSelectionSelect = function () {
97
+ if (!this.isDefalutStopMoveGraph) {
98
+ this.lf.updateEditConfig({
99
+ stopMoveGraph: false,
100
+ });
101
+ }
102
+ this.close();
103
+ };
91
104
  SelectionSelect.prototype.open = function () {
92
105
  this.__disabled = false;
93
106
  };
94
107
  SelectionSelect.prototype.close = function () {
95
108
  this.__disabled = true;
96
109
  };
97
- SelectionSelect.pluginName = 'selection-select';
110
+ SelectionSelect.pluginName = 'selectionSelect';
98
111
  return SelectionSelect;
99
112
  }());
100
113
  exports.SelectionSelect = SelectionSelect;
@@ -23,7 +23,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
23
23
  exports.InsertNodeInPolyline = void 0;
24
24
  var edge_1 = require("./edge");
25
25
  var InsertNodeInPolyline = {
26
- pluginName: 'insert-node-in-polyline',
26
+ pluginName: 'insertNodeInPolyline',
27
27
  _lf: null,
28
28
  dndAdd: true,
29
29
  dropAdd: true,
@@ -81,7 +81,7 @@ var CurvedEdgeView = /** @class */ (function (_super) {
81
81
  strokeDashArray: strokeDashArray,
82
82
  });
83
83
  };
84
- CurvedEdgeView.extendKey = 'CurvedEdge';
84
+ CurvedEdgeView.extendKey = 'curvedEdge';
85
85
  return CurvedEdgeView;
86
86
  }(core_1.PolylineEdge));
87
87
  var CurvedEdgeModel = /** @class */ (function (_super) {
@@ -12,6 +12,17 @@ var __extends = (this && this.__extends) || (function () {
12
12
  d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
13
13
  };
14
14
  })();
15
+ var __assign = (this && this.__assign) || function () {
16
+ __assign = Object.assign || function(t) {
17
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
18
+ s = arguments[i];
19
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
20
+ t[p] = s[p];
21
+ }
22
+ return t;
23
+ };
24
+ return __assign.apply(this, arguments);
25
+ };
15
26
  var __read = (this && this.__read) || function (o, n) {
16
27
  var m = typeof Symbol === "function" && o[Symbol.iterator];
17
28
  if (!m) return o;
@@ -34,27 +45,31 @@ var __spread = (this && this.__spread) || function () {
34
45
  };
35
46
  Object.defineProperty(exports, "__esModule", { value: true });
36
47
  var core_1 = require("@logicflow/core");
48
+ var NodeResize_1 = require("../../NodeResize");
37
49
  var GroupNodeModel = /** @class */ (function (_super) {
38
50
  __extends(GroupNodeModel, _super);
39
51
  function GroupNodeModel() {
40
52
  var _this = _super !== null && _super.apply(this, arguments) || this;
41
53
  _this.isGroup = true;
42
- _this.children = new Set();
43
- _this.isRestrict = true; // 其子节点是否被禁止通过拖拽移出分组。 默认false,允许拖拽移除分组。
44
54
  return _this;
45
55
  }
46
- GroupNodeModel.prototype.setAttributes = function () {
56
+ GroupNodeModel.prototype.initNodeData = function (data) {
57
+ _super.prototype.initNodeData.call(this, data);
58
+ var children = [];
59
+ if (Array.isArray(data.children)) {
60
+ children = data.children;
61
+ }
62
+ // 初始化组的子节点
63
+ this.children = new Set(children);
47
64
  this.width = 500;
48
65
  this.height = 200;
49
- this.strokeWidth = 1;
50
- this.zIndex = 0;
66
+ // todo: 参考bpmn.js, 分组和未加入分组的节点重合时,未加入分组的节点在分组之下。方便标识。
67
+ this.zIndex = -1;
51
68
  this.radius = 0;
52
- };
53
- /**
54
- * 设置是否允许子节点被拖动移除分组
55
- */
56
- GroupNodeModel.prototype.setIsRestrict = function (isRestrict) {
57
- this.isRestrict = isRestrict;
69
+ this.text.editable = false;
70
+ this.text.draggable = false;
71
+ this.isRestrict = false;
72
+ this.resizable = false;
58
73
  };
59
74
  GroupNodeModel.prototype.isInRange = function (_a) {
60
75
  var x1 = _a.x1, y1 = _a.y1, x2 = _a.x2, y2 = _a.y2;
@@ -63,28 +78,40 @@ var GroupNodeModel = /** @class */ (function (_super) {
63
78
  && y1 >= (this.y - this.height / 2)
64
79
  && y2 <= (this.y + this.height / 2);
65
80
  };
66
- // todo: 更好的方式定义分组的样式
67
81
  GroupNodeModel.prototype.setAllowAppendChild = function (isAllow) {
68
- if (isAllow) {
69
- this.stroke = 'red';
70
- }
71
- else {
72
- this.stroke = 'rgb(24, 125, 255)';
73
- }
82
+ this.setProperty('groupAddable', isAllow);
74
83
  };
84
+ /**
85
+ * 添加分组子节点
86
+ * @param id 节点id
87
+ */
75
88
  GroupNodeModel.prototype.addChild = function (id) {
76
89
  this.children.add(id);
77
90
  };
91
+ /**
92
+ * 删除分组子节点
93
+ * @param id 节点id
94
+ */
78
95
  GroupNodeModel.prototype.removeChild = function (id) {
79
96
  this.children.delete(id);
80
97
  };
98
+ GroupNodeModel.prototype.getAddableOutlineStyle = function () {
99
+ return {
100
+ stroke: '#FEB663',
101
+ strokeWidth: 2,
102
+ strokeDasharray: '4 4',
103
+ fill: 'transparent',
104
+ };
105
+ };
81
106
  GroupNodeModel.prototype.getData = function () {
82
107
  var data = _super.prototype.getData.call(this);
83
108
  data.children = __spread(this.children);
109
+ var properties = data.properties;
110
+ delete properties.groupAddable;
84
111
  return data;
85
112
  };
86
113
  return GroupNodeModel;
87
- }(core_1.RectNodeModel));
114
+ }(NodeResize_1.RectResize.model));
88
115
  var GroupNode = /** @class */ (function (_super) {
89
116
  __extends(GroupNode, _super);
90
117
  function GroupNode() {
@@ -94,8 +121,27 @@ var GroupNode = /** @class */ (function (_super) {
94
121
  * 重新toFront,阻止其置顶
95
122
  */
96
123
  GroupNode.prototype.toFront = function () { };
124
+ GroupNode.prototype.getControlGroup = function () {
125
+ return this.props.model.resizable ? _super.prototype.getControlGroup.call(this) : null;
126
+ };
127
+ GroupNode.prototype.getAddedableShape = function () {
128
+ var _a = this.props.model, width = _a.width, height = _a.height, x = _a.x, y = _a.y, radius = _a.radius, properties = _a.properties;
129
+ if (!properties.groupAddable)
130
+ return null;
131
+ var strokeWidth = this.props.model.getNodeStyle().strokeWidth;
132
+ var style = this.props.model.getAddableOutlineStyle();
133
+ var newWidth = width + strokeWidth + 8;
134
+ var newHeight = height + strokeWidth + 8;
135
+ return core_1.h('rect', __assign(__assign({}, style), { width: newWidth, height: newHeight, x: x - newWidth / 2, y: y - newHeight / 2, rx: radius, ry: radius }));
136
+ };
137
+ GroupNode.prototype.getResizeShape = function () {
138
+ return core_1.h('g', {}, [
139
+ this.getAddedableShape(),
140
+ _super.prototype.getResizeShape.call(this),
141
+ ]);
142
+ };
97
143
  return GroupNode;
98
- }(core_1.RectNode));
144
+ }(NodeResize_1.RectResize.view));
99
145
  exports.default = {
100
146
  type: 'group',
101
147
  view: GroupNode,