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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (104) hide show
  1. package/cjs/NodeResize/Control/Control.js +71 -16
  2. package/cjs/NodeResize/Node/DiamondResize.js +24 -10
  3. package/cjs/NodeResize/Node/EllipseResize.js +24 -10
  4. package/cjs/NodeResize/Node/HtmlResize.js +24 -10
  5. package/cjs/NodeResize/Node/RectResize.js +24 -10
  6. package/cjs/bpmn-adapter/index.js +74 -122
  7. package/cjs/bpmn-adapter/json2xml.js +2 -4
  8. package/cjs/bpmn-adapter/xml2json.js +247 -2
  9. package/cjs/components/control/index.js +16 -16
  10. package/cjs/components/dnd-panel/index.js +21 -0
  11. package/cjs/components/highlight/index.js +0 -1
  12. package/cjs/components/menu/index.js +9 -9
  13. package/cjs/components/mini-map/index.js +223 -138
  14. package/cjs/components/selection-select/index.js +6 -19
  15. package/cjs/index.js +0 -1
  16. package/cjs/materials/curved-edge/index.js +19 -5
  17. package/cjs/materials/curved-edge/searchMiddleIndex.js +17 -0
  18. package/cjs/materials/group/GroupNode.js +34 -65
  19. package/cjs/materials/group/index.js +80 -70
  20. package/cjs/style/index.css +10 -0
  21. package/cjs/tools/auto-layout/index.js +1 -1
  22. package/es/NodeResize/Control/Control.d.ts +4 -1
  23. package/es/NodeResize/Control/Control.js +71 -16
  24. package/es/NodeResize/Node/DiamondResize.d.ts +3 -1
  25. package/es/NodeResize/Node/DiamondResize.js +24 -10
  26. package/es/NodeResize/Node/EllipseResize.d.ts +3 -1
  27. package/es/NodeResize/Node/EllipseResize.js +24 -10
  28. package/es/NodeResize/Node/HtmlResize.d.ts +3 -1
  29. package/es/NodeResize/Node/HtmlResize.js +24 -10
  30. package/es/NodeResize/Node/RectResize.d.ts +3 -1
  31. package/es/NodeResize/Node/RectResize.js +24 -10
  32. package/es/bpmn-adapter/index.d.ts +33 -41
  33. package/es/bpmn-adapter/index.js +74 -122
  34. package/es/bpmn-adapter/json2xml.js +2 -4
  35. package/es/bpmn-adapter/xml2json.js +247 -2
  36. package/es/components/control/index.d.ts +3 -2
  37. package/es/components/control/index.js +16 -16
  38. package/es/components/dnd-panel/index.js +21 -0
  39. package/es/components/highlight/index.js +0 -1
  40. package/es/components/menu/index.d.ts +3 -2
  41. package/es/components/menu/index.js +9 -9
  42. package/es/components/mini-map/index.d.ts +57 -45
  43. package/es/components/mini-map/index.js +223 -138
  44. package/es/components/selection-select/index.d.ts +0 -1
  45. package/es/components/selection-select/index.js +6 -19
  46. package/es/index.d.ts +0 -1
  47. package/es/index.js +0 -1
  48. package/es/materials/curved-edge/index.js +19 -5
  49. package/es/materials/curved-edge/searchMiddleIndex.d.ts +1 -0
  50. package/es/materials/curved-edge/searchMiddleIndex.js +14 -0
  51. package/es/materials/group/GroupNode.d.ts +5 -7
  52. package/es/materials/group/GroupNode.js +34 -65
  53. package/es/materials/group/index.d.ts +19 -1
  54. package/es/materials/group/index.js +80 -70
  55. package/es/style/index.css +10 -0
  56. package/es/tools/auto-layout/index.d.ts +1 -1
  57. package/es/tools/auto-layout/index.js +1 -1
  58. package/lib/AutoLayout.js +1 -1
  59. package/lib/BpmnAdapter.js +1 -1
  60. package/lib/BpmnElement.js +1 -1
  61. package/lib/ContextMenu.js +1 -1
  62. package/lib/Control.js +1 -1
  63. package/lib/CurvedEdge.js +1 -1
  64. package/lib/DndPanel.js +1 -1
  65. package/lib/FlowPath.js +1 -1
  66. package/lib/Group.js +1 -1
  67. package/lib/Highlight.js +1 -1
  68. package/lib/InsertNodeInPolyline.js +1 -1
  69. package/lib/Menu.js +1 -1
  70. package/lib/MiniMap.js +1 -1
  71. package/lib/NodeResize.js +1 -1
  72. package/lib/RectLabelNode.js +1 -1
  73. package/lib/SelectionSelect.js +1 -1
  74. package/lib/Snapshot.js +1 -1
  75. package/lib/TurboAdapter.js +1 -1
  76. package/lib/lfJson2Xml.js +1 -1
  77. package/lib/lfXml2Json.js +1 -1
  78. package/lib/style/index.css +10 -0
  79. package/package.json +3 -2
  80. package/types/NodeResize/Control/Control.d.ts +4 -1
  81. package/types/NodeResize/Node/DiamondResize.d.ts +3 -1
  82. package/types/NodeResize/Node/EllipseResize.d.ts +3 -1
  83. package/types/NodeResize/Node/HtmlResize.d.ts +3 -1
  84. package/types/NodeResize/Node/RectResize.d.ts +3 -1
  85. package/types/bpmn-adapter/index.d.ts +33 -41
  86. package/types/components/control/index.d.ts +3 -2
  87. package/types/components/menu/index.d.ts +3 -2
  88. package/types/components/mini-map/index.d.ts +57 -45
  89. package/types/components/selection-select/index.d.ts +0 -1
  90. package/types/index.d.ts +0 -1
  91. package/types/materials/curved-edge/searchMiddleIndex.d.ts +1 -0
  92. package/types/materials/group/GroupNode.d.ts +5 -7
  93. package/types/materials/group/index.d.ts +19 -1
  94. package/types/tools/auto-layout/index.d.ts +1 -1
  95. package/cjs/locale/en-locale/en.js +0 -22
  96. package/cjs/locale/en-locale/index.js +0 -29
  97. package/cjs/locale/locale.js +0 -19
  98. package/es/locale/en-locale/en.d.ts +0 -19
  99. package/es/locale/en-locale/en.js +0 -19
  100. package/es/locale/en-locale/index.d.ts +0 -9
  101. package/es/locale/en-locale/index.js +0 -26
  102. package/es/locale/locale.d.ts +0 -6
  103. package/es/locale/locale.js +0 -16
  104. package/lib/EnLocale.js +0 -1
