@antv/g6 5.0.0-beta.4 → 5.0.0-beta.6
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.
- package/dist/g6.min.js +2 -2
- package/esm/index.d.ts +15 -1
- package/esm/index.js +1 -1
- package/esm/item/combo.d.ts +1 -1
- package/esm/item/combo.js +16 -9
- package/esm/item/combo.js.map +1 -1
- package/esm/item/edge.d.ts +2 -1
- package/esm/item/edge.js +18 -8
- package/esm/item/edge.js.map +1 -1
- package/esm/item/item.d.ts +3 -2
- package/esm/item/item.js +12 -6
- package/esm/item/item.js.map +1 -1
- package/esm/item/node.d.ts +2 -1
- package/esm/item/node.js +19 -10
- package/esm/item/node.js.map +1 -1
- package/esm/runtime/controller/item.d.ts +1 -0
- package/esm/runtime/controller/item.js +271 -151
- package/esm/runtime/controller/item.js.map +1 -1
- package/esm/runtime/graph.d.ts +98 -18
- package/esm/runtime/graph.js +427 -75
- package/esm/runtime/graph.js.map +1 -1
- package/esm/stdlib/behavior/activate-relations.js +2 -2
- package/esm/stdlib/behavior/activate-relations.js.map +1 -1
- package/esm/stdlib/behavior/brush-select.js +1 -2
- package/esm/stdlib/behavior/brush-select.js.map +1 -1
- package/esm/stdlib/behavior/click-select.js +1 -1
- package/esm/stdlib/behavior/click-select.js.map +1 -1
- package/esm/stdlib/behavior/create-edge.d.ts +57 -0
- package/esm/stdlib/behavior/create-edge.js +206 -0
- package/esm/stdlib/behavior/create-edge.js.map +1 -0
- package/esm/stdlib/behavior/drag-canvas.d.ts +1 -1
- package/esm/stdlib/behavior/drag-canvas.js +51 -28
- package/esm/stdlib/behavior/drag-canvas.js.map +1 -1
- package/esm/stdlib/behavior/drag-combo.d.ts +2 -2
- package/esm/stdlib/behavior/drag-combo.js +43 -32
- package/esm/stdlib/behavior/drag-combo.js.map +1 -1
- package/esm/stdlib/behavior/drag-node.d.ts +3 -3
- package/esm/stdlib/behavior/drag-node.js +76 -63
- package/esm/stdlib/behavior/drag-node.js.map +1 -1
- package/esm/stdlib/behavior/index.d.ts +2 -0
- package/esm/stdlib/behavior/index.js +2 -0
- package/esm/stdlib/behavior/index.js.map +1 -1
- package/esm/stdlib/behavior/lasso-select.d.ts +1 -1
- package/esm/stdlib/behavior/lasso-select.js +1 -2
- package/esm/stdlib/behavior/lasso-select.js.map +1 -1
- package/esm/stdlib/behavior/scroll-canvas.d.ts +67 -0
- package/esm/stdlib/behavior/scroll-canvas.js +266 -0
- package/esm/stdlib/behavior/scroll-canvas.js.map +1 -0
- package/esm/stdlib/behavior/zoom-canvas.d.ts +1 -1
- package/esm/stdlib/behavior/zoom-canvas.js +47 -24
- package/esm/stdlib/behavior/zoom-canvas.js.map +1 -1
- package/esm/stdlib/index.d.ts +6 -0
- package/esm/stdlib/index.js +15 -9
- package/esm/stdlib/index.js.map +1 -1
- package/esm/stdlib/item/edge/base.d.ts +1 -1
- package/esm/stdlib/item/edge/base.js +13 -4
- package/esm/stdlib/item/edge/base.js.map +1 -1
- package/esm/stdlib/item/node/base.d.ts +1 -1
- package/esm/stdlib/item/node/base.js +11 -12
- package/esm/stdlib/item/node/base.js.map +1 -1
- package/esm/stdlib/item/node/image.d.ts +1 -1
- package/esm/stdlib/item/node/image.js +1 -1
- package/esm/stdlib/item/node/image.js.map +1 -1
- package/esm/stdlib/plugin/history/combo-command.js +2 -2
- package/esm/stdlib/plugin/history/combo-command.js.map +1 -1
- package/esm/stdlib/plugin/history/index.d.ts +10 -10
- package/esm/stdlib/plugin/history/index.js +14 -14
- package/esm/stdlib/plugin/history/index.js.map +1 -1
- package/esm/stdlib/plugin/history/item-data-command.js +4 -4
- package/esm/stdlib/plugin/history/item-data-command.js.map +1 -1
- package/esm/stdlib/plugin/history/layer-updated-command.js +2 -2
- package/esm/stdlib/plugin/history/layer-updated-command.js.map +1 -1
- package/esm/stdlib/plugin/history/state-updated-command.js +1 -1
- package/esm/stdlib/plugin/history/state-updated-command.js.map +1 -1
- package/esm/stdlib/plugin/history/visibility-updated-command.js +2 -2
- package/esm/stdlib/plugin/history/visibility-updated-command.js.map +1 -1
- package/esm/stdlib/plugin/hull/hullComponent.d.ts +1 -1
- package/esm/stdlib/plugin/hull/hullComponent.js +3 -6
- package/esm/stdlib/plugin/hull/hullComponent.js.map +1 -1
- package/esm/stdlib/plugin/index.d.ts +1 -0
- package/esm/stdlib/plugin/index.js +1 -0
- package/esm/stdlib/plugin/index.js.map +1 -1
- package/esm/stdlib/plugin/minimap/index.d.ts +5 -1
- package/esm/stdlib/plugin/minimap/index.js +109 -8
- package/esm/stdlib/plugin/minimap/index.js.map +1 -1
- package/esm/stdlib/plugin/snapline/index.d.ts +163 -0
- package/esm/stdlib/plugin/snapline/index.js +1052 -0
- package/esm/stdlib/plugin/snapline/index.js.map +1 -0
- package/esm/stdlib/plugin/types.d.ts +1 -0
- package/esm/types/graph.d.ts +45 -19
- package/esm/types/hook.d.ts +22 -2
- package/esm/types/spec.d.ts +19 -3
- package/esm/util/bbox.d.ts +16 -1
- package/esm/util/bbox.js +29 -0
- package/esm/util/bbox.js.map +1 -1
- package/esm/util/item.d.ts +16 -1
- package/esm/util/item.js +31 -8
- package/esm/util/item.js.map +1 -1
- package/esm/util/shape.js +2 -2
- package/esm/util/shape.js.map +1 -1
- package/esm/util/warn.d.ts +14 -0
- package/esm/util/warn.js +4 -0
- package/esm/util/warn.js.map +1 -0
- package/lib/index.d.ts +15 -1
- package/lib/index.js +1 -1
- package/lib/item/combo.d.ts +1 -1
- package/lib/item/combo.js +16 -9
- package/lib/item/combo.js.map +1 -1
- package/lib/item/edge.d.ts +2 -1
- package/lib/item/edge.js +18 -8
- package/lib/item/edge.js.map +1 -1
- package/lib/item/item.d.ts +3 -2
- package/lib/item/item.js +12 -6
- package/lib/item/item.js.map +1 -1
- package/lib/item/node.d.ts +2 -1
- package/lib/item/node.js +19 -10
- package/lib/item/node.js.map +1 -1
- package/lib/runtime/controller/item.d.ts +1 -0
- package/lib/runtime/controller/item.js +270 -150
- package/lib/runtime/controller/item.js.map +1 -1
- package/lib/runtime/graph.d.ts +98 -18
- package/lib/runtime/graph.js +427 -75
- package/lib/runtime/graph.js.map +1 -1
- package/lib/stdlib/behavior/activate-relations.js +2 -2
- package/lib/stdlib/behavior/activate-relations.js.map +1 -1
- package/lib/stdlib/behavior/brush-select.js +1 -2
- package/lib/stdlib/behavior/brush-select.js.map +1 -1
- package/lib/stdlib/behavior/click-select.js +1 -1
- package/lib/stdlib/behavior/click-select.js.map +1 -1
- package/lib/stdlib/behavior/create-edge.d.ts +57 -0
- package/lib/stdlib/behavior/create-edge.js +210 -0
- package/lib/stdlib/behavior/create-edge.js.map +1 -0
- package/lib/stdlib/behavior/drag-canvas.d.ts +1 -1
- package/lib/stdlib/behavior/drag-canvas.js +51 -28
- package/lib/stdlib/behavior/drag-canvas.js.map +1 -1
- package/lib/stdlib/behavior/drag-combo.d.ts +2 -2
- package/lib/stdlib/behavior/drag-combo.js +43 -32
- package/lib/stdlib/behavior/drag-combo.js.map +1 -1
- package/lib/stdlib/behavior/drag-node.d.ts +3 -3
- package/lib/stdlib/behavior/drag-node.js +76 -63
- package/lib/stdlib/behavior/drag-node.js.map +1 -1
- package/lib/stdlib/behavior/index.d.ts +2 -0
- package/lib/stdlib/behavior/index.js +2 -0
- package/lib/stdlib/behavior/index.js.map +1 -1
- package/lib/stdlib/behavior/lasso-select.d.ts +1 -1
- package/lib/stdlib/behavior/lasso-select.js +1 -2
- package/lib/stdlib/behavior/lasso-select.js.map +1 -1
- package/lib/stdlib/behavior/scroll-canvas.d.ts +67 -0
- package/lib/stdlib/behavior/scroll-canvas.js +270 -0
- package/lib/stdlib/behavior/scroll-canvas.js.map +1 -0
- package/lib/stdlib/behavior/zoom-canvas.d.ts +1 -1
- package/lib/stdlib/behavior/zoom-canvas.js +47 -24
- package/lib/stdlib/behavior/zoom-canvas.js.map +1 -1
- package/lib/stdlib/index.d.ts +6 -0
- package/lib/stdlib/index.js +15 -9
- package/lib/stdlib/index.js.map +1 -1
- package/lib/stdlib/item/edge/base.d.ts +1 -1
- package/lib/stdlib/item/edge/base.js +13 -4
- package/lib/stdlib/item/edge/base.js.map +1 -1
- package/lib/stdlib/item/node/base.d.ts +1 -1
- package/lib/stdlib/item/node/base.js +11 -12
- package/lib/stdlib/item/node/base.js.map +1 -1
- package/lib/stdlib/item/node/image.d.ts +1 -1
- package/lib/stdlib/item/node/image.js +1 -1
- package/lib/stdlib/item/node/image.js.map +1 -1
- package/lib/stdlib/plugin/history/combo-command.js +2 -2
- package/lib/stdlib/plugin/history/combo-command.js.map +1 -1
- package/lib/stdlib/plugin/history/index.d.ts +10 -10
- package/lib/stdlib/plugin/history/index.js +14 -14
- package/lib/stdlib/plugin/history/index.js.map +1 -1
- package/lib/stdlib/plugin/history/item-data-command.js +4 -4
- package/lib/stdlib/plugin/history/item-data-command.js.map +1 -1
- package/lib/stdlib/plugin/history/layer-updated-command.js +2 -2
- package/lib/stdlib/plugin/history/layer-updated-command.js.map +1 -1
- package/lib/stdlib/plugin/history/state-updated-command.js +1 -1
- package/lib/stdlib/plugin/history/state-updated-command.js.map +1 -1
- package/lib/stdlib/plugin/history/visibility-updated-command.js +2 -2
- package/lib/stdlib/plugin/history/visibility-updated-command.js.map +1 -1
- package/lib/stdlib/plugin/hull/hullComponent.d.ts +1 -1
- package/lib/stdlib/plugin/hull/hullComponent.js +3 -6
- package/lib/stdlib/plugin/hull/hullComponent.js.map +1 -1
- package/lib/stdlib/plugin/index.d.ts +1 -0
- package/lib/stdlib/plugin/index.js +1 -0
- package/lib/stdlib/plugin/index.js.map +1 -1
- package/lib/stdlib/plugin/minimap/index.d.ts +5 -1
- package/lib/stdlib/plugin/minimap/index.js +109 -8
- package/lib/stdlib/plugin/minimap/index.js.map +1 -1
- package/lib/stdlib/plugin/snapline/index.d.ts +163 -0
- package/lib/stdlib/plugin/snapline/index.js +1056 -0
- package/lib/stdlib/plugin/snapline/index.js.map +1 -0
- package/lib/stdlib/plugin/types.d.ts +1 -0
- package/lib/types/graph.d.ts +45 -19
- package/lib/types/hook.d.ts +22 -2
- package/lib/types/spec.d.ts +19 -3
- package/lib/util/bbox.d.ts +16 -1
- package/lib/util/bbox.js +32 -1
- package/lib/util/bbox.js.map +1 -1
- package/lib/util/item.d.ts +16 -1
- package/lib/util/item.js +33 -9
- package/lib/util/item.js.map +1 -1
- package/lib/util/shape.js +2 -2
- package/lib/util/shape.js.map +1 -1
- package/lib/util/warn.d.ts +14 -0
- package/lib/util/warn.js +8 -0
- package/lib/util/warn.js.map +1 -0
- package/package.json +2 -2
- package/src/index.ts +1 -1
- package/src/item/combo.ts +14 -9
- package/src/item/edge.ts +17 -8
- package/src/item/item.ts +11 -6
- package/src/item/node.ts +24 -16
- package/src/runtime/controller/item.ts +240 -72
- package/src/runtime/graph.ts +536 -80
- package/src/stdlib/behavior/activate-relations.ts +2 -2
- package/src/stdlib/behavior/brush-select.ts +4 -2
- package/src/stdlib/behavior/click-select.ts +1 -1
- package/src/stdlib/behavior/create-edge.ts +295 -0
- package/src/stdlib/behavior/drag-canvas.ts +67 -29
- package/src/stdlib/behavior/drag-combo.ts +10 -10
- package/src/stdlib/behavior/drag-node.ts +18 -18
- package/src/stdlib/behavior/index.ts +2 -0
- package/src/stdlib/behavior/lasso-select.ts +5 -3
- package/src/stdlib/behavior/scroll-canvas.ts +348 -0
- package/src/stdlib/behavior/zoom-canvas.ts +61 -25
- package/src/stdlib/index.ts +16 -7
- package/src/stdlib/item/edge/base.ts +13 -5
- package/src/stdlib/item/node/base.ts +15 -14
- package/src/stdlib/item/node/image.ts +1 -1
- package/src/stdlib/plugin/history/combo-command.ts +2 -2
- package/src/stdlib/plugin/history/index.ts +14 -14
- package/src/stdlib/plugin/history/item-data-command.ts +4 -4
- package/src/stdlib/plugin/history/layer-updated-command.ts +2 -2
- package/src/stdlib/plugin/history/state-updated-command.ts +1 -1
- package/src/stdlib/plugin/history/visibility-updated-command.ts +2 -2
- package/src/stdlib/plugin/hull/hullComponent.ts +8 -5
- package/src/stdlib/plugin/index.ts +1 -0
- package/src/stdlib/plugin/minimap/index.ts +113 -9
- package/src/stdlib/plugin/snapline/index.ts +1277 -0
- package/src/stdlib/plugin/types.ts +1 -0
- package/src/types/graph.ts +53 -22
- package/src/types/hook.ts +22 -2
- package/src/types/spec.ts +22 -3
- package/src/util/bbox.ts +38 -1
- package/src/util/item.ts +65 -28
- package/src/util/shape.ts +2 -2
- package/src/util/warn.ts +20 -0
|
@@ -118,7 +118,7 @@ export class ActivateRelations extends Behavior {
|
|
|
118
118
|
edgeIds,
|
|
119
119
|
);
|
|
120
120
|
|
|
121
|
-
graph.
|
|
121
|
+
graph.historyBatch(() => {
|
|
122
122
|
/** 节点 */
|
|
123
123
|
graph.setItemState(activeNodeIds, ACTIVE_STATE, true);
|
|
124
124
|
graph.setItemState(inactiveNodeIds, ACTIVE_STATE, false);
|
|
@@ -132,7 +132,7 @@ export class ActivateRelations extends Behavior {
|
|
|
132
132
|
}
|
|
133
133
|
public clearActiveState(e: any) {
|
|
134
134
|
const { activeState: ACTIVE_STATE } = this.options;
|
|
135
|
-
this.graph.
|
|
135
|
+
this.graph.historyBatch(() => {
|
|
136
136
|
this.graph.setItemState(this.prevNodeIds, ACTIVE_STATE, false);
|
|
137
137
|
this.graph.setItemState(this.prevEdgeIds, ACTIVE_STATE, false);
|
|
138
138
|
});
|
|
@@ -345,8 +345,10 @@ export class BrushSelect extends Behavior {
|
|
|
345
345
|
const { graph, options } = this;
|
|
346
346
|
const { brushStyle } = options;
|
|
347
347
|
const brush = graph.drawTransient('rect', BRUSH_SHAPE_ID, {
|
|
348
|
-
style:
|
|
349
|
-
|
|
348
|
+
style: {
|
|
349
|
+
...brushStyle,
|
|
350
|
+
pointerEvents: 'none',
|
|
351
|
+
},
|
|
350
352
|
});
|
|
351
353
|
return brush;
|
|
352
354
|
}
|
|
@@ -136,7 +136,7 @@ export class ClickSelect extends Behavior {
|
|
|
136
136
|
|
|
137
137
|
// Select/Unselect item.
|
|
138
138
|
if (this.options.shouldUpdate(event)) {
|
|
139
|
-
this.graph.
|
|
139
|
+
this.graph.historyBatch(() => {
|
|
140
140
|
if (!multiple) {
|
|
141
141
|
// Not multiple, clear all currently selected items
|
|
142
142
|
this.graph.setItemState(this.selectedIds, state, false);
|
|
@@ -0,0 +1,295 @@
|
|
|
1
|
+
import type { IG6GraphEvent } from '../../types';
|
|
2
|
+
import { warn } from '../../util/warn';
|
|
3
|
+
import { generateEdgeID } from '../../util/item';
|
|
4
|
+
import { Behavior } from '../../types/behavior';
|
|
5
|
+
import { EdgeDisplayModelData } from '../../types/edge';
|
|
6
|
+
|
|
7
|
+
const KEYBOARD_TRIGGERS = ['shift', 'ctrl', 'control', 'alt', 'meta'] as const;
|
|
8
|
+
const EVENT_TRIGGERS = ['click', 'drag'] as const;
|
|
9
|
+
|
|
10
|
+
const VIRTUAL_EDGE_ID = 'g6-create-edge-virtual-edge';
|
|
11
|
+
const DUMMY_NODE_ID = 'g6-create-edge-dummy-node';
|
|
12
|
+
|
|
13
|
+
// type Trigger = (typeof EVENT_TRIGGERS)[number];
|
|
14
|
+
|
|
15
|
+
interface CreateEdgeOptions {
|
|
16
|
+
/**
|
|
17
|
+
* The triggering conditions for this interaction can be either 'click' or 'drag'.
|
|
18
|
+
* Default to `click`.
|
|
19
|
+
*/
|
|
20
|
+
trigger: (typeof EVENT_TRIGGERS)[number];
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Keyboard keys serve as auxiliary triggers for this interaction.
|
|
24
|
+
* cound be 'shift', 'ctrl', 'control', 'alt', 'meta', undefined.
|
|
25
|
+
*/
|
|
26
|
+
key?: (typeof KEYBOARD_TRIGGERS)[number];
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Config of the created edge.
|
|
30
|
+
*/
|
|
31
|
+
edgeConfig: EdgeDisplayModelData;
|
|
32
|
+
/**
|
|
33
|
+
* The event name to trigger after creating the virtual edge.
|
|
34
|
+
*/
|
|
35
|
+
createVirtualEventName?: string;
|
|
36
|
+
/**
|
|
37
|
+
* The event name to trigger after creating the actual edge.
|
|
38
|
+
*/
|
|
39
|
+
createActualEventName?: string;
|
|
40
|
+
/**
|
|
41
|
+
* The event name to trigger after canceling the behavior.
|
|
42
|
+
*/
|
|
43
|
+
cancelCreateEventName?: string;
|
|
44
|
+
/**
|
|
45
|
+
* Whether allow the behavior happen on the current item.
|
|
46
|
+
*/
|
|
47
|
+
shouldBegin: (event: IG6GraphEvent) => boolean;
|
|
48
|
+
/**
|
|
49
|
+
*
|
|
50
|
+
* Whether it is allowed to end the creation of edges under the current conditions being operated.
|
|
51
|
+
*/
|
|
52
|
+
shouldEnd: (event: IG6GraphEvent) => boolean;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const DEFAULT_OPTIONS: CreateEdgeOptions = {
|
|
56
|
+
trigger: 'click',
|
|
57
|
+
key: undefined,
|
|
58
|
+
shouldBegin: () => true,
|
|
59
|
+
shouldEnd: () => false,
|
|
60
|
+
edgeConfig: {},
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
export class CreateEdge extends Behavior {
|
|
64
|
+
isKeyDown = false;
|
|
65
|
+
addingEdge = null;
|
|
66
|
+
dummyNode = null;
|
|
67
|
+
|
|
68
|
+
constructor(options: Partial<CreateEdgeOptions>) {
|
|
69
|
+
super(Object.assign({}, DEFAULT_OPTIONS, options));
|
|
70
|
+
this.validateOptions(options);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
validateOptions(options: Partial<CreateEdgeOptions>) {
|
|
74
|
+
if (options.trigger && !EVENT_TRIGGERS.includes(options.trigger)) {
|
|
75
|
+
warn({
|
|
76
|
+
optionName: `create-edge.trigger`,
|
|
77
|
+
shouldBe: EVENT_TRIGGERS,
|
|
78
|
+
now: options.trigger,
|
|
79
|
+
scope: 'behavior',
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
this.options.trigger = DEFAULT_OPTIONS.trigger;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
if (options.key && !KEYBOARD_TRIGGERS.includes(options.key)) {
|
|
86
|
+
warn({
|
|
87
|
+
optionName: `create-edge.key`,
|
|
88
|
+
shouldBe: KEYBOARD_TRIGGERS,
|
|
89
|
+
now: options.key,
|
|
90
|
+
scope: 'behavior',
|
|
91
|
+
});
|
|
92
|
+
this.options.key = DEFAULT_OPTIONS.key;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
getEvents = () => {
|
|
97
|
+
const { trigger, key } = this.options;
|
|
98
|
+
const [CLICK_NAME] = EVENT_TRIGGERS;
|
|
99
|
+
|
|
100
|
+
const triggerEvents =
|
|
101
|
+
trigger === CLICK_NAME
|
|
102
|
+
? {
|
|
103
|
+
'node:click': this.handleCreateEdge,
|
|
104
|
+
pointermove: this.updateEndPoint,
|
|
105
|
+
'edge:click': this.cancelCreating,
|
|
106
|
+
'canvas:click': this.cancelCreating,
|
|
107
|
+
'combo:click': this.handleCreateEdge,
|
|
108
|
+
}
|
|
109
|
+
: {
|
|
110
|
+
'node:dragstart': this.handleCreateEdge,
|
|
111
|
+
'combo:dragstart': this.handleCreateEdge,
|
|
112
|
+
drag: this.updateEndPoint,
|
|
113
|
+
drop: this.onDrop,
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
const keyboardEvents = key
|
|
117
|
+
? {
|
|
118
|
+
keydown: this.onKeyDown,
|
|
119
|
+
keyup: this.onKeyUp,
|
|
120
|
+
}
|
|
121
|
+
: {};
|
|
122
|
+
|
|
123
|
+
return { ...triggerEvents, ...keyboardEvents } as Record<
|
|
124
|
+
string,
|
|
125
|
+
(e: IG6GraphEvent) => void
|
|
126
|
+
>;
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
handleCreateEdge = (e: IG6GraphEvent) => {
|
|
130
|
+
if (this.options.key && !this.isKeyDown) {
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
if (this.options.shouldEnd(e)) {
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
const { graph, options, addingEdge } = this;
|
|
139
|
+
const currentNodeId = e.itemId;
|
|
140
|
+
|
|
141
|
+
const { edgeConfig, createVirtualEventName, createActualEventName } =
|
|
142
|
+
options;
|
|
143
|
+
|
|
144
|
+
if (addingEdge) {
|
|
145
|
+
// create edge end, add the actual edge to graph and remove the virtual edge and node
|
|
146
|
+
graph.addData('edge', {
|
|
147
|
+
id: generateEdgeID(addingEdge.source, currentNodeId),
|
|
148
|
+
source: addingEdge.source,
|
|
149
|
+
target: currentNodeId,
|
|
150
|
+
data: {
|
|
151
|
+
...edgeConfig,
|
|
152
|
+
type:
|
|
153
|
+
currentNodeId === addingEdge.source ? 'loop-edge' : edgeConfig.type,
|
|
154
|
+
},
|
|
155
|
+
});
|
|
156
|
+
if (createActualEventName) {
|
|
157
|
+
graph.emit(createActualEventName, { edge: addingEdge });
|
|
158
|
+
}
|
|
159
|
+
this.cancelCreating();
|
|
160
|
+
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
this.dummyNode = graph.addData('node', {
|
|
165
|
+
id: DUMMY_NODE_ID,
|
|
166
|
+
data: {
|
|
167
|
+
x: e.canvas.x,
|
|
168
|
+
y: e.canvas.y,
|
|
169
|
+
keyShape: {
|
|
170
|
+
opacity: 0,
|
|
171
|
+
interactive: false,
|
|
172
|
+
},
|
|
173
|
+
labelShape: {
|
|
174
|
+
opacity: 0,
|
|
175
|
+
},
|
|
176
|
+
anchorPoints: [[0.5, 0.5]],
|
|
177
|
+
},
|
|
178
|
+
});
|
|
179
|
+
this.addingEdge = graph.addData('edge', {
|
|
180
|
+
id: VIRTUAL_EDGE_ID,
|
|
181
|
+
source: currentNodeId,
|
|
182
|
+
target: DUMMY_NODE_ID,
|
|
183
|
+
data: {
|
|
184
|
+
...edgeConfig,
|
|
185
|
+
},
|
|
186
|
+
});
|
|
187
|
+
if (createVirtualEventName) {
|
|
188
|
+
graph.emit(createVirtualEventName, { edge: this.addingEdge });
|
|
189
|
+
}
|
|
190
|
+
};
|
|
191
|
+
|
|
192
|
+
onDrop = async (e: IG6GraphEvent) => {
|
|
193
|
+
const { addingEdge, options, graph } = this;
|
|
194
|
+
|
|
195
|
+
const { edgeConfig, key, createActualEventName } = options;
|
|
196
|
+
if (key && !this.isKeyDown) {
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
if (!addingEdge) {
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
const elements = await this.graph.canvas.document.elementsFromPoint(
|
|
205
|
+
e.canvas.x,
|
|
206
|
+
e.canvas.y,
|
|
207
|
+
);
|
|
208
|
+
const currentIds = elements
|
|
209
|
+
// @ts-ignore TODO: G type
|
|
210
|
+
.map((ele) => ele.parentNode.getAttribute?.('data-item-id'))
|
|
211
|
+
.filter((id) => id !== undefined && !DUMMY_NODE_ID !== id);
|
|
212
|
+
const dropId = currentIds.find(
|
|
213
|
+
(id) => this.graph.getComboData(id) || this.graph.getNodeData(id),
|
|
214
|
+
);
|
|
215
|
+
|
|
216
|
+
if (!dropId) {
|
|
217
|
+
this.cancelCreating();
|
|
218
|
+
return;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
graph.addData('edge', {
|
|
222
|
+
id: generateEdgeID(addingEdge.source, dropId),
|
|
223
|
+
source: addingEdge.source,
|
|
224
|
+
target: dropId,
|
|
225
|
+
data: {
|
|
226
|
+
...edgeConfig,
|
|
227
|
+
type: dropId === addingEdge.source ? 'loop-edge' : edgeConfig.type,
|
|
228
|
+
},
|
|
229
|
+
});
|
|
230
|
+
if (createActualEventName) {
|
|
231
|
+
graph.emit(createActualEventName, { edge: addingEdge });
|
|
232
|
+
}
|
|
233
|
+
this.cancelCreating();
|
|
234
|
+
};
|
|
235
|
+
|
|
236
|
+
updateEndPoint = (e: IG6GraphEvent) => {
|
|
237
|
+
const { options, graph, addingEdge, isKeyDown } = this;
|
|
238
|
+
if (options.key && !isKeyDown) {
|
|
239
|
+
return;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
if (!addingEdge) {
|
|
243
|
+
return;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
const sourceId = addingEdge.source,
|
|
247
|
+
targetId = addingEdge.target;
|
|
248
|
+
|
|
249
|
+
if (!graph.getItemById(sourceId)) {
|
|
250
|
+
this.addingEdge = null;
|
|
251
|
+
return;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
graph.updatePosition('node', {
|
|
255
|
+
id: targetId,
|
|
256
|
+
data: {
|
|
257
|
+
x: e.canvas.x,
|
|
258
|
+
y: e.canvas.y,
|
|
259
|
+
},
|
|
260
|
+
});
|
|
261
|
+
};
|
|
262
|
+
|
|
263
|
+
cancelCreating = () => {
|
|
264
|
+
if (this.addingEdge) {
|
|
265
|
+
this.graph.removeData('edge', VIRTUAL_EDGE_ID);
|
|
266
|
+
this.addingEdge = null;
|
|
267
|
+
}
|
|
268
|
+
if (this.dummyNode) {
|
|
269
|
+
this.graph.removeData('node', DUMMY_NODE_ID);
|
|
270
|
+
this.dummyNode = null;
|
|
271
|
+
}
|
|
272
|
+
if (this.options.cancelCreateEventName) {
|
|
273
|
+
this.graph.emit(this.options.cancelCreateEventName, {});
|
|
274
|
+
}
|
|
275
|
+
};
|
|
276
|
+
|
|
277
|
+
onKeyDown = (e: KeyboardEvent) => {
|
|
278
|
+
const code = e.key;
|
|
279
|
+
|
|
280
|
+
if (!code) {
|
|
281
|
+
return;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
if (code.toLocaleLowerCase() === this.options.key) {
|
|
285
|
+
this.isKeyDown = true;
|
|
286
|
+
}
|
|
287
|
+
};
|
|
288
|
+
|
|
289
|
+
onKeyUp = (e: IG6GraphEvent) => {
|
|
290
|
+
if (this.addingEdge) {
|
|
291
|
+
this.cancelCreating();
|
|
292
|
+
}
|
|
293
|
+
this.isKeyDown = false;
|
|
294
|
+
};
|
|
295
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { isNumber } from '@antv/util';
|
|
2
|
+
import { ID, IG6GraphEvent } from '../../types';
|
|
2
3
|
import { Behavior } from '../../types/behavior';
|
|
3
4
|
import { Point } from '../../types/common';
|
|
4
5
|
|
|
@@ -53,7 +54,7 @@ export interface DragCanvasOptions {
|
|
|
53
54
|
}
|
|
54
55
|
|
|
55
56
|
const DEFAULT_OPTIONS: Required<DragCanvasOptions> = {
|
|
56
|
-
enableOptimize:
|
|
57
|
+
enableOptimize: undefined,
|
|
57
58
|
dragOnItems: false,
|
|
58
59
|
trigger: 'drag',
|
|
59
60
|
direction: 'both',
|
|
@@ -132,25 +133,44 @@ export class DragCanvas extends Behavior {
|
|
|
132
133
|
|
|
133
134
|
private hideShapes() {
|
|
134
135
|
const { graph } = this;
|
|
135
|
-
|
|
136
|
+
|
|
137
|
+
const { tileBehavior: graphBehaviorOptimize, tileBehaviorSize = 1000 } =
|
|
138
|
+
graph.getSpecification().optimize || {};
|
|
139
|
+
const optimize = this.options.enableOptimize || graphBehaviorOptimize;
|
|
140
|
+
const shouldOptimize = isNumber(optimize)
|
|
141
|
+
? graph.getAllNodesData().length > optimize
|
|
142
|
+
: optimize;
|
|
143
|
+
|
|
144
|
+
if (shouldOptimize) {
|
|
136
145
|
this.hiddenEdgeIds = graph
|
|
137
146
|
.getAllEdgesData()
|
|
138
147
|
.map((edge) => edge.id)
|
|
139
148
|
.filter((id) => graph.getItemVisible(id) === true);
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
149
|
+
this.hiddenNodeIds = graph
|
|
150
|
+
.getAllNodesData()
|
|
151
|
+
.map((node) => node.id)
|
|
152
|
+
.filter((id) => graph.getItemVisible(id) === true);
|
|
153
|
+
let requestId;
|
|
154
|
+
const hiddenIds = [...this.hiddenNodeIds];
|
|
155
|
+
const sectionNum = Math.ceil(hiddenIds.length / tileBehaviorSize);
|
|
156
|
+
const sections = Array.from({ length: sectionNum }, (v, i) =>
|
|
157
|
+
hiddenIds.slice(
|
|
158
|
+
i * tileBehaviorSize,
|
|
159
|
+
i * tileBehaviorSize + tileBehaviorSize,
|
|
160
|
+
),
|
|
161
|
+
);
|
|
162
|
+
const update = () => {
|
|
163
|
+
if (!sections.length) {
|
|
164
|
+
cancelAnimationFrame(requestId);
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
const section = sections.shift();
|
|
168
|
+
graph.executeWithNoStack(() => {
|
|
169
|
+
graph.hideItem(section, false, true);
|
|
170
|
+
});
|
|
171
|
+
requestId = requestAnimationFrame(update);
|
|
172
|
+
};
|
|
173
|
+
requestId = requestAnimationFrame(update);
|
|
154
174
|
}
|
|
155
175
|
}
|
|
156
176
|
|
|
@@ -241,19 +261,37 @@ export class DragCanvas extends Behavior {
|
|
|
241
261
|
this.pointerDownAt = undefined;
|
|
242
262
|
this.dragging = false;
|
|
243
263
|
|
|
244
|
-
const { graph } = this;
|
|
245
|
-
|
|
246
|
-
graph.
|
|
247
|
-
|
|
248
|
-
|
|
264
|
+
const { graph, hiddenNodeIds, hiddenEdgeIds = [] } = this;
|
|
265
|
+
const { tileBehavior: graphBehaviorOptimize, tileBehaviorSize = 1000 } =
|
|
266
|
+
graph.getSpecification().optimize || {};
|
|
267
|
+
const optimize = this.options.enableOptimize || graphBehaviorOptimize;
|
|
268
|
+
const shouldOptimize = isNumber(optimize)
|
|
269
|
+
? graph.getAllNodesData().length > optimize
|
|
270
|
+
: optimize;
|
|
271
|
+
|
|
272
|
+
if (shouldOptimize) {
|
|
273
|
+
if (hiddenNodeIds) {
|
|
274
|
+
let requestId;
|
|
275
|
+
const hiddenIds = [...hiddenNodeIds, ...hiddenEdgeIds];
|
|
276
|
+
const sectionNum = Math.ceil(hiddenIds.length / tileBehaviorSize);
|
|
277
|
+
const sections = Array.from({ length: sectionNum }, (v, i) =>
|
|
278
|
+
hiddenIds.slice(
|
|
279
|
+
i * tileBehaviorSize,
|
|
280
|
+
i * tileBehaviorSize + tileBehaviorSize,
|
|
281
|
+
),
|
|
282
|
+
);
|
|
283
|
+
const update = () => {
|
|
284
|
+
if (!sections.length) {
|
|
285
|
+
cancelAnimationFrame(requestId);
|
|
286
|
+
return;
|
|
287
|
+
}
|
|
288
|
+
graph.startHistoryBatch();
|
|
289
|
+
graph.showItem(sections.shift(), false);
|
|
290
|
+
graph.stopHistoryBatch();
|
|
291
|
+
requestId = requestAnimationFrame(update);
|
|
292
|
+
};
|
|
293
|
+
requestId = requestAnimationFrame(update);
|
|
249
294
|
}
|
|
250
|
-
// if (this.hiddenNodeIds) {
|
|
251
|
-
// this.hiddenNodeIds.forEach((id) => {
|
|
252
|
-
// this.graph.drawTransient('node', id, { action: 'remove' });
|
|
253
|
-
// });
|
|
254
|
-
// graph.showItem(this.hiddenNodeIds, true);
|
|
255
|
-
// }
|
|
256
|
-
graph.stopBatch();
|
|
257
295
|
}
|
|
258
296
|
}
|
|
259
297
|
|
|
@@ -250,7 +250,7 @@ export class DragCombo extends Behavior {
|
|
|
250
250
|
selectedComboIds,
|
|
251
251
|
this.hiddenComboTreeRoots,
|
|
252
252
|
);
|
|
253
|
-
this.graph.
|
|
253
|
+
this.graph.executeWithNoStack(() => {
|
|
254
254
|
this.graph.hideItem(
|
|
255
255
|
this.hiddenEdges.map((edge) => edge.id),
|
|
256
256
|
true,
|
|
@@ -280,7 +280,7 @@ export class DragCombo extends Behavior {
|
|
|
280
280
|
});
|
|
281
281
|
|
|
282
282
|
// Hide original edges and nodes. They will be restored when pointerup.
|
|
283
|
-
this.graph.
|
|
283
|
+
this.graph.executeWithNoStack(() => {
|
|
284
284
|
this.graph.hideItem(selectedComboIds, true);
|
|
285
285
|
this.graph.hideItem(
|
|
286
286
|
this.hiddenEdges.map((edge) => edge.id),
|
|
@@ -429,7 +429,7 @@ export class DragCombo extends Behavior {
|
|
|
429
429
|
}
|
|
430
430
|
|
|
431
431
|
public restoreHiddenItems(positions?: Position[]) {
|
|
432
|
-
this.graph.
|
|
432
|
+
this.graph.pauseStack();
|
|
433
433
|
if (this.hiddenEdges.length) {
|
|
434
434
|
this.graph.showItem(
|
|
435
435
|
this.hiddenEdges.map((edge) => edge.id),
|
|
@@ -452,7 +452,7 @@ export class DragCombo extends Behavior {
|
|
|
452
452
|
true,
|
|
453
453
|
);
|
|
454
454
|
}
|
|
455
|
-
this.graph.
|
|
455
|
+
this.graph.resumeStack();
|
|
456
456
|
}
|
|
457
457
|
|
|
458
458
|
public onPointerUp(event: IG6GraphEvent) {
|
|
@@ -526,8 +526,8 @@ export class DragCombo extends Behavior {
|
|
|
526
526
|
this.originPositions = [];
|
|
527
527
|
}
|
|
528
528
|
|
|
529
|
-
public onDropNode(event: IG6GraphEvent) {
|
|
530
|
-
const elements = this.graph.canvas.document.
|
|
529
|
+
public async onDropNode(event: IG6GraphEvent) {
|
|
530
|
+
const elements = await this.graph.canvas.document.elementsFromPoint(
|
|
531
531
|
event.canvas.x,
|
|
532
532
|
event.canvas.y,
|
|
533
533
|
);
|
|
@@ -561,7 +561,7 @@ export class DragCombo extends Behavior {
|
|
|
561
561
|
|
|
562
562
|
public onDropCombo(event: IG6GraphEvent) {
|
|
563
563
|
const newParentId = event.itemId;
|
|
564
|
-
this.graph.
|
|
564
|
+
this.graph.startHistoryBatch();
|
|
565
565
|
this.originPositions.forEach(({ id }) => {
|
|
566
566
|
const model = this.graph.getComboData(id);
|
|
567
567
|
if (!model || model.id === newParentId) return;
|
|
@@ -570,12 +570,12 @@ export class DragCombo extends Behavior {
|
|
|
570
570
|
// event.stopPropagation();
|
|
571
571
|
this.graph.updateData('combo', { id, data: { parentId: newParentId } });
|
|
572
572
|
});
|
|
573
|
-
this.graph.
|
|
573
|
+
this.graph.stopHistoryBatch();
|
|
574
574
|
this.onPointerUp(event);
|
|
575
575
|
}
|
|
576
576
|
|
|
577
577
|
public onDropCanvas(event: IG6GraphEvent) {
|
|
578
|
-
this.graph.
|
|
578
|
+
this.graph.startHistoryBatch();
|
|
579
579
|
this.originPositions.forEach(({ id }) => {
|
|
580
580
|
const model = this.graph.getComboData(id);
|
|
581
581
|
if (!model) return;
|
|
@@ -583,7 +583,7 @@ export class DragCombo extends Behavior {
|
|
|
583
583
|
if (!parentId) return;
|
|
584
584
|
this.graph.updateData('combo', { id, data: { parentId: undefined } });
|
|
585
585
|
});
|
|
586
|
-
this.graph.
|
|
586
|
+
this.graph.stopHistoryBatch();
|
|
587
587
|
this.onPointerUp(event);
|
|
588
588
|
}
|
|
589
589
|
}
|
|
@@ -258,7 +258,7 @@ export class DragNode extends Behavior {
|
|
|
258
258
|
this.selectedNodeIds,
|
|
259
259
|
this.hiddenComboTreeItems,
|
|
260
260
|
);
|
|
261
|
-
this.graph.
|
|
261
|
+
this.graph.executeWithNoStack(() => {
|
|
262
262
|
this.graph.hideItem(
|
|
263
263
|
this.hiddenEdges.map((edge) => edge.id),
|
|
264
264
|
true,
|
|
@@ -292,7 +292,7 @@ export class DragNode extends Behavior {
|
|
|
292
292
|
});
|
|
293
293
|
|
|
294
294
|
// Hide original edges and nodes. They will be restored when pointerup.
|
|
295
|
-
this.graph.
|
|
295
|
+
this.graph.executeWithNoStack(() => {
|
|
296
296
|
this.graph.hideItem(this.selectedNodeIds, true);
|
|
297
297
|
this.graph.hideItem(
|
|
298
298
|
this.hiddenEdges.map((edge) => edge.id),
|
|
@@ -457,7 +457,7 @@ export class DragNode extends Behavior {
|
|
|
457
457
|
this.graph.drawTransient('rect', DELEGATE_SHAPE_ID, { action: 'remove' });
|
|
458
458
|
}
|
|
459
459
|
|
|
460
|
-
public clearTransientItems() {
|
|
460
|
+
public clearTransientItems(positions: Array<Position>) {
|
|
461
461
|
this.hiddenEdges.forEach((edge) => {
|
|
462
462
|
this.graph.drawTransient('node', edge.source, { action: 'remove' });
|
|
463
463
|
this.graph.drawTransient('node', edge.target, { action: 'remove' });
|
|
@@ -472,13 +472,13 @@ export class DragNode extends Behavior {
|
|
|
472
472
|
action: 'remove',
|
|
473
473
|
});
|
|
474
474
|
});
|
|
475
|
-
|
|
475
|
+
positions.forEach(({ id }) => {
|
|
476
476
|
this.graph.drawTransient('node', id, { action: 'remove' });
|
|
477
477
|
});
|
|
478
478
|
}
|
|
479
479
|
|
|
480
480
|
public restoreHiddenItems(positions?: Position[]) {
|
|
481
|
-
this.graph.
|
|
481
|
+
this.graph.pauseStack();
|
|
482
482
|
if (this.hiddenEdges.length) {
|
|
483
483
|
this.graph.showItem(
|
|
484
484
|
this.hiddenEdges.map((edge) => edge.id),
|
|
@@ -508,7 +508,7 @@ export class DragNode extends Behavior {
|
|
|
508
508
|
true,
|
|
509
509
|
);
|
|
510
510
|
}
|
|
511
|
-
this.graph.
|
|
511
|
+
this.graph.resumeStack();
|
|
512
512
|
}
|
|
513
513
|
|
|
514
514
|
public clearState() {
|
|
@@ -543,7 +543,7 @@ export class DragNode extends Behavior {
|
|
|
543
543
|
debounce((positions) => {
|
|
544
544
|
// restore the hidden items after move real nodes done
|
|
545
545
|
if (enableTransient) {
|
|
546
|
-
this.clearTransientItems();
|
|
546
|
+
this.clearTransientItems(positions);
|
|
547
547
|
}
|
|
548
548
|
|
|
549
549
|
if (this.options.enableDelegate) {
|
|
@@ -573,7 +573,7 @@ export class DragNode extends Behavior {
|
|
|
573
573
|
return;
|
|
574
574
|
}
|
|
575
575
|
this.clearDelegate();
|
|
576
|
-
this.clearTransientItems();
|
|
576
|
+
this.clearTransientItems(this.originPositions);
|
|
577
577
|
this.restoreHiddenItems();
|
|
578
578
|
|
|
579
579
|
const enableTransient =
|
|
@@ -589,8 +589,8 @@ export class DragNode extends Behavior {
|
|
|
589
589
|
this.clearState();
|
|
590
590
|
}
|
|
591
591
|
|
|
592
|
-
public onDropNode(event: IG6GraphEvent) {
|
|
593
|
-
const elements = this.graph.canvas.document.
|
|
592
|
+
public async onDropNode(event: IG6GraphEvent) {
|
|
593
|
+
const elements = await this.graph.canvas.document.elementsFromPoint(
|
|
594
594
|
event.canvas.x,
|
|
595
595
|
event.canvas.y,
|
|
596
596
|
);
|
|
@@ -608,7 +608,7 @@ export class DragNode extends Behavior {
|
|
|
608
608
|
? this.graph.getNodeData(dropId).data.parentId
|
|
609
609
|
: dropId;
|
|
610
610
|
|
|
611
|
-
this.graph.
|
|
611
|
+
this.graph.startHistoryBatch();
|
|
612
612
|
this.originPositions.forEach(({ id }) => {
|
|
613
613
|
const model = this.graph.getNodeData(id);
|
|
614
614
|
if (!model) return;
|
|
@@ -621,13 +621,13 @@ export class DragNode extends Behavior {
|
|
|
621
621
|
this.graph.updateData('node', { id, data: { parentId: newParentId } });
|
|
622
622
|
});
|
|
623
623
|
this.onPointerUp(event);
|
|
624
|
-
this.graph.
|
|
624
|
+
this.graph.stopHistoryBatch();
|
|
625
625
|
}
|
|
626
626
|
|
|
627
627
|
public onDropCombo(event: IG6GraphEvent) {
|
|
628
628
|
event.stopPropagation();
|
|
629
629
|
const newParentId = event.itemId;
|
|
630
|
-
this.graph.
|
|
630
|
+
this.graph.startHistoryBatch();
|
|
631
631
|
this.onPointerUp(event);
|
|
632
632
|
this.originPositions.forEach(({ id }) => {
|
|
633
633
|
const model = this.graph.getNodeData(id);
|
|
@@ -637,11 +637,11 @@ export class DragNode extends Behavior {
|
|
|
637
637
|
this.graph.updateData('node', { id, data: { parentId: newParentId } });
|
|
638
638
|
});
|
|
639
639
|
this.clearState();
|
|
640
|
-
this.graph.
|
|
640
|
+
this.graph.stopHistoryBatch();
|
|
641
641
|
}
|
|
642
642
|
|
|
643
|
-
public onDropCanvas(event: IG6GraphEvent) {
|
|
644
|
-
const elements = this.graph.canvas.document.
|
|
643
|
+
public async onDropCanvas(event: IG6GraphEvent) {
|
|
644
|
+
const elements = await this.graph.canvas.document.elementsFromPoint(
|
|
645
645
|
event.canvas.x,
|
|
646
646
|
event.canvas.y,
|
|
647
647
|
);
|
|
@@ -657,7 +657,7 @@ export class DragNode extends Behavior {
|
|
|
657
657
|
const parentId = this.graph.getNodeData(dropId)
|
|
658
658
|
? this.graph.getNodeData(dropId).data.parentId
|
|
659
659
|
: dropId;
|
|
660
|
-
this.graph.
|
|
660
|
+
this.graph.startHistoryBatch();
|
|
661
661
|
this.onPointerUp(event);
|
|
662
662
|
const nodeToUpdate = [];
|
|
663
663
|
this.originPositions.forEach(({ id }) => {
|
|
@@ -671,6 +671,6 @@ export class DragNode extends Behavior {
|
|
|
671
671
|
});
|
|
672
672
|
if (nodeToUpdate.length) this.graph.updateData('node', nodeToUpdate);
|
|
673
673
|
this.clearState();
|
|
674
|
-
this.graph.
|
|
674
|
+
this.graph.stopHistoryBatch();
|
|
675
675
|
}
|
|
676
676
|
}
|