@logicflow/extension 1.1.21 → 1.1.24

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.
@@ -64,12 +64,17 @@ var MiniMap = /** @class */ (function () {
64
64
  y: e.y,
65
65
  };
66
66
  };
67
- this.__drag = function (e) {
67
+ this.moveViewport = function (top, left) {
68
68
  var viewStyle = _this.__viewport.style;
69
- _this.__viewPortTop += e.y - _this.__startPosition.y;
70
- _this.__viewPortLeft += e.x - _this.__startPosition.x;
69
+ _this.__viewPortTop = top;
70
+ _this.__viewPortLeft = left;
71
71
  viewStyle.top = _this.__viewPortTop + "px";
72
72
  viewStyle.left = _this.__viewPortLeft + "px";
73
+ };
74
+ this.__drag = function (e) {
75
+ var top = _this.__viewPortTop + e.y - _this.__startPosition.y;
76
+ var left = _this.__viewPortLeft + e.x - _this.__startPosition.x;
77
+ _this.moveViewport(top, left);
73
78
  _this.__startPosition = {
74
79
  x: e.x,
75
80
  y: e.y,
@@ -88,6 +93,21 @@ var MiniMap = /** @class */ (function () {
88
93
  this.__drop = function () {
89
94
  document.removeEventListener('mousemove', _this.__drag);
90
95
  document.removeEventListener('mouseup', _this.__drop);
96
+ var top = _this.__viewPortTop;
97
+ var left = _this.__viewPortLeft;
98
+ if (_this.__viewPortLeft > _this.__width) {
99
+ left = _this.__width - _this.__viewPortWidth;
100
+ }
101
+ if (_this.__viewPortTop > _this.__height) {
102
+ top = _this.__height - _this.__viewPortHeight;
103
+ }
104
+ if (_this.__viewPortLeft < -_this.__width) {
105
+ left = 0;
106
+ }
107
+ if (_this.__viewPortTop < -_this.__height) {
108
+ top = 0;
109
+ }
110
+ _this.moveViewport(top, left);
91
111
  };
92
112
  this.__lf = lf;
93
113
  this.__miniMapWidth = lf.graphModel.width;
@@ -311,7 +331,7 @@ var MiniMap = /** @class */ (function () {
311
331
  var graphRatio = (this.__lf.graphModel.width / this.__lf.graphModel.height);
312
332
  var realViewPortHeight = realViewPortWidth / graphRatio;
313
333
  this.__viewPortTop = TRANSLATE_Y > 0 ? 0 : -TRANSLATE_Y * scale;
314
- this.__viewPortLeft = -TRANSLATE_X * scale;
334
+ this.__viewPortLeft = TRANSLATE_X > 0 ? 0 : -TRANSLATE_X * scale;
315
335
  this.__viewPortWidth = realViewPortWidth;
316
336
  this.__viewPortHeight = realViewPortHeight;
317
337
  viewStyle.top = this.__viewPortTop + "px";
@@ -6,7 +6,7 @@ var SelectionSelect = /** @class */ (function () {
6
6
  var _this = this;
7
7
  var lf = _a.lf;
8
8
  this.__disabled = false;
9
- this.isDefalutStopMoveGraph = false;
9
+ this.isDefaultStopMoveGraph = false;
10
10
  this.isWholeNode = true;
11
11
  this.isWholeEdge = true;
12
12
  this.__draw = function (ev) {
@@ -44,16 +44,20 @@ var SelectionSelect = /** @class */ (function () {
44
44
  }
45
45
  var lt = [Math.min(x, x1), Math.min(y, y1)];
46
46
  var rt = [Math.max(x, x1), Math.max(y, y1)];
47
- var elements = _this.lf.getAreaElement(lt, rt, _this.isWholeEdge, _this.isWholeNode);
47
+ var elements = _this.lf.graphModel.getAreaElement(lt, rt, _this.isWholeEdge, _this.isWholeNode, true);
48
+ var group = _this.lf.graphModel.group;
48
49
  elements.forEach(function (element) {
49
- _this.lf.selectElementById(element.id, true);
50
+ // 如果节点属于分组,则不不选中节点
51
+ if (!group || !group.getNodeGroup(element.id)) {
52
+ _this.lf.selectElementById(element.id, true);
53
+ }
50
54
  });
51
55
  _this.lf.emit('selection:selected', elements);
52
56
  };
53
57
  this.lf = lf;
54
- // 初始化isDefalutStopMoveGraph取值
58
+ // 初始化isDefaultStopMoveGraph取值
55
59
  var stopMoveGraph = lf.getEditConfig().stopMoveGraph;
56
- this.isDefalutStopMoveGraph = stopMoveGraph;
60
+ this.isDefaultStopMoveGraph = stopMoveGraph;
57
61
  lf.openSelectionSelect = function () {
58
62
  _this.openSelectionSelect();
59
63
  };
@@ -104,7 +108,7 @@ var SelectionSelect = /** @class */ (function () {
104
108
  SelectionSelect.prototype.openSelectionSelect = function () {
105
109
  var stopMoveGraph = this.lf.getEditConfig().stopMoveGraph;
106
110
  if (!stopMoveGraph) {
107
- this.isDefalutStopMoveGraph = false;
111
+ this.isDefaultStopMoveGraph = false;
108
112
  this.lf.updateEditConfig({
109
113
  stopMoveGraph: true,
110
114
  });
@@ -115,7 +119,7 @@ var SelectionSelect = /** @class */ (function () {
115
119
  * 关闭选区
116
120
  */
117
121
  SelectionSelect.prototype.closeSelectionSelect = function () {
118
- if (!this.isDefalutStopMoveGraph) {
122
+ if (!this.isDefaultStopMoveGraph) {
119
123
  this.lf.updateEditConfig({
120
124
  stopMoveGraph: false,
121
125
  });
@@ -222,7 +222,7 @@ var GroupNodeModel = /** @class */ (function (_super) {
222
222
  var model = this.graphModel.addEdge(edgeData);
223
223
  model.virtual = true;
224
224
  // 强制不保存group连线数据
225
- model.getData = function () { return null; };
225
+ // model.getData = () => null;
226
226
  model.text.editable = false;
227
227
  model.isFoldedEdge = true;
228
228
  };
@@ -40,7 +40,7 @@ var Group = /** @class */ (function () {
40
40
  });
41
41
  }
42
42
  };
43
- this.appendNodeToGrop = function (_a) {
43
+ this.appendNodeToGroup = function (_a) {
44
44
  var data = _a.data;
45
45
  // 如果这个节点之前已经在group中了,则将其从之前的group中移除
46
46
  var preGroupId = _this.nodeGroupMap.get(data.id);
@@ -114,9 +114,9 @@ var Group = /** @class */ (function () {
114
114
  return true;
115
115
  });
116
116
  lf.graphModel.group = this;
117
- lf.on('node:add', this.appendNodeToGrop);
117
+ lf.on('node:add', this.appendNodeToGroup);
118
118
  lf.on('node:delete', this.deleteGroupChild);
119
- lf.on('node:drop', this.appendNodeToGrop);
119
+ lf.on('node:drop', this.appendNodeToGroup);
120
120
  lf.on('node:dnd-drag', this.setActiveGroup);
121
121
  lf.on('node:drag', this.setActiveGroup);
122
122
  lf.on('graph:rendered', this.graphRendered);
@@ -164,7 +164,7 @@ var Snapshot = /** @class */ (function () {
164
164
  真实dom存在缩放影响其宽高数值
165
165
  在得到真实宽高后除以缩放比例即可得到正常宽高
166
166
  */
167
- var base = document.getElementsByClassName('lf-base')[0];
167
+ var base = this.lf.graphModel.rootEl.querySelector('.lf-base');
168
168
  var bbox = base.getBoundingClientRect();
169
169
  var graphModel = this.lf.graphModel;
170
170
  var transformModel = graphModel.transformModel;
@@ -68,6 +68,7 @@ declare class MiniMap {
68
68
  }): void;
69
69
  __createViewPort(): void;
70
70
  __startDrag: (e: any) => void;
71
+ moveViewport: (top: any, left: any) => void;
71
72
  __drag: (e: any) => void;
72
73
  __drop: () => void;
73
74
  }
@@ -61,12 +61,17 @@ var MiniMap = /** @class */ (function () {
61
61
  y: e.y,
62
62
  };
63
63
  };
64
- this.__drag = function (e) {
64
+ this.moveViewport = function (top, left) {
65
65
  var viewStyle = _this.__viewport.style;
66
- _this.__viewPortTop += e.y - _this.__startPosition.y;
67
- _this.__viewPortLeft += e.x - _this.__startPosition.x;
66
+ _this.__viewPortTop = top;
67
+ _this.__viewPortLeft = left;
68
68
  viewStyle.top = _this.__viewPortTop + "px";
69
69
  viewStyle.left = _this.__viewPortLeft + "px";
70
+ };
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;
74
+ _this.moveViewport(top, left);
70
75
  _this.__startPosition = {
71
76
  x: e.x,
72
77
  y: e.y,
@@ -85,6 +90,21 @@ var MiniMap = /** @class */ (function () {
85
90
  this.__drop = function () {
86
91
  document.removeEventListener('mousemove', _this.__drag);
87
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;
97
+ }
98
+ if (_this.__viewPortTop > _this.__height) {
99
+ top = _this.__height - _this.__viewPortHeight;
100
+ }
101
+ if (_this.__viewPortLeft < -_this.__width) {
102
+ left = 0;
103
+ }
104
+ if (_this.__viewPortTop < -_this.__height) {
105
+ top = 0;
106
+ }
107
+ _this.moveViewport(top, left);
88
108
  };
89
109
  this.__lf = lf;
90
110
  this.__miniMapWidth = lf.graphModel.width;
@@ -308,7 +328,7 @@ var MiniMap = /** @class */ (function () {
308
328
  var graphRatio = (this.__lf.graphModel.width / this.__lf.graphModel.height);
309
329
  var realViewPortHeight = realViewPortWidth / graphRatio;
310
330
  this.__viewPortTop = TRANSLATE_Y > 0 ? 0 : -TRANSLATE_Y * scale;
311
- this.__viewPortLeft = -TRANSLATE_X * scale;
331
+ this.__viewPortLeft = TRANSLATE_X > 0 ? 0 : -TRANSLATE_X * scale;
312
332
  this.__viewPortWidth = realViewPortWidth;
313
333
  this.__viewPortHeight = realViewPortHeight;
314
334
  viewStyle.top = this.__viewPortTop + "px";
@@ -12,7 +12,7 @@ declare class SelectionSelect {
12
12
  y: number;
13
13
  };
14
14
  __disabled: boolean;
15
- isDefalutStopMoveGraph: boolean;
15
+ isDefaultStopMoveGraph: boolean;
16
16
  isWholeNode: boolean;
17
17
  isWholeEdge: boolean;
18
18
  static pluginName: string;
@@ -3,7 +3,7 @@ var SelectionSelect = /** @class */ (function () {
3
3
  var _this = this;
4
4
  var lf = _a.lf;
5
5
  this.__disabled = false;
6
- this.isDefalutStopMoveGraph = false;
6
+ this.isDefaultStopMoveGraph = false;
7
7
  this.isWholeNode = true;
8
8
  this.isWholeEdge = true;
9
9
  this.__draw = function (ev) {
@@ -41,16 +41,20 @@ var SelectionSelect = /** @class */ (function () {
41
41
  }
42
42
  var lt = [Math.min(x, x1), Math.min(y, y1)];
43
43
  var rt = [Math.max(x, x1), Math.max(y, y1)];
44
- var elements = _this.lf.getAreaElement(lt, rt, _this.isWholeEdge, _this.isWholeNode);
44
+ var elements = _this.lf.graphModel.getAreaElement(lt, rt, _this.isWholeEdge, _this.isWholeNode, true);
45
+ var group = _this.lf.graphModel.group;
45
46
  elements.forEach(function (element) {
46
- _this.lf.selectElementById(element.id, true);
47
+ // 如果节点属于分组,则不不选中节点
48
+ if (!group || !group.getNodeGroup(element.id)) {
49
+ _this.lf.selectElementById(element.id, true);
50
+ }
47
51
  });
48
52
  _this.lf.emit('selection:selected', elements);
49
53
  };
50
54
  this.lf = lf;
51
- // 初始化isDefalutStopMoveGraph取值
55
+ // 初始化isDefaultStopMoveGraph取值
52
56
  var stopMoveGraph = lf.getEditConfig().stopMoveGraph;
53
- this.isDefalutStopMoveGraph = stopMoveGraph;
57
+ this.isDefaultStopMoveGraph = stopMoveGraph;
54
58
  lf.openSelectionSelect = function () {
55
59
  _this.openSelectionSelect();
56
60
  };
@@ -101,7 +105,7 @@ var SelectionSelect = /** @class */ (function () {
101
105
  SelectionSelect.prototype.openSelectionSelect = function () {
102
106
  var stopMoveGraph = this.lf.getEditConfig().stopMoveGraph;
103
107
  if (!stopMoveGraph) {
104
- this.isDefalutStopMoveGraph = false;
108
+ this.isDefaultStopMoveGraph = false;
105
109
  this.lf.updateEditConfig({
106
110
  stopMoveGraph: true,
107
111
  });
@@ -112,7 +116,7 @@ var SelectionSelect = /** @class */ (function () {
112
116
  * 关闭选区
113
117
  */
114
118
  SelectionSelect.prototype.closeSelectionSelect = function () {
115
- if (!this.isDefalutStopMoveGraph) {
119
+ if (!this.isDefaultStopMoveGraph) {
116
120
  this.lf.updateEditConfig({
117
121
  stopMoveGraph: false,
118
122
  });
@@ -220,7 +220,7 @@ var GroupNodeModel = /** @class */ (function (_super) {
220
220
  var model = this.graphModel.addEdge(edgeData);
221
221
  model.virtual = true;
222
222
  // 强制不保存group连线数据
223
- model.getData = function () { return null; };
223
+ // model.getData = () => null;
224
224
  model.text.editable = false;
225
225
  model.isFoldedEdge = true;
226
226
  };
@@ -17,7 +17,7 @@ declare class Group {
17
17
  lf: any;
18
18
  });
19
19
  graphRendered: (data: any) => void;
20
- appendNodeToGrop: ({ data }: {
20
+ appendNodeToGroup: ({ data }: {
21
21
  data: any;
22
22
  }) => void;
23
23
  deleteGroupChild: ({ data }: {
@@ -36,7 +36,7 @@ var Group = /** @class */ (function () {
36
36
  });
37
37
  }
38
38
  };
39
- this.appendNodeToGrop = function (_a) {
39
+ this.appendNodeToGroup = function (_a) {
40
40
  var data = _a.data;
41
41
  // 如果这个节点之前已经在group中了,则将其从之前的group中移除
42
42
  var preGroupId = _this.nodeGroupMap.get(data.id);
@@ -110,9 +110,9 @@ var Group = /** @class */ (function () {
110
110
  return true;
111
111
  });
112
112
  lf.graphModel.group = this;
113
- lf.on('node:add', this.appendNodeToGrop);
113
+ lf.on('node:add', this.appendNodeToGroup);
114
114
  lf.on('node:delete', this.deleteGroupChild);
115
- lf.on('node:drop', this.appendNodeToGrop);
115
+ lf.on('node:drop', this.appendNodeToGroup);
116
116
  lf.on('node:dnd-drag', this.setActiveGroup);
117
117
  lf.on('node:drag', this.setActiveGroup);
118
118
  lf.on('graph:rendered', this.graphRendered);
@@ -161,7 +161,7 @@ var Snapshot = /** @class */ (function () {
161
161
  真实dom存在缩放影响其宽高数值
162
162
  在得到真实宽高后除以缩放比例即可得到正常宽高
163
163
  */
164
- var base = document.getElementsByClassName('lf-base')[0];
164
+ var base = this.lf.graphModel.rootEl.querySelector('.lf-base');
165
165
  var bbox = base.getBoundingClientRect();
166
166
  var graphModel = this.lf.graphModel;
167
167
  var transformModel = graphModel.transformModel;