@logicflow/extension 2.0.15 → 2.0.17

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.
@@ -1,14 +1,52 @@
1
1
  "use strict";
2
+ var __read = (this && this.__read) || function (o, n) {
3
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
4
+ if (!m) return o;
5
+ var i = m.call(o), r, ar = [], e;
6
+ try {
7
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
8
+ }
9
+ catch (error) { e = { error: error }; }
10
+ finally {
11
+ try {
12
+ if (r && !r.done && (m = i["return"])) m.call(i);
13
+ }
14
+ finally { if (e) throw e.error; }
15
+ }
16
+ return ar;
17
+ };
18
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
19
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
20
+ if (ar || !(i in from)) {
21
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
22
+ ar[i] = from[i];
23
+ }
24
+ }
25
+ return to.concat(ar || Array.prototype.slice.call(from));
26
+ };
2
27
  Object.defineProperty(exports, "__esModule", { value: true });
3
28
  exports.SelectionSelect = void 0;
29
+ var lodash_es_1 = require("lodash-es");
4
30
  var SelectionSelect = /** @class */ (function () {
5
31
  function SelectionSelect(_a) {
6
- var lf = _a.lf;
32
+ var lf = _a.lf, options = _a.options;
7
33
  var _this = this;
34
+ var _b;
8
35
  this.disabled = true;
9
- this.isDefaultStopMoveGraph = false;
10
36
  this.isWholeNode = true;
11
37
  this.isWholeEdge = true;
38
+ this.exclusiveMode = false; // 框选独占模式:true 表示只能进行框选操作,false 表示可以同时进行其他画布操作
39
+ // 用于区分选区和点击事件
40
+ this.mouseDownInfo = null;
41
+ // 记录原始的 stopMoveGraph 设置
42
+ this.originalStopMoveGraph = false;
43
+ /**
44
+ * 处理画布空白处鼠标按下事件(非独占模式)
45
+ */
46
+ this.handleBlankMouseDown = function (_a) {
47
+ var e = _a.e;
48
+ _this.handleMouseDown(e);
49
+ };
12
50
  this.draw = function (ev) {
13
51
  var _a = _this.lf.getPointByClient(ev.clientX, ev.clientY).domOverlayPosition, x1 = _a.x, y1 = _a.y;
14
52
  _this.endPoint = {
@@ -37,17 +75,33 @@ var SelectionSelect = /** @class */ (function () {
37
75
  }
38
76
  }
39
77
  };
40
- this.drawOff = function () {
41
- var _a;
78
+ this.drawOff = function (e) {
79
+ // 处理鼠标抬起事件
80
+ // 首先判断是否是点击,如果是,则清空框选
81
+ if (_this.mouseDownInfo) {
82
+ var _a = _this.mouseDownInfo, x = _a.x, y = _a.y, time = _a.time;
83
+ var isClick = Math.abs(e.clientX - x) < 5 &&
84
+ Math.abs(e.clientY - y) < 5 &&
85
+ Date.now() - time < 200;
86
+ if (isClick) {
87
+ _this.lf.clearSelectElements();
88
+ _this.cleanupSelectionState();
89
+ return;
90
+ }
91
+ }
92
+ var curStartPoint = (0, lodash_es_1.cloneDeep)(_this.startPoint);
93
+ var curEndPoint = (0, lodash_es_1.cloneDeep)(_this.endPoint);
42
94
  document.removeEventListener('mousemove', _this.draw);
43
- document.removeEventListener('mouseup', _this.drawOff);
44
- if (_this.wrapper) {
45
- _this.wrapper.oncontextmenu = null;
46
- (_a = _this.container) === null || _a === void 0 ? void 0 : _a.removeChild(_this.wrapper);
95
+ if (!_this.exclusiveMode) {
96
+ document.removeEventListener('mouseup', _this.drawOff);
47
97
  }
48
- if (_this.startPoint && _this.endPoint) {
49
- var _b = _this.startPoint, x = _b.x, y = _b.y;
50
- var _c = _this.endPoint, x1 = _c.x, y1 = _c.y;
98
+ // 恢复原始的 stopMoveGraph 设置
99
+ _this.lf.updateEditConfig({
100
+ stopMoveGraph: _this.originalStopMoveGraph,
101
+ });
102
+ if (curStartPoint && curEndPoint) {
103
+ var x = curStartPoint.x, y = curStartPoint.y;
104
+ var x1 = curEndPoint.x, y1 = curEndPoint.y;
51
105
  // 返回框选范围,左上角和右下角的坐标
52
106
  var lt = [Math.min(x, x1), Math.min(y, y1)];
53
107
  var rb = [Math.max(x, x1), Math.max(y, y1)];
@@ -57,33 +111,71 @@ var SelectionSelect = /** @class */ (function () {
57
111
  });
58
112
  // 选区太小的情况就忽略
59
113
  if (Math.abs(x1 - x) < 10 && Math.abs(y1 - y) < 10) {
114
+ if (_this.wrapper) {
115
+ _this.wrapper.oncontextmenu = null;
116
+ if (_this.container && _this.wrapper.parentNode === _this.container) {
117
+ _this.container.removeChild(_this.wrapper);
118
+ }
119
+ _this.wrapper = undefined;
120
+ }
60
121
  return;
61
122
  }
62
- var elements = _this.lf.graphModel.getAreaElement(lt, rb, _this.isWholeEdge, _this.isWholeNode, true);
63
- var _d = _this.lf.graphModel, dynamicGroup_1 = _d.dynamicGroup, group_1 = _d.group;
123
+ var elements_1 = _this.lf.graphModel.getAreaElement(lt, rb, _this.isWholeEdge, _this.isWholeNode, true);
124
+ var _b = _this.lf.graphModel, dynamicGroup_1 = _b.dynamicGroup, group_1 = _b.group;
64
125
  var nonGroupedElements_1 = [];
65
- elements.forEach(function (element) {
126
+ var selectedElements = _this.lf.getSelectElements();
127
+ // 同时记录节点和边的ID
128
+ var selectedIds_1 = new Set(__spreadArray(__spreadArray([], __read(selectedElements.nodes.map(function (node) { return node.id; })), false), __read(selectedElements.edges.map(function (edge) { return edge.id; })), false));
129
+ elements_1.forEach(function (element) {
66
130
  // 如果节点属于分组,则不选中节点,此处兼容旧版 Group 插件
67
- if (group_1 && group_1.getNodeGroup(element.id)) {
68
- return;
131
+ if (group_1) {
132
+ var elementGroup = group_1.getNodeGroup(element.id);
133
+ if (elements_1.includes(elementGroup)) {
134
+ // 当被选中的元素的父分组被选中时,不选中该元素
135
+ return;
136
+ }
137
+ }
138
+ if (dynamicGroup_1) {
139
+ var elementGroup = dynamicGroup_1.getGroupByNodeId(element.id);
140
+ if (elements_1.includes(elementGroup)) {
141
+ // 当被选中的元素的父分组被选中时,不选中该元素
142
+ return;
143
+ }
69
144
  }
70
- if (dynamicGroup_1 && dynamicGroup_1.getGroupByNodeId(element.id)) {
145
+ // 在独占模式下,如果元素已经被选中,则取消选中
146
+ if (_this.exclusiveMode && selectedIds_1.has(element.id)) {
147
+ _this.lf.deselectElementById(element.id);
71
148
  return;
72
149
  }
150
+ // 非独占模式下,或者元素未被选中时,选中元素
73
151
  _this.lf.selectElementById(element.id, true);
74
152
  nonGroupedElements_1.push(element);
75
153
  });
154
+ // 重置起始点和终点
155
+ // 注意:这两个值必须在触发closeSelectionSelect方法前充值,否则会导致独占模式下元素无法选中的问题
156
+ _this.startPoint = undefined;
157
+ _this.endPoint = undefined;
158
+ // 如果有选中的元素,触发 selection:drop 事件
159
+ if (nonGroupedElements_1.length > 0) {
160
+ _this.lf.emit('selection:drop', { e: e });
161
+ }
162
+ // 触发 selection:selected 事件
76
163
  _this.lf.emit('selection:selected', {
77
164
  elements: nonGroupedElements_1,
78
165
  leftTopPoint: lt,
79
166
  rightBottomPoint: rb,
80
167
  });
81
168
  }
169
+ if (_this.wrapper) {
170
+ _this.wrapper.oncontextmenu = null;
171
+ if (_this.container && _this.wrapper.parentNode === _this.container) {
172
+ _this.container.removeChild(_this.wrapper);
173
+ }
174
+ _this.wrapper = undefined;
175
+ }
82
176
  };
83
177
  this.lf = lf;
84
- // 初始化isDefaultStopMoveGraph取值
85
- var stopMoveGraph = lf.getEditConfig().stopMoveGraph;
86
- this.isDefaultStopMoveGraph = stopMoveGraph;
178
+ this.exclusiveMode = (_b = options === null || options === void 0 ? void 0 : options.exclusiveMode) !== null && _b !== void 0 ? _b : false;
87
179
  // TODO: 有没有既能将方法挂载到lf上,又能提供类型提示的方法?
88
180
  lf.openSelectionSelect = function () {
89
181
  _this.openSelectionSelect();
@@ -91,43 +183,114 @@ var SelectionSelect = /** @class */ (function () {
91
183
  lf.closeSelectionSelect = function () {
92
184
  _this.closeSelectionSelect();
93
185
  };
186
+ // 新增切换独占模式的方法
187
+ lf.setSelectionSelectMode = function (exclusive) {
188
+ _this.setExclusiveMode(exclusive);
189
+ };
190
+ // 绑定方法的 this 上下文
191
+ this.handleMouseDown = this.handleMouseDown.bind(this);
192
+ this.draw = this.draw.bind(this);
193
+ this.drawOff = this.drawOff.bind(this);
94
194
  }
95
- SelectionSelect.prototype.render = function (lf, domContainer) {
96
- var _this = this;
195
+ SelectionSelect.prototype.render = function (_, domContainer) {
97
196
  this.container = domContainer;
98
- lf.on('blank:mousedown', function (_a) {
99
- var e = _a.e;
100
- var config = lf.getEditConfig();
101
- // 鼠标控制滚动移动画布的时候,不能选区。
102
- if (!config.stopMoveGraph || _this.disabled) {
103
- return;
104
- }
105
- // 禁用右键框选,修复可能导致画布出现多个框选框不消失的问题,见https://github.com/didi/LogicFlow/issues/985
106
- var isRightClick = e.button === 2;
107
- if (isRightClick) {
108
- return;
197
+ };
198
+ /**
199
+ * 清理选区状态
200
+ */
201
+ SelectionSelect.prototype.cleanupSelectionState = function () {
202
+ // 清理当前的选区状态
203
+ if (this.wrapper) {
204
+ this.wrapper.oncontextmenu = null;
205
+ if (this.container && this.wrapper.parentNode === this.container) {
206
+ this.container.removeChild(this.wrapper);
109
207
  }
110
- var _b = lf.getPointByClient(e.clientX, e.clientY).domOverlayPosition, x = _b.x, y = _b.y;
111
- _this.startPoint = {
112
- x: x,
113
- y: y,
114
- };
115
- _this.endPoint = {
116
- x: x,
117
- y: y,
118
- };
119
- var wrapper = document.createElement('div');
120
- wrapper.className = 'lf-selection-select';
121
- wrapper.oncontextmenu = function prevent(ev) {
122
- ev.preventDefault();
123
- };
124
- wrapper.style.top = "".concat(_this.startPoint.y, "px");
125
- wrapper.style.left = "".concat(_this.startPoint.x, "px");
126
- domContainer.appendChild(wrapper);
127
- _this.wrapper = wrapper;
128
- document.addEventListener('mousemove', _this.draw);
129
- document.addEventListener('mouseup', _this.drawOff);
208
+ this.wrapper = undefined;
209
+ }
210
+ this.startPoint = undefined;
211
+ this.endPoint = undefined;
212
+ this.mouseDownInfo = null;
213
+ // 移除事件监听
214
+ document.removeEventListener('mousemove', this.draw);
215
+ document.removeEventListener('mouseup', this.drawOff);
216
+ };
217
+ /**
218
+ * 切换框选模式
219
+ * @param exclusive 是否为独占模式。true 表示只能进行框选操作,false 表示可以同时进行其他画布操作
220
+ */
221
+ SelectionSelect.prototype.setExclusiveMode = function (exclusive) {
222
+ if (exclusive === void 0) { exclusive = false; }
223
+ if (this.exclusiveMode === exclusive)
224
+ return;
225
+ this.cleanupSelectionState();
226
+ this.exclusiveMode = exclusive;
227
+ if (this.container && !this.disabled) {
228
+ // 切换事件监听方式
229
+ this.removeEventListeners();
230
+ this.addEventListeners();
231
+ }
232
+ };
233
+ SelectionSelect.prototype.addEventListeners = function () {
234
+ if (!this.container)
235
+ return;
236
+ if (this.exclusiveMode) {
237
+ // 独占模式:监听 container 的 mousedown 事件
238
+ this.container.style.pointerEvents = 'auto';
239
+ this.container.addEventListener('mousedown', this.handleMouseDown);
240
+ }
241
+ else {
242
+ // 非独占模式:监听画布的 blank:mousedown 事件
243
+ this.container.style.pointerEvents = 'none';
244
+ // 使用实例方法而不是箭头函数,这样可以正确移除事件监听
245
+ this.lf.on('blank:mousedown', this.handleBlankMouseDown);
246
+ }
247
+ };
248
+ SelectionSelect.prototype.removeEventListeners = function () {
249
+ if (this.container) {
250
+ this.container.style.pointerEvents = 'none';
251
+ this.container.removeEventListener('mousedown', this.handleMouseDown);
252
+ }
253
+ // 移除 blank:mousedown 事件监听
254
+ this.lf.off('blank:mousedown', this.handleBlankMouseDown);
255
+ };
256
+ /**
257
+ * 处理鼠标按下事件
258
+ */
259
+ SelectionSelect.prototype.handleMouseDown = function (e) {
260
+ var _a;
261
+ if (!this.container || this.disabled)
262
+ return;
263
+ // 禁用右键框选
264
+ var isRightClick = e.button === 2;
265
+ if (isRightClick)
266
+ return;
267
+ // 清理之前可能存在的选区状态
268
+ this.cleanupSelectionState();
269
+ // 记录鼠标按下时的位置和时间
270
+ this.mouseDownInfo = {
271
+ x: e.clientX,
272
+ y: e.clientY,
273
+ time: Date.now(),
274
+ };
275
+ // 记录原始设置并临时禁止画布移动
276
+ this.originalStopMoveGraph = this.lf.getEditConfig().stopMoveGraph;
277
+ this.lf.updateEditConfig({
278
+ stopMoveGraph: true,
130
279
  });
280
+ var _b = this.lf.getPointByClient(e.clientX, e.clientY).domOverlayPosition, x = _b.x, y = _b.y;
281
+ this.startPoint = { x: x, y: y };
282
+ this.endPoint = { x: x, y: y };
283
+ var wrapper = document.createElement('div');
284
+ wrapper.className = 'lf-selection-select';
285
+ wrapper.oncontextmenu = function prevent(ev) {
286
+ ev.preventDefault();
287
+ };
288
+ wrapper.style.top = "".concat(this.startPoint.y, "px");
289
+ wrapper.style.left = "".concat(this.startPoint.x, "px");
290
+ (_a = this.container) === null || _a === void 0 ? void 0 : _a.appendChild(wrapper);
291
+ this.wrapper = wrapper;
292
+ document.addEventListener('mousemove', this.draw);
293
+ document.addEventListener('mouseup', this.drawOff);
131
294
  };
132
295
  /**
133
296
  * 设置选中的灵敏度
@@ -144,24 +307,35 @@ var SelectionSelect = /** @class */ (function () {
144
307
  * 开启选区
145
308
  */
146
309
  SelectionSelect.prototype.openSelectionSelect = function () {
147
- var stopMoveGraph = this.lf.getEditConfig().stopMoveGraph;
148
- if (!stopMoveGraph) {
149
- this.isDefaultStopMoveGraph = false;
150
- this.lf.updateEditConfig({
151
- stopMoveGraph: true,
152
- });
310
+ if (!this.disabled) {
311
+ this.closeSelectionSelect();
312
+ }
313
+ if (!this.container) {
314
+ return;
153
315
  }
316
+ this.cleanupSelectionState();
317
+ this.addEventListeners();
154
318
  this.open();
155
319
  };
156
320
  /**
157
321
  * 关闭选区
158
322
  */
159
323
  SelectionSelect.prototype.closeSelectionSelect = function () {
160
- if (!this.isDefaultStopMoveGraph) {
161
- this.lf.updateEditConfig({
162
- stopMoveGraph: false,
324
+ if (!this.container) {
325
+ return;
326
+ }
327
+ // 如果还有未完成的框选,先触发 drawOff 完成框选
328
+ if (this.wrapper && this.startPoint && this.endPoint) {
329
+ // 记录上一次的结束点,用于触发 mouseup 事件
330
+ var lastEndPoint = (0, lodash_es_1.cloneDeep)(this.endPoint);
331
+ var lastEvent = new MouseEvent('mouseup', {
332
+ clientX: lastEndPoint.x,
333
+ clientY: lastEndPoint.y,
163
334
  });
335
+ this.drawOff(lastEvent);
164
336
  }
337
+ this.cleanupSelectionState();
338
+ this.removeEventListeners();
165
339
  this.close();
166
340
  };
167
341
  SelectionSelect.prototype.open = function () {
@@ -48,10 +48,14 @@ export declare class DynamicGroup {
48
48
  * @param nodes
49
49
  */
50
50
  calibrateTopGroupZIndex(nodes: NodeData[]): void;
51
- addNodeToGroup: ({ data: node }: CallbackArgs<'node:add'>) => void;
51
+ onSelectionDrop: () => void;
52
+ onNodeAddOrDrop: ({ data: node }: CallbackArgs<'node:add'>) => void;
53
+ addNodeToGroup: (node: LogicFlow.NodeData) => void;
52
54
  onGroupAddNode: ({ data: groupData, childId, }: CallbackArgs<'group:add-node'>) => void;
53
55
  removeNodeFromGroup: ({ data: node, model, }: CallbackArgs<'node:delete'>) => void;
54
- setActiveGroup: ({ data: node }: CallbackArgs<'node:drag'>) => void;
56
+ onSelectionDrag: () => void;
57
+ onNodeDrag: ({ data: node }: CallbackArgs<'node:drag'>) => void;
58
+ setActiveGroup: (node: LogicFlow.NodeData) => void;
55
59
  /**
56
60
  * 1. 分组节点默认在普通节点下面
57
61
  * 2. 分组节点被选中后,会将分组节点以及其内部的其它分组节点放到其余分组节点的上面
@@ -72,9 +72,17 @@ var DynamicGroup = /** @class */ (function () {
72
72
  this.topGroupZIndex = DEFAULT_BOTTOM_Z_INDEX;
73
73
  // 存储节点与 group 的映射关系
74
74
  this.nodeGroupMap = new Map();
75
- // 监听 LogicFlow 的相关事件,做对应的处理
76
- this.addNodeToGroup = function (_a) {
75
+ this.onSelectionDrop = function () {
76
+ var selectedNodes = _this.lf.graphModel.getSelectElements().nodes;
77
+ selectedNodes.forEach(function (node) {
78
+ _this.addNodeToGroup(node);
79
+ });
80
+ };
81
+ this.onNodeAddOrDrop = function (_a) {
77
82
  var node = _a.data;
83
+ _this.addNodeToGroup(node);
84
+ };
85
+ this.addNodeToGroup = function (node) {
78
86
  // 1. 如果该节点之前已经在 group 中了,则将其从之前的 group 移除
79
87
  var preGroupId = _this.nodeGroupMap.get(node.id);
80
88
  if (preGroupId) {
@@ -114,12 +122,10 @@ var DynamicGroup = /** @class */ (function () {
114
122
  var group = _this.getGroupByBounds(bounds, node);
115
123
  if (group) {
116
124
  var isAllowAppendIn = group.isAllowAppendIn(node);
117
- console.log('isAllowAppendIn', isAllowAppendIn);
118
125
  if (isAllowAppendIn) {
119
126
  group.addChild(node.id);
120
127
  // 建立节点与 group 的映射关系放在了 group.addChild 触发的事件中,与直接调用 addChild 的行为保持一致
121
- // TODO 下面这个是干什么的,是否需要一起移动到事件的逻辑中?
122
- group.setAllowAppendChild(true);
128
+ group.setAllowAppendChild(false);
123
129
  }
124
130
  else {
125
131
  // 抛出不允许插入的事件
@@ -133,7 +139,6 @@ var DynamicGroup = /** @class */ (function () {
133
139
  };
134
140
  this.onGroupAddNode = function (_a) {
135
141
  var groupData = _a.data, childId = _a.childId;
136
- console.log('group:add-node', groupData);
137
142
  _this.nodeGroupMap.set(childId, groupData.id);
138
143
  };
139
144
  this.removeNodeFromGroup = function (_a) {
@@ -151,8 +156,17 @@ var DynamicGroup = /** @class */ (function () {
151
156
  _this.nodeGroupMap.delete(node.id);
152
157
  }
153
158
  };
154
- this.setActiveGroup = function (_a) {
159
+ this.onSelectionDrag = function () {
160
+ var selectedNodes = _this.lf.graphModel.getSelectElements().nodes;
161
+ selectedNodes.forEach(function (node) {
162
+ _this.setActiveGroup(node);
163
+ });
164
+ };
165
+ this.onNodeDrag = function (_a) {
155
166
  var node = _a.data;
167
+ _this.setActiveGroup(node);
168
+ };
169
+ this.setActiveGroup = function (node) {
156
170
  var nodeModel = _this.lf.getNodeModelById(node.id);
157
171
  var bounds = nodeModel === null || nodeModel === void 0 ? void 0 : nodeModel.getBounds();
158
172
  if (nodeModel && bounds) {
@@ -167,7 +181,6 @@ var DynamicGroup = /** @class */ (function () {
167
181
  if (!isAllowAppendIn)
168
182
  return;
169
183
  _this.activeGroup = targetGroup;
170
- console.log('this.activeGroup', _this.activeGroup);
171
184
  _this.activeGroup.setAllowAppendChild(true);
172
185
  }
173
186
  };
@@ -277,7 +290,6 @@ var DynamicGroup = /** @class */ (function () {
277
290
  };
278
291
  this.onGraphRendered = function (_a) {
279
292
  var data = _a.data;
280
- console.log('data', data);
281
293
  (0, lodash_es_1.forEach)(data.nodes, function (node) {
282
294
  if (node.children) {
283
295
  (0, lodash_es_1.forEach)(node.children, function (childId) {
@@ -584,16 +596,14 @@ var DynamicGroup = /** @class */ (function () {
584
596
  return true;
585
597
  });
586
598
  graphModel.dynamicGroup = this;
587
- lf.on('node:add,node:drop,node:dnd-add', this.addNodeToGroup);
599
+ lf.on('node:add,node:drop,node:dnd-add', this.onNodeAddOrDrop);
600
+ lf.on('selection:drop', this.onSelectionDrop);
588
601
  lf.on('node:delete', this.removeNodeFromGroup);
589
- lf.on('node:drag,node:dnd-drag', this.setActiveGroup);
602
+ lf.on('node:drag,node:dnd-drag', this.onNodeDrag);
603
+ lf.on('selection:drag', this.onSelectionDrag);
590
604
  lf.on('node:click', this.onNodeSelect);
591
605
  lf.on('node:mousemove', this.onNodeMove);
592
606
  lf.on('graph:rendered', this.onGraphRendered);
593
- lf.on('graph:updated', function (_a) {
594
- var data = _a.data;
595
- return console.log('data', data);
596
- });
597
607
  lf.on('group:add-node', this.onGroupAddNode);
598
608
  // https://github.com/didi/LogicFlow/issues/1346
599
609
  // 重写 addElements() 方法,在 addElements() 原有基础上增加对 group 内部所有 nodes 和 edges 的复制功能
@@ -627,7 +637,6 @@ var DynamicGroup = /** @class */ (function () {
627
637
  (0, lodash_es_1.forEach)(edgesInnerGroup, function (edge) {
628
638
  _this.createEdge(edge, nodeIdMap, distance);
629
639
  });
630
- console.log('selectedEdges --->>>', selectedEdges);
631
640
  (0, lodash_es_1.forEach)(selectedEdges, function (edge) {
632
641
  elements.edges.push(_this.createEdge(edge, nodeIdMap, distance));
633
642
  });
@@ -640,9 +649,11 @@ var DynamicGroup = /** @class */ (function () {
640
649
  DynamicGroup.prototype.render = function () { };
641
650
  DynamicGroup.prototype.destroy = function () {
642
651
  // 销毁监听的事件,并移除渲染的 dom 内容
643
- this.lf.off('node:add,node:drop,node:dnd-add', this.addNodeToGroup);
652
+ this.lf.off('node:add,node:drop,node:dnd-add', this.onNodeAddOrDrop);
653
+ this.lf.off('selection:drop', this.onSelectionDrop);
644
654
  this.lf.off('node:delete', this.removeNodeFromGroup);
645
- this.lf.off('node:drag,node:dnd-drag', this.setActiveGroup);
655
+ this.lf.off('node:drag,node:dnd-drag', this.onNodeDrag);
656
+ this.lf.off('selection:drag', this.onSelectionDrag);
646
657
  this.lf.off('node:click', this.onNodeSelect);
647
658
  this.lf.off('node:mousemove', this.onNodeMove);
648
659
  this.lf.off('graph:rendered', this.onGraphRendered);
@@ -329,7 +329,6 @@ var GroupNodeModel = /** @class */ (function (_super) {
329
329
  var _this = this;
330
330
  var data = _super.prototype.getData.call(this);
331
331
  data.children = [];
332
- console.log('this.children', this.children);
333
332
  this.children.forEach(function (childId) {
334
333
  var model = _this.graphModel.getNodeModelById(childId);
335
334
  if (model && !model.virtual) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@logicflow/extension",
3
- "version": "2.0.15",
3
+ "version": "2.0.17",
4
4
  "description": "LogicFlow Extensions",
5
5
  "main": "lib/index.js",
6
6
  "module": "es/index.js",
@@ -20,7 +20,7 @@
20
20
  "author": "Logicflow-Team",
21
21
  "license": "Apache-2.0",
22
22
  "peerDependencies": {
23
- "@logicflow/core": "2.0.11"
23
+ "@logicflow/core": "2.0.13"
24
24
  },
25
25
  "dependencies": {
26
26
  "@antv/hierarchy": "^0.6.11",
@@ -31,7 +31,7 @@
31
31
  "preact": "^10.17.1",
32
32
  "rangy": "^1.3.1",
33
33
  "vanilla-picker": "^2.12.3",
34
- "@logicflow/core": "2.0.11"
34
+ "@logicflow/core": "2.0.13"
35
35
  },
36
36
  "devDependencies": {
37
37
  "less": "^4.1.1",
@@ -3,6 +3,7 @@ import LogicFlow from '@logicflow/core'
3
3
  import GraphData = LogicFlow.GraphData
4
4
  import NodeData = LogicFlow.NodeData
5
5
  import EdgeData = LogicFlow.EdgeData
6
+ import Position = LogicFlow.Position
6
7
 
7
8
  type SetType = 'add' | 'reset'
8
9
 
@@ -29,7 +30,8 @@ class Menu {
29
30
  private __container?: HTMLElement
30
31
  private __menuDOM?: HTMLElement
31
32
  private menuTypeMap?: Map<string, MenuItem[]>
32
- private __currentData: EdgeData | NodeData | GraphData | null = null
33
+ private __currentData: EdgeData | NodeData | GraphData | Position | null =
34
+ null
33
35
  static pluginName = 'menu'
34
36
 
35
37
  constructor({ lf }) {
@@ -209,6 +211,7 @@ class Menu {
209
211
  const {
210
212
  domOverlayPosition: { x, y },
211
213
  } = position
214
+ this.__currentData = { ...position.canvasOverlayPosition }
212
215
  this.showMenu(x, y, menuList)
213
216
  })
214
217
  this.lf.on('selection:contextmenu', ({ data, position }) => {