@@ -9,134 +9,180 @@ var __values = (this && this.__values) || function(o) {
9
9
  };
10
10
  throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
11
11
  };
12
+ import { throttle } from 'lodash-es';
12
13
  var MiniMap = /** @class */ (function () {
13
14
  function MiniMap(_a) {
14
15
  var _this = this;
15
- var lf = _a.lf, LogicFlow = _a.LogicFlow;
16
- this.__lf = null;
17
- this.__container = null;
18
- this.__miniMapWrap = null;
19
- this.__miniMapContainer = null;
20
- this.__lfMap = null;
21
- this.__viewport = null;
22
- this.__width = 150;
23
- this.__height = 220;
24
- this.__miniMapWidth = 450;
25
- this.__miniMapHeight = 660;
26
- this.__viewPortTop = 0;
27
- this.__viewPortLeft = 0;
28
- this.__startPosition = null;
29
- this.__viewPortScale = 1;
30
- this.__viewPortWidth = 150;
31
- this.__viewPortHeight = 75;
32
- this.__resetDataX = 0;
33
- this.__resetDataY = 0;
34
- this.__LogicFlow = null;
35
- this.__isShow = false;
36
- this.__disabledPlugins = ['miniMap', 'control', 'selectionSelect'];
16
+ var lf = _a.lf, LogicFlow = _a.LogicFlow, options = _a.options;
17
+ this.lf = null;
18
+ this.container = null;
19
+ this.miniMapWrap = null;
20
+ this.miniMapContainer = null;
21
+ this.lfMap = null;
22
+ this.viewport = null;
23
+ this.width = 150;
24
+ this.height = 220;
25
+ this.leftPosition = undefined;
26
+ this.topPosition = undefined;
27
+ this.rightPosition = undefined;
28
+ this.bottomPosition = undefined;
29
+ this.miniMapWidth = 450;
30
+ this.miniMapHeight = 660;
31
+ this.viewPortTop = 0;
32
+ this.viewPortLeft = 0;
33
+ this.startPosition = null;
34
+ this.viewPortScale = 1;
35
+ this.viewPortWidth = 150;
36
+ this.viewPortHeight = 75;
37
+ this.resetDataX = 0;
38
+ this.resetDataY = 0;
39
+ this.LogicFlow = null;
40
+ this.isShow = false;
41
+ this.isShowHeader = true;
42
+ this.isShowCloseIcon = true;
43
+ this.dragging = false;
44
+ this.disabledPlugins = ['miniMap', 'control', 'selectionSelect'];
37
45
  /**
38
46
  * 显示mini map
39
- */
47
+ */
40
48
  this.show = function (leftPosition, topPosition) {
41
- _this.__setView();
42
- if (!_this.__isShow) {
43
- _this.__createMiniMap(leftPosition, topPosition);
49
+ _this.setView();
50
+ if (!_this.isShow) {
51
+ _this.createMiniMap(leftPosition, topPosition);
44
52
  }
45
- _this.__isShow = true;
53
+ _this.isShow = true;
46
54
  };
47
55
  /**
48
56
  * 隐藏mini map
49
57
  */
50
58
  this.hide = function () {
51
- if (_this.__isShow) {
52
- _this.__removeMiniMap();
59
+ if (_this.isShow) {
60
+ _this.removeMiniMap();
53
61
  }
54
- _this.__isShow = false;
62
+ _this.isShow = false;
63
+ };
64
+ this.reset = function () {
65
+ _this.lf.resetTranslate();
66
+ _this.lf.resetZoom();
67
+ _this.hide();
68
+ _this.show();
55
69
  };
56
- this.__startDrag = function (e) {
57
- document.addEventListener('mousemove', _this.__drag);
58
- document.addEventListener('mouseup', _this.__drop);
59
- _this.__startPosition = {
70
+ this.startDrag = function (e) {
71
+ document.addEventListener('mousemove', _this.drag);
72
+ document.addEventListener('mouseup', _this.drop);
73
+ _this.startPosition = {
60
74
  x: e.x,
61
75
  y: e.y,
62
76
  };
63
77
  };
64
78
  this.moveViewport = function (top, left) {
65
- var viewStyle = _this.__viewport.style;
66
- _this.__viewPortTop = top;
67
- _this.__viewPortLeft = left;
68
- viewStyle.top = _this.__viewPortTop + "px";
69
- viewStyle.left = _this.__viewPortLeft + "px";
79
+ var viewStyle = _this.viewport.style;
80
+ _this.viewPortTop = top;
81
+ _this.viewPortLeft = left;
82
+ viewStyle.top = _this.viewPortTop + "px";
83
+ viewStyle.left = _this.viewPortLeft + "px";
70
84
  };
71
- this.__drag = function (e) {
72
- var top = _this.__viewPortTop + e.y - _this.__startPosition.y;
73
- var left = _this.__viewPortLeft + e.x - _this.__startPosition.x;
85
+ this.drag = function (e) {
86
+ _this.dragging = true;
87
+ var top = _this.viewPortTop + e.y - _this.startPosition.y;
88
+ var left = _this.viewPortLeft + e.x - _this.startPosition.x;
74
89
  _this.moveViewport(top, left);
75
- _this.__startPosition = {
90
+ _this.startPosition = {
76
91
  x: e.x,
77
92
  y: e.y,
78
93
  };
79
- var centerX = (_this.__viewPortLeft + _this.__viewPortWidth / 2)
80
- / _this.__viewPortScale;
81
- var centerY = (_this.__viewPortTop + _this.__viewPortHeight / 2)
82
- / _this.__viewPortScale;
83
- _this.__lf.focusOn({
94
+ var centerX = (_this.viewPortLeft + _this.viewPortWidth / 2)
95
+ / _this.viewPortScale;
96
+ var centerY = (_this.viewPortTop + _this.viewPortHeight / 2)
97
+ / _this.viewPortScale;
98
+ _this.lf.focusOn({
84
99
  coordinate: {
85
- x: centerX + _this.__resetDataX,
86
- y: centerY + _this.__resetDataY,
100
+ x: centerX + _this.resetDataX,
101
+ y: centerY + _this.resetDataY,
87
102
  },
88
103
  });
89
104
  };
90
- this.__drop = function () {
91
- document.removeEventListener('mousemove', _this.__drag);
92
- document.removeEventListener('mouseup', _this.__drop);
93
- var top = _this.__viewPortTop;
94
- var left = _this.__viewPortLeft;
95
- if (_this.__viewPortLeft > _this.__width) {
96
- left = _this.__width - _this.__viewPortWidth;
105
+ this.drop = function () {
106
+ document.removeEventListener('mousemove', _this.drag);
107
+ document.removeEventListener('mouseup', _this.drop);
108
+ var top = _this.viewPortTop;
109
+ var left = _this.viewPortLeft;
110
+ if (_this.viewPortLeft > _this.width) {
111
+ left = _this.width - _this.viewPortWidth;
97
112
  }
98
- if (_this.__viewPortTop > _this.__height) {
99
- top = _this.__height - _this.__viewPortHeight;
113
+ if (_this.viewPortTop > _this.height) {
114
+ top = _this.height - _this.viewPortHeight;
100
115
  }
101
- if (_this.__viewPortLeft < -_this.__width) {
116
+ if (_this.viewPortLeft < -_this.width) {
102
117
  left = 0;
103
118
  }
104
- if (_this.__viewPortTop < -_this.__height) {
119
+ if (_this.viewPortTop < -_this.height) {
105
120
  top = 0;
106
121
  }
107
122
  _this.moveViewport(top, left);
108
123
  };
109
- this.__lf = lf;
110
- this.__miniMapWidth = lf.graphModel.width;
111
- this.__miniMapHeight = (lf.graphModel.width * 220) / 150;
112
- this.__LogicFlow = LogicFlow;
113
- this.__init();
124
+ this.mapClick = function (e) {
125
+ if (_this.dragging) {
126
+ _this.dragging = false;
127
+ }
128
+ else {
129
+ var layerX = e.layerX, layerY = e.layerY;
130
+ var ViewPortCenterX = layerX;
131
+ var ViewPortCenterY = layerY;
132
+ var graphData = _this.lf.getGraphRawData();
133
+ var _a = _this.getBounds(graphData), left = _a.left, top_1 = _a.top;
134
+ var resetGraphX = left + ViewPortCenterX / _this.viewPortScale;
135
+ var resetGraphY = top_1 + ViewPortCenterY / _this.viewPortScale;
136
+ _this.lf.focusOn({ coordinate: { x: resetGraphX, y: resetGraphY } });
137
+ }
138
+ };
139
+ this.lf = lf;
140
+ if (options && options.MiniMap) {
141
+ this.setOption(options);
142
+ }
143
+ this.miniMapWidth = lf.graphModel.width;
144
+ this.miniMapHeight = (lf.graphModel.width * this.height) / this.width;
145
+ this.LogicFlow = LogicFlow;
146
+ this.initMiniMap();
114
147
  }
115
148
  MiniMap.prototype.render = function (lf, container) {
116
149
  var _this = this;
117
- this.__container = container;
118
- this.__lf.on('history:change', function () {
119
- if (_this.__isShow) {
120
- _this.__setView();
150
+ this.container = container;
151
+ this.lf.on('history:change', function () {
152
+ if (_this.isShow) {
153
+ _this.setView();
121
154
  }
122
155
  });
123
- this.__lf.on('blank:drop', function () {
124
- if (_this.__isShow) {
125
- _this.__setView();
156
+ this.lf.on('graph:transform', throttle(function () {
157
+ // 小地图已展示,并且没有拖拽小地图视口
158
+ if (_this.isShow && !_this.dragging) {
159
+ _this.setView();
126
160
  }
127
- });
161
+ }, 300));
128
162
  };
129
163
  MiniMap.prototype.init = function (option) {
130
- this.__disabledPlugins = this.__disabledPlugins.concat(option.disabledPlugins || []);
164
+ this.disabledPlugins = this.disabledPlugins.concat(option.disabledPlugins || []);
165
+ };
166
+ MiniMap.prototype.setOption = function (options) {
167
+ var _a = options.MiniMap, _b = _a.width, width = _b === void 0 ? 150 : _b, _c = _a.height, height = _c === void 0 ? 220 : _c, _d = _a.isShowHeader, isShowHeader = _d === void 0 ? true : _d, _e = _a.isShowCloseIcon, isShowCloseIcon = _e === void 0 ? true : _e, _f = _a.leftPosition, leftPosition = _f === void 0 ? 0 : _f, _g = _a.topPosition, topPosition = _g === void 0 ? 0 : _g, rightPosition = _a.rightPosition, bottomPosition = _a.bottomPosition;
168
+ this.width = width;
169
+ this.height = height;
170
+ this.isShowHeader = isShowHeader;
171
+ this.isShowCloseIcon = isShowCloseIcon;
172
+ this.viewPortWidth = width;
173
+ this.leftPosition = leftPosition;
174
+ this.topPosition = topPosition;
175
+ this.rightPosition = rightPosition;
176
+ this.bottomPosition = bottomPosition;
131
177
  };
132
- MiniMap.prototype.__init = function () {
178
+ MiniMap.prototype.initMiniMap = function () {
133
179
  var miniMapWrap = document.createElement('div');
134
180
  miniMapWrap.className = 'lf-mini-map-graph';
135
- miniMapWrap.style.width = this.__width + "px";
136
- miniMapWrap.style.height = this.__height + "px";
137
- this.__lfMap = new this.__LogicFlow({
138
- width: this.__lf.graphModel.width,
139
- height: (this.__lf.graphModel.width * 220) / 150,
181
+ miniMapWrap.style.width = this.width + 4 + "px";
182
+ miniMapWrap.style.height = this.height + "px";
183
+ this.lfMap = new this.LogicFlow({
184
+ width: this.lf.graphModel.width,
185
+ height: (this.lf.graphModel.width * this.height) / this.width,
140
186
  container: miniMapWrap,
141
187
  isSilentMode: true,
142
188
  stopZoomGraph: true,
@@ -144,48 +190,68 @@ var MiniMap = /** @class */ (function () {
144
190
  stopMoveGraph: true,
145
191
  hideAnchors: true,
146
192
  hoverOutline: false,
147
- disabledPlugins: this.__disabledPlugins,
193
+ disabledPlugins: this.disabledPlugins,
148
194
  });
149
195
  // minimap中禁用adapter。
150
- this.__lfMap.adapterIn = function (a) { return a; };
151
- this.__lfMap.adapterOut = function (a) { return a; };
152
- this.__miniMapWrap = miniMapWrap;
153
- this.__createViewPort();
196
+ this.lfMap.adapterIn = function (a) { return a; };
197
+ this.lfMap.adapterOut = function (a) { return a; };
198
+ this.miniMapWrap = miniMapWrap;
199
+ this.createViewPort();
200
+ miniMapWrap.addEventListener('click', this.mapClick);
154
201
  };
155
- MiniMap.prototype.__createMiniMap = function (left, top) {
202
+ MiniMap.prototype.createMiniMap = function (left, top) {
156
203
  var miniMapContainer = document.createElement('div');
157
- var miniMapWrap = this.__miniMapWrap;
158
- miniMapContainer.appendChild(miniMapWrap);
159
- if (typeof left !== 'undefined' && typeof top !== 'undefined') {
160
- miniMapContainer.style.left = left + "px";
161
- miniMapContainer.style.top = top + "px";
204
+ miniMapContainer.appendChild(this.miniMapWrap);
205
+ if (typeof left !== 'undefined' || typeof top !== 'undefined') {
206
+ miniMapContainer.style.left = (left || 0) + "px";
207
+ miniMapContainer.style.top = (top || 0) + "px";
208
+ }
209
+ else {
210
+ if (typeof this.rightPosition !== 'undefined') {
211
+ miniMapContainer.style.right = this.rightPosition + "px";
212
+ }
213
+ else if (typeof this.leftPosition !== 'undefined') {
214
+ miniMapContainer.style.left = this.leftPosition + "px";
215
+ }
216
+ if (typeof this.bottomPosition !== 'undefined') {
217
+ miniMapContainer.style.bottom = this.bottomPosition + "px";
218
+ }
219
+ else if (typeof this.topPosition !== 'undefined') {
220
+ miniMapContainer.style.top = this.topPosition + "px";
221
+ }
162
222
  }
163
223
  miniMapContainer.style.position = 'absolute';
164
224
  miniMapContainer.className = 'lf-mini-map';
165
- this.__container.appendChild(miniMapContainer);
166
- this.__miniMapWrap.appendChild(this.__viewport);
225
+ if (!this.isShowCloseIcon) {
226
+ miniMapContainer.classList.add('lf-mini-map-no-close-icon');
227
+ }
228
+ if (!this.isShowHeader) {
229
+ miniMapContainer.classList.add('lf-mini-map-no-header');
230
+ }
231
+ this.container.appendChild(miniMapContainer);
232
+ this.miniMapWrap.appendChild(this.viewport);
167
233
  var header = document.createElement('div');
168
234
  header.className = 'lf-mini-map-header';
169
- header.innerText = '导航';
235
+ header.innerText = MiniMap.headerTitle;
170
236
  miniMapContainer.appendChild(header);
171
237
  var close = document.createElement('span');
172
238
  close.className = 'lf-mini-map-close';
173
239
  close.addEventListener('click', this.hide);
174
240
  miniMapContainer.appendChild(close);
175
- this.__miniMapContainer = miniMapContainer;
241
+ this.miniMapContainer = miniMapContainer;
176
242
  };
177
- MiniMap.prototype.__removeMiniMap = function () {
178
- this.__container.removeChild(this.__miniMapContainer);
243
+ MiniMap.prototype.removeMiniMap = function () {
244
+ this.container.removeChild(this.miniMapContainer);
179
245
  };
180
246
  /**
181
247
  * 计算所有图形一起,占领的区域范围。
182
248
  * @param data
183
249
  */
184
- MiniMap.prototype.__getBounds = function (data) {
250
+ MiniMap.prototype.getBounds = function (data) {
185
251
  var left = 0;
186
- var right = this.__miniMapWidth;
252
+ var right = this.miniMapWidth;
187
253
  var top = 0;
188
- var bottom = this.__miniMapHeight;
254
+ var bottom = this.miniMapHeight;
189
255
  var nodes = data.nodes;
190
256
  if (nodes && nodes.length > 0) {
191
257
  // 因为获取的节点不知道真实的宽高,这里需要补充一点数值
@@ -213,7 +279,7 @@ var MiniMap = /** @class */ (function () {
213
279
  * 保证渲染的时候,minimap能完全展示。
214
280
  * 获取将画布所有元素平移到0,0开始时,所有节点数据
215
281
  */
216
- MiniMap.prototype.__resetData = function (data) {
282
+ MiniMap.prototype.resetData = function (data) {
217
283
  var nodes = data.nodes, edges = data.edges;
218
284
  var left = 0;
219
285
  var top = 0;
@@ -227,8 +293,8 @@ var MiniMap = /** @class */ (function () {
227
293
  top = nodeTop < top ? nodeTop : top;
228
294
  });
229
295
  if (left < 0 || top < 0) {
230
- this.__resetDataX = left;
231
- this.__resetDataY = top;
296
+ this.resetDataX = left;
297
+ this.resetDataY = top;
232
298
  nodes.forEach(function (node) {
233
299
  node.x = node.x - left;
234
300
  node.y = node.y - top;
@@ -266,21 +332,22 @@ var MiniMap = /** @class */ (function () {
266
332
  * 显示视口范围
267
333
  * 1. 基于画布的范围比例,设置视口范围比例。宽度默认为导航宽度。
268
334
  */
269
- MiniMap.prototype.__setView = function () {
335
+ MiniMap.prototype.setView = function () {
270
336
  var e_1, _a;
271
337
  // 1. 获取到图中所有的节点中的位置,将其偏移到原点开始(避免节点位置为负的时候无法展示问题)。
272
- var data = this.__resetData(this.__lf.getGraphRawData());
338
+ var graphData = this.lf.getGraphRawData();
339
+ var data = this.resetData(graphData);
273
340
  // 由于随时都会有新节点注册进来,需要同步将注册的
274
- var viewMap = this.__lf.viewMap;
275
- var modelMap = this.__lf.graphModel.modelMap;
276
- var minimapViewMap = this.__lfMap.viewMap;
341
+ var viewMap = this.lf.viewMap;
342
+ var modelMap = this.lf.graphModel.modelMap;
343
+ var minimapViewMap = this.lfMap.viewMap;
277
344
  try {
278
345
  // todo: no-restricted-syntax
279
346
  for (var _b = __values(viewMap.keys()), _c = _b.next(); !_c.done; _c = _b.next()) {
280
347
  var key = _c.value;
281
348
  if (!minimapViewMap.has(key)) {
282
- this.__lfMap.setView(key, viewMap.get(key));
283
- this.__lfMap.graphModel.modelMap.set(key, modelMap.get(key));
349
+ this.lfMap.setView(key, viewMap.get(key));
350
+ this.lfMap.graphModel.modelMap.set(key, modelMap.get(key));
284
351
  }
285
352
  }
286
353
  }
@@ -291,22 +358,22 @@ var MiniMap = /** @class */ (function () {
291
358
  }
292
359
  finally { if (e_1) throw e_1.error; }
293
360
  }
294
- this.__lfMap.render(data);
361
+ this.lfMap.render(data);
295
362
  // 2. 将偏移后的数据渲染到minimap画布上
296
363
  // 3. 计算出所有节点在一起的边界。
297
- var _d = this.__getBounds(data), left = _d.left, top = _d.top, right = _d.right, bottom = _d.bottom;
364
+ var _d = this.getBounds(data), left = _d.left, top = _d.top, right = _d.right, bottom = _d.bottom;
298
365
  // 4. 计算所有节点的边界与minimap看板的边界的比例.
299
- var realWidthScale = this.__width / (right - left);
300
- var realHeightScale = this.__height / (bottom - top);
366
+ var realWidthScale = this.width / (right - left);
367
+ var realHeightScale = this.height / (bottom - top);
301
368
  // 5. 取比例最小的值,将渲染的画布缩小对应比例。
302
- var innerStyle = this.__miniMapWrap.firstChild.style;
369
+ var innerStyle = this.miniMapWrap.firstChild.style;
303
370
  var scale = Math.min(realWidthScale, realHeightScale);
304
371
  innerStyle.transform = "matrix(" + scale + ", 0, 0, " + scale + ", 0, 0)";
305
372
  innerStyle.transformOrigin = 'left top';
306
373
  innerStyle.height = bottom - Math.min(top, 0) + "px";
307
374
  innerStyle.width = right - Math.min(left, 0) + "px";
308
- this.__viewPortScale = scale;
309
- this.__setViewPort(scale, {
375
+ this.viewPortScale = scale;
376
+ this.setViewPort(scale, {
310
377
  left: left,
311
378
  top: top,
312
379
  right: right,
@@ -314,36 +381,54 @@ var MiniMap = /** @class */ (function () {
314
381
  });
315
382
  };
316
383
  // 设置视口
317
- MiniMap.prototype.__setViewPort = function (scale, _a) {
384
+ MiniMap.prototype.setViewPort = function (scale, _a) {
318
385
  var left = _a.left, right = _a.right, top = _a.top, bottom = _a.bottom;
319
- var viewStyle = this.__viewport.style;
320
- viewStyle.width = this.__width - 4 + "px";
321
- viewStyle.height = (this.__width - 4) / (this.__lf.graphModel.width / this.__lf.graphModel.height) + "px";
322
- // top
323
- var _b = this.__lf.getTransform(), TRANSLATE_X = _b.TRANSLATE_X, TRANSLATE_Y = _b.TRANSLATE_Y;
386
+ var viewStyle = this.viewport.style;
387
+ viewStyle.width = this.viewPortWidth + "px";
388
+ viewStyle.height = (this.viewPortWidth) / (this.lf.graphModel.width / this.lf.graphModel.height) + "px";
389
+ var _b = this.lf.getTransform(), TRANSLATE_X = _b.TRANSLATE_X, TRANSLATE_Y = _b.TRANSLATE_Y, SCALE_X = _b.SCALE_X, SCALE_Y = _b.SCALE_Y;
324
390
  var realWidth = right - left;
325
- // 视口实际宽 = 视口默认宽 / (所有元素一起占据的真实宽 / 绘布宽)
326
- var realViewPortWidth = (this.__width - 4) / (realWidth / this.__lf.graphModel.width);
391
+ // 视口宽 = 小地图宽 / (所有元素一起占据的真实宽 / 绘布宽)
392
+ var viewPortWidth = (this.width) / (realWidth / this.lf.graphModel.width);
393
+ // 实际视口宽 = 小地图宽 * 占宽度比例
394
+ var realViewPortWidth = this.width * (viewPortWidth / this.width);
395
+ var graphRatio = (this.lf.graphModel.width / this.lf.graphModel.height);
327
396
  // 视口实际高 = 视口实际宽 / (绘布宽 / 绘布高)
328
- var graphRatio = (this.__lf.graphModel.width / this.__lf.graphModel.height);
329
397
  var realViewPortHeight = realViewPortWidth / graphRatio;
330
- this.__viewPortTop = TRANSLATE_Y > 0 ? 0 : -TRANSLATE_Y * scale;
331
- this.__viewPortLeft = TRANSLATE_X > 0 ? 0 : -TRANSLATE_X * scale;
332
- this.__viewPortWidth = realViewPortWidth;
333
- this.__viewPortHeight = realViewPortHeight;
334
- viewStyle.top = this.__viewPortTop + "px";
335
- viewStyle.left = this.__viewPortLeft + "px";
336
- viewStyle.width = realViewPortWidth + "px";
337
- viewStyle.height = realViewPortHeight + "px";
398
+ var graphData = this.lf.getGraphRawData();
399
+ var _c = this.getBounds(graphData), graphLeft = _c.left, graphTop = _c.top;
400
+ var viewportLeft = graphLeft;
401
+ var viewportTop = graphTop;
402
+ viewportLeft += TRANSLATE_X / SCALE_X;
403
+ viewportTop += TRANSLATE_Y / SCALE_Y;
404
+ this.viewPortTop = viewportTop > 0 ? 0 : (-viewportTop * scale);
405
+ this.viewPortLeft = viewportLeft > 0 ? 0 : (-viewportLeft * scale);
406
+ this.viewPortWidth = realViewPortWidth;
407
+ this.viewPortHeight = realViewPortHeight;
408
+ viewStyle.top = this.viewPortTop + "px";
409
+ viewStyle.left = this.viewPortLeft + "px";
410
+ viewStyle.width = realViewPortWidth / SCALE_X + "px";
411
+ viewStyle.height = realViewPortHeight / SCALE_Y + "px";
338
412
  };
339
413
  // 预览视窗
340
- MiniMap.prototype.__createViewPort = function () {
414
+ MiniMap.prototype.createViewPort = function () {
341
415
  var div = document.createElement('div');
342
416
  div.className = 'lf-minimap-viewport';
343
- div.addEventListener('mousedown', this.__startDrag);
344
- this.__viewport = div;
417
+ div.addEventListener('mousedown', this.startDrag);
418
+ this.viewport = div;
345
419
  };
346
420
  MiniMap.pluginName = 'miniMap';
421
+ MiniMap.width = 150;
422
+ MiniMap.height = 220;
423
+ MiniMap.viewPortWidth = 150;
424
+ MiniMap.viewPortHeight = 75;
425
+ MiniMap.isShowHeader = true;
426
+ MiniMap.isShowCloseIcon = true;
427
+ MiniMap.leftPosition = 0;
428
+ MiniMap.topPosition = 0;
429
+ MiniMap.rightPosition = null;
430
+ MiniMap.bottomPosition = null;
431
+ MiniMap.headerTitle = '导航';
347
432
  return MiniMap;
348
433
  }());
349
434
  export default MiniMap;
@@ -36,7 +36,6 @@ declare class SelectionSelect {
36
36
  closeSelectionSelect(): void;
37
37
  __draw: (ev: any) => void;
38
38
  __drawOff: () => void;
39
- isSelectElement(elementModel: any): boolean;
40
39
  open(): void;
41
40
  close(): void;
42
41
  }
@@ -45,7 +45,7 @@ var SelectionSelect = /** @class */ (function () {
45
45
  var group = _this.lf.graphModel.group;
46
46
  elements.forEach(function (element) {
47
47
  // 如果节点属于分组,则不不选中节点
48
- if (_this.isSelectElement(element)) {
48
+ if (!group || !group.getNodeGroup(element.id)) {
49
49
  _this.lf.selectElementById(element.id, true);
50
50
  }
51
51
  });
@@ -72,6 +72,11 @@ var SelectionSelect = /** @class */ (function () {
72
72
  if (!config.stopMoveGraph || _this.__disabled) {
73
73
  return;
74
74
  }
75
+ // 禁用右键框选,修复可能导致画布出现多个框选框不消失的问题,见https://github.com/didi/LogicFlow/issues/985
76
+ var isRightClick = e.button === 2;
77
+ if (isRightClick) {
78
+ return;
79
+ }
75
80
  var _b = lf.getPointByClient(e.clientX, e.clientY).domOverlayPosition, x = _b.x, y = _b.y;
76
81
  _this.startPoint = { x: x, y: y };
77
82
  _this.endPoint = { x: x, y: y };
@@ -123,24 +128,6 @@ var SelectionSelect = /** @class */ (function () {
123
128
  }
124
129
  this.close();
125
130
  };
126
- SelectionSelect.prototype.isSelectElement = function (elementModel) {
127
- // 如果不可见,则不被选中
128
- if (!elementModel.visible)
129
- return false;
130
- var group = this.lf.extension.group;
131
- // 节点在group中,则不被选中
132
- if (group) {
133
- if (elementModel.BaseType === 'node' && group.getNodeGroup(elementModel.id))
134
- return false;
135
- if (elementModel.BaseType === 'edge') {
136
- if (group.getNodeGroup(elementModel.sourceNodeId)
137
- || group.getNodeGroup(elementModel.targetNodeId)) {
138
- return false;
139
- }
140
- }
141
- }
142
- return true;
143
- };
144
131
  SelectionSelect.prototype.open = function () {
145
132
  this.__disabled = false;
146
133
  };
package/es/index.d.ts CHANGED
@@ -16,5 +16,4 @@ export * from './tools/flow-path';
16
16
  export * from './tools/auto-layout';
17
17
  export * from './bpmn-adapter/xml2json';
18
18
  export * from './bpmn-adapter/json2xml';
19
- export * from './locale/en-locale';
20
19
  export * from './components/highlight';
package/es/index.js CHANGED
@@ -17,5 +17,4 @@ export * from './tools/flow-path';
17
17
  export * from './tools/auto-layout';
18
18
  export * from './bpmn-adapter/xml2json';
19
19
  export * from './bpmn-adapter/json2xml';
20
- export * from './locale/en-locale';
21
20
  export * from './components/highlight';
@@ -39,6 +39,7 @@ var __read = (this && this.__read) || function (o, n) {
39
39
  return ar;
40
40
  };
41
41
  import { PolylineEdge, PolylineEdgeModel, h } from '@logicflow/core';
42
+ import searchMiddleIndex from './searchMiddleIndex';
42
43
  var CurvedEdge = /** @class */ (function (_super) {
43
44
  __extends(CurvedEdge, _super);
44
45
  function CurvedEdge() {
@@ -67,7 +68,20 @@ var CurvedEdge = /** @class */ (function (_super) {
67
68
  var style = model.getEdgeStyle();
68
69
  var animationStyle = model.getEdgeAnimationStyle();
69
70
  var points2 = this.pointFilter(points.split(' ').map(function (p) { return p.split(',').map(function (a) { return Number(a); }); }));
70
- var _b = __read(points2[0], 2), startX = _b[0], startY = _b[1];
71
+ var res = searchMiddleIndex(points2);
72
+ if (res) {
73
+ var _b = __read(res, 2), first = _b[0], last = _b[1];
74
+ var firstPoint = points2[first];
75
+ var lastPoint_1 = points2[last];
76
+ var flag = firstPoint.some(function (num, index) { return num === lastPoint_1[index]; });
77
+ if (!flag) {
78
+ var diff = (lastPoint_1[1] - firstPoint[1]) / 2;
79
+ var firstNextPoint = [lastPoint_1[0], lastPoint_1[1] - diff];
80
+ var lastPrePoint = [firstPoint[0], firstPoint[1] + diff];
81
+ points2.splice(first + 1, 0, lastPrePoint, firstNextPoint);
82
+ }
83
+ }
84
+ var _c = __read(points2[0], 2), startX = _c[0], startY = _c[1];
71
85
  var d = "M" + startX + " " + startY;
72
86
  // 1) 如果一个点不为开始和结束,则在这个点的前后增加弧度开始和结束点。
73
87
  // 2) 判断这个点与前一个点的坐标
@@ -75,9 +89,9 @@ var CurvedEdge = /** @class */ (function (_super) {
75
89
  // y为(这个点的y 大于前一个点的y, 则 为 这个点的y - 5;小于前一个点的y, 则为这个点的y+5)
76
90
  // 同理,判断这个点与后一个点的x,y是否相同,如果x相同,则y进行加减,如果y相同,则x进行加减
77
91
  for (var i = 1; i < points2.length - 1; i++) {
78
- var _c = __read(points2[i - 1], 2), preX = _c[0], preY = _c[1];
79
- var _d = __read(points2[i], 2), currentX = _d[0], currentY = _d[1];
80
- var _e = __read(points2[i + 1], 2), nextX = _e[0], nextY = _e[1];
92
+ var _d = __read(points2[i - 1], 2), preX = _d[0], preY = _d[1];
93
+ var _e = __read(points2[i], 2), currentX = _e[0], currentY = _e[1];
94
+ var _f = __read(points2[i + 1], 2), nextX = _f[0], nextY = _f[1];
81
95
  if (currentX === preX && currentY !== preY) {
82
96
  var y = currentY > preY ? currentY - radius : currentY + radius;
83
97
  d = d + " L " + currentX + " " + y;
@@ -96,7 +110,7 @@ var CurvedEdge = /** @class */ (function (_super) {
96
110
  d = d + " " + x + " " + currentY;
97
111
  }
98
112
  }
99
- var _f = __read(points2[points2.length - 1], 2), endX = _f[0], endY = _f[1];
113
+ var _g = __read(points2[points2.length - 1], 2), endX = _g[0], endY = _g[1];
100
114
  d = d + " L " + endX + " " + endY;
101
115
  var attrs = __assign(__assign(__assign({ d: d, style: isAnimation ? animationStyle : {} }, style), arrowConfig), { fill: 'none' });
102
116
  return h('path', __assign({ d: d }, attrs));
@@ -0,0 +1 @@
1
+ export default function searchMiddleIndex<T>(arr: Array<T>): [number, number] | false;
@@ -0,0 +1,14 @@
1
+ export default function searchMiddleIndex(arr) {
2
+ if (arr.length <= 1)
3
+ return false;
4
+ var first = 0;
5
+ var last = arr.length - 1;
6
+ while (first !== last && first + 1 !== last && last - 1 !== first) {
7
+ first++;
8
+ last--;
9
+ }
10
+ if (first === last) {
11
+ return [--first, last];
12
+ }
13
+ return [first, last];
14
+ }