@antv/g6 5.0.0-alpha.8 → 5.0.0-alpha.9
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 +6 -19
- package/esm/index.d.ts +26 -6
- package/esm/item/combo.d.ts +72 -2
- package/esm/item/combo.js +122 -2
- package/esm/item/combo.js.map +1 -1
- package/esm/item/edge.d.ts +3 -3
- package/esm/item/edge.js +4 -5
- package/esm/item/edge.js.map +1 -1
- package/esm/item/item.d.ts +4 -4
- package/esm/item/item.js +38 -9
- package/esm/item/item.js.map +1 -1
- package/esm/item/node.d.ts +20 -16
- package/esm/item/node.js +14 -8
- package/esm/item/node.js.map +1 -1
- package/esm/runtime/controller/data.d.ts +12 -4
- package/esm/runtime/controller/data.js +354 -62
- package/esm/runtime/controller/data.js.map +1 -1
- package/esm/runtime/controller/interaction.js +16 -4
- package/esm/runtime/controller/interaction.js.map +1 -1
- package/esm/runtime/controller/item.d.ts +11 -2
- package/esm/runtime/controller/item.js +344 -52
- package/esm/runtime/controller/item.js.map +1 -1
- package/esm/runtime/controller/layout.js +19 -5
- package/esm/runtime/controller/layout.js.map +1 -1
- package/esm/runtime/graph.d.ts +54 -17
- package/esm/runtime/graph.js +165 -34
- package/esm/runtime/graph.js.map +1 -1
- package/esm/stdlib/behavior/click-select.d.ts +3 -0
- package/esm/stdlib/behavior/click-select.js +13 -1
- package/esm/stdlib/behavior/click-select.js.map +1 -1
- package/esm/stdlib/behavior/collapse-expand-combo.d.ts +29 -0
- package/esm/stdlib/behavior/collapse-expand-combo.js +35 -0
- package/esm/stdlib/behavior/collapse-expand-combo.js.map +1 -0
- package/esm/stdlib/behavior/drag-combo.d.ts +99 -0
- package/esm/stdlib/behavior/drag-combo.js +341 -0
- package/esm/stdlib/behavior/drag-combo.js.map +1 -0
- package/esm/stdlib/behavior/drag-node.d.ts +14 -10
- package/esm/stdlib/behavior/drag-node.js +134 -37
- package/esm/stdlib/behavior/drag-node.js.map +1 -1
- package/esm/stdlib/behavior/hover-activate.d.ts +3 -1
- package/esm/stdlib/behavior/hover-activate.js +3 -1
- package/esm/stdlib/behavior/hover-activate.js.map +1 -1
- package/esm/stdlib/behavior/orbit-canvas-3d.js +1 -1
- package/esm/stdlib/behavior/orbit-canvas-3d.js.map +1 -1
- package/esm/stdlib/behavior/track-canvas-3d.js +1 -1
- package/esm/stdlib/behavior/track-canvas-3d.js.map +1 -1
- package/esm/stdlib/index.d.ts +25 -3
- package/esm/stdlib/index.js +25 -3
- package/esm/stdlib/index.js.map +1 -1
- package/esm/stdlib/item/combo/circle.d.ts +29 -0
- package/esm/stdlib/item/combo/circle.js +56 -0
- package/esm/stdlib/item/combo/circle.js.map +1 -0
- package/esm/stdlib/item/edge/base.d.ts +2 -2
- package/esm/stdlib/item/edge/base.js +3 -0
- package/esm/stdlib/item/edge/base.js.map +1 -1
- package/esm/stdlib/item/edge/cubic-horizon.d.ts +37 -0
- package/esm/stdlib/item/edge/cubic-horizon.js +71 -0
- package/esm/stdlib/item/edge/cubic-horizon.js.map +1 -0
- package/esm/stdlib/item/edge/cubic-vertical.d.ts +37 -0
- package/esm/stdlib/item/edge/cubic-vertical.js +71 -0
- package/esm/stdlib/item/edge/cubic-vertical.js.map +1 -0
- package/esm/stdlib/item/edge/cubic.d.ts +60 -0
- package/esm/stdlib/item/edge/cubic.js +99 -0
- package/esm/stdlib/item/edge/cubic.js.map +1 -0
- package/esm/stdlib/item/edge/index.d.ts +1 -0
- package/esm/stdlib/item/edge/index.js +1 -0
- package/esm/stdlib/item/edge/index.js.map +1 -1
- package/esm/stdlib/item/edge/line.d.ts +1 -1
- package/esm/stdlib/item/edge/quadratic.d.ts +41 -0
- package/esm/stdlib/item/edge/quadratic.js +66 -0
- package/esm/stdlib/item/edge/quadratic.js.map +1 -0
- package/esm/stdlib/item/node/base.d.ts +38 -37
- package/esm/stdlib/item/node/base.js +4 -4
- package/esm/stdlib/item/node/base.js.map +1 -1
- package/esm/stdlib/item/node/index.d.ts +1 -0
- package/esm/stdlib/item/node/index.js +1 -0
- package/esm/stdlib/item/node/index.js.map +1 -1
- package/esm/stdlib/item/node/rect.d.ts +31 -0
- package/esm/stdlib/item/node/rect.js +59 -0
- package/esm/stdlib/item/node/rect.js.map +1 -0
- package/esm/stdlib/plugin/fisheye/index.d.ts +102 -0
- package/esm/stdlib/plugin/fisheye/index.js +487 -0
- package/esm/stdlib/plugin/fisheye/index.js.map +1 -0
- package/esm/stdlib/plugin/menu/index.d.ts +42 -0
- package/esm/stdlib/plugin/menu/index.js +236 -0
- package/esm/stdlib/plugin/menu/index.js.map +1 -0
- package/esm/stdlib/plugin/tooltip/index.d.ts +75 -0
- package/esm/stdlib/plugin/tooltip/index.js +377 -0
- package/esm/stdlib/plugin/tooltip/index.js.map +1 -0
- package/esm/stdlib/theme/dark.js +4 -0
- package/esm/stdlib/theme/dark.js.map +1 -1
- package/esm/stdlib/theme/light.js +54 -9
- package/esm/stdlib/theme/light.js.map +1 -1
- package/esm/types/combo.d.ts +52 -3
- package/esm/types/data.d.ts +4 -4
- package/esm/types/edge.d.ts +2 -3
- package/esm/types/event.d.ts +9 -1
- package/esm/types/event.js +8 -8
- package/esm/types/event.js.map +1 -1
- package/esm/types/graph.d.ts +49 -13
- package/esm/types/hook.d.ts +8 -1
- package/esm/types/item.d.ts +4 -4
- package/esm/types/node.d.ts +4 -5
- package/esm/types/theme.d.ts +1 -1
- package/esm/util/animate.js.map +1 -1
- package/esm/util/canvas.js +8 -0
- package/esm/util/canvas.js.map +1 -1
- package/esm/util/data.d.ts +65 -0
- package/esm/util/data.js +150 -0
- package/esm/util/data.js.map +1 -0
- package/esm/util/event.d.ts +8 -0
- package/esm/util/event.js +16 -0
- package/esm/util/event.js.map +1 -1
- package/esm/util/item.d.ts +2 -1
- package/esm/util/item.js +36 -13
- package/esm/util/item.js.map +1 -1
- package/esm/util/shape.d.ts +39 -4
- package/esm/util/shape.js +101 -1
- package/esm/util/shape.js.map +1 -1
- package/esm/util/zoom.d.ts +2 -2
- package/lib/index.d.ts +26 -6
- package/lib/item/combo.d.ts +72 -2
- package/lib/item/combo.js +122 -2
- package/lib/item/combo.js.map +1 -1
- package/lib/item/edge.d.ts +3 -3
- package/lib/item/edge.js +4 -5
- package/lib/item/edge.js.map +1 -1
- package/lib/item/item.d.ts +4 -4
- package/lib/item/item.js +37 -8
- package/lib/item/item.js.map +1 -1
- package/lib/item/node.d.ts +20 -16
- package/lib/item/node.js +14 -8
- package/lib/item/node.js.map +1 -1
- package/lib/runtime/controller/data.d.ts +12 -4
- package/lib/runtime/controller/data.js +353 -61
- package/lib/runtime/controller/data.js.map +1 -1
- package/lib/runtime/controller/interaction.js +15 -3
- package/lib/runtime/controller/interaction.js.map +1 -1
- package/lib/runtime/controller/item.d.ts +11 -2
- package/lib/runtime/controller/item.js +342 -50
- package/lib/runtime/controller/item.js.map +1 -1
- package/lib/runtime/controller/layout.js +19 -5
- package/lib/runtime/controller/layout.js.map +1 -1
- package/lib/runtime/graph.d.ts +54 -17
- package/lib/runtime/graph.js +165 -34
- package/lib/runtime/graph.js.map +1 -1
- package/lib/stdlib/behavior/click-select.d.ts +3 -0
- package/lib/stdlib/behavior/click-select.js +13 -1
- package/lib/stdlib/behavior/click-select.js.map +1 -1
- package/lib/stdlib/behavior/collapse-expand-combo.d.ts +29 -0
- package/lib/stdlib/behavior/collapse-expand-combo.js +38 -0
- package/lib/stdlib/behavior/collapse-expand-combo.js.map +1 -0
- package/lib/stdlib/behavior/drag-combo.d.ts +99 -0
- package/lib/stdlib/behavior/drag-combo.js +344 -0
- package/lib/stdlib/behavior/drag-combo.js.map +1 -0
- package/lib/stdlib/behavior/drag-node.d.ts +14 -10
- package/lib/stdlib/behavior/drag-node.js +134 -37
- package/lib/stdlib/behavior/drag-node.js.map +1 -1
- package/lib/stdlib/behavior/hover-activate.d.ts +3 -1
- package/lib/stdlib/behavior/hover-activate.js +3 -2
- package/lib/stdlib/behavior/hover-activate.js.map +1 -1
- package/lib/stdlib/behavior/orbit-canvas-3d.js +1 -1
- package/lib/stdlib/behavior/orbit-canvas-3d.js.map +1 -1
- package/lib/stdlib/behavior/track-canvas-3d.js +1 -1
- package/lib/stdlib/behavior/track-canvas-3d.js.map +1 -1
- package/lib/stdlib/index.d.ts +25 -3
- package/lib/stdlib/index.js +25 -3
- package/lib/stdlib/index.js.map +1 -1
- package/lib/stdlib/item/combo/circle.d.ts +29 -0
- package/lib/stdlib/item/combo/circle.js +60 -0
- package/lib/stdlib/item/combo/circle.js.map +1 -0
- package/lib/stdlib/item/edge/base.d.ts +2 -2
- package/lib/stdlib/item/edge/base.js +3 -0
- package/lib/stdlib/item/edge/base.js.map +1 -1
- package/lib/stdlib/item/edge/cubic-horizon.d.ts +37 -0
- package/lib/stdlib/item/edge/cubic-horizon.js +75 -0
- package/lib/stdlib/item/edge/cubic-horizon.js.map +1 -0
- package/lib/stdlib/item/edge/cubic-vertical.d.ts +37 -0
- package/lib/stdlib/item/edge/cubic-vertical.js +75 -0
- package/lib/stdlib/item/edge/cubic-vertical.js.map +1 -0
- package/lib/stdlib/item/edge/cubic.d.ts +60 -0
- package/lib/stdlib/item/edge/cubic.js +103 -0
- package/lib/stdlib/item/edge/cubic.js.map +1 -0
- package/lib/stdlib/item/edge/index.d.ts +1 -0
- package/lib/stdlib/item/edge/index.js +1 -0
- package/lib/stdlib/item/edge/index.js.map +1 -1
- package/lib/stdlib/item/edge/line.d.ts +1 -1
- package/lib/stdlib/item/edge/quadratic.d.ts +41 -0
- package/lib/stdlib/item/edge/quadratic.js +70 -0
- package/lib/stdlib/item/edge/quadratic.js.map +1 -0
- package/lib/stdlib/item/node/base.d.ts +38 -37
- package/lib/stdlib/item/node/base.js +4 -4
- package/lib/stdlib/item/node/base.js.map +1 -1
- package/lib/stdlib/item/node/index.d.ts +1 -0
- package/lib/stdlib/item/node/index.js +1 -0
- package/lib/stdlib/item/node/index.js.map +1 -1
- package/lib/stdlib/item/node/rect.d.ts +31 -0
- package/lib/stdlib/item/node/rect.js +63 -0
- package/lib/stdlib/item/node/rect.js.map +1 -0
- package/lib/stdlib/plugin/fisheye/index.d.ts +102 -0
- package/lib/stdlib/plugin/fisheye/index.js +490 -0
- package/lib/stdlib/plugin/fisheye/index.js.map +1 -0
- package/lib/stdlib/plugin/menu/index.d.ts +42 -0
- package/lib/stdlib/plugin/menu/index.js +242 -0
- package/lib/stdlib/plugin/menu/index.js.map +1 -0
- package/lib/stdlib/plugin/tooltip/index.d.ts +75 -0
- package/lib/stdlib/plugin/tooltip/index.js +383 -0
- package/lib/stdlib/plugin/tooltip/index.js.map +1 -0
- package/lib/stdlib/theme/dark.js +4 -0
- package/lib/stdlib/theme/dark.js.map +1 -1
- package/lib/stdlib/theme/light.js +54 -9
- package/lib/stdlib/theme/light.js.map +1 -1
- package/lib/types/combo.d.ts +52 -3
- package/lib/types/data.d.ts +4 -4
- package/lib/types/edge.d.ts +2 -3
- package/lib/types/event.d.ts +9 -1
- package/lib/types/event.js +10 -10
- package/lib/types/event.js.map +1 -1
- package/lib/types/graph.d.ts +49 -13
- package/lib/types/hook.d.ts +8 -1
- package/lib/types/item.d.ts +4 -4
- package/lib/types/item.js +1 -1
- package/lib/types/item.js.map +1 -1
- package/lib/types/node.d.ts +4 -5
- package/lib/types/theme.d.ts +1 -1
- package/lib/util/animate.js.map +1 -1
- package/lib/util/canvas.js +8 -0
- package/lib/util/canvas.js.map +1 -1
- package/lib/util/data.d.ts +65 -0
- package/lib/util/data.js +161 -0
- package/lib/util/data.js.map +1 -0
- package/lib/util/event.d.ts +8 -0
- package/lib/util/event.js +18 -1
- package/lib/util/event.js.map +1 -1
- package/lib/util/item.d.ts +2 -1
- package/lib/util/item.js +36 -13
- package/lib/util/item.js.map +1 -1
- package/lib/util/shape.d.ts +39 -4
- package/lib/util/shape.js +105 -2
- package/lib/util/shape.js.map +1 -1
- package/lib/util/zoom.d.ts +2 -2
- package/package.json +13 -13
- package/src/item/combo.ts +220 -2
- package/src/item/edge.ts +7 -8
- package/src/item/item.ts +58 -15
- package/src/item/node.ts +47 -24
- package/src/runtime/controller/data.ts +390 -68
- package/src/runtime/controller/interaction.ts +23 -3
- package/src/runtime/controller/item.ts +444 -64
- package/src/runtime/controller/layout.ts +24 -5
- package/src/runtime/graph.ts +225 -38
- package/src/stdlib/behavior/click-select.ts +15 -2
- package/src/stdlib/behavior/collapse-expand-combo.ts +59 -0
- package/src/stdlib/behavior/drag-combo.ts +533 -0
- package/src/stdlib/behavior/drag-node.ts +195 -62
- package/src/stdlib/behavior/hover-activate.ts +4 -5
- package/src/stdlib/behavior/orbit-canvas-3d.ts +1 -1
- package/src/stdlib/behavior/track-canvas-3d.ts +1 -1
- package/src/stdlib/index.ts +25 -3
- package/src/stdlib/item/combo/circle.ts +113 -0
- package/src/stdlib/item/edge/base.ts +5 -2
- package/src/stdlib/item/edge/cubic-horizon.ts +114 -0
- package/src/stdlib/item/edge/cubic-vertical.ts +116 -0
- package/src/stdlib/item/edge/cubic.ts +198 -0
- package/src/stdlib/item/edge/index.ts +1 -0
- package/src/stdlib/item/edge/quadratic.ts +136 -0
- package/src/stdlib/item/node/base.ts +79 -41
- package/src/stdlib/item/node/index.ts +1 -0
- package/src/stdlib/item/node/rect.ts +124 -0
- package/src/stdlib/plugin/fisheye/index.ts +578 -0
- package/src/stdlib/plugin/menu/index.ts +260 -0
- package/src/stdlib/plugin/tooltip/index.ts +424 -0
- package/src/stdlib/theme/dark.ts +4 -0
- package/src/stdlib/theme/light.ts +77 -9
- package/src/types/combo.ts +61 -3
- package/src/types/data.ts +6 -4
- package/src/types/edge.ts +2 -2
- package/src/types/event.ts +8 -8
- package/src/types/graph.ts +73 -16
- package/src/types/hook.ts +8 -1
- package/src/types/item.ts +10 -9
- package/src/types/node.ts +4 -4
- package/src/types/theme.ts +1 -1
- package/src/util/animate.ts +2 -3
- package/src/util/canvas.ts +10 -0
- package/src/util/data.ts +178 -0
- package/src/util/event.ts +29 -0
- package/src/util/item.ts +75 -12
- package/src/util/shape.ts +142 -5
- package/src/util/zoom.ts +2 -2
|
@@ -1,7 +1,19 @@
|
|
|
1
|
-
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
+
t[p] = s[p];
|
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
+
t[p[i]] = s[p[i]];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
12
|
+
import { Graph as GraphLib, GraphView } from '@antv/graphlib';
|
|
2
13
|
import { clone, isArray, isObject, } from '@antv/util';
|
|
3
14
|
import { registery as registry } from '../../stdlib';
|
|
4
15
|
import { getExtension } from '../../util/extension';
|
|
16
|
+
import { deconstructData, graphComboTreeDfs, validateComboStrucutre, } from '../../util/data';
|
|
5
17
|
/**
|
|
6
18
|
* Manages the data transform extensions;
|
|
7
19
|
* Storages user data and inner data.
|
|
@@ -22,12 +34,25 @@ export class DataController {
|
|
|
22
34
|
const ids = conditionIsArray ? condition : [condition];
|
|
23
35
|
switch (type) {
|
|
24
36
|
case 'node':
|
|
25
|
-
return ids.map((id) =>
|
|
37
|
+
return ids.map((id) => {
|
|
38
|
+
if (!graphCore.hasNode(id))
|
|
39
|
+
return undefined;
|
|
40
|
+
const model = graphCore.getNode(id);
|
|
41
|
+
if (model.data._isCombo)
|
|
42
|
+
return undefined;
|
|
43
|
+
return model;
|
|
44
|
+
});
|
|
26
45
|
case 'edge':
|
|
27
46
|
return ids.map((id) => graphCore.hasEdge(id) ? graphCore.getEdge(id) : undefined);
|
|
28
47
|
case 'combo':
|
|
29
|
-
|
|
30
|
-
|
|
48
|
+
return ids.map((id) => {
|
|
49
|
+
if (!graphCore.hasNode(id))
|
|
50
|
+
return undefined;
|
|
51
|
+
const model = graphCore.getNode(id);
|
|
52
|
+
if (!model.data._isCombo)
|
|
53
|
+
return undefined;
|
|
54
|
+
return model;
|
|
55
|
+
});
|
|
31
56
|
}
|
|
32
57
|
}
|
|
33
58
|
else if (conditionType === 'function') {
|
|
@@ -53,16 +78,21 @@ export class DataController {
|
|
|
53
78
|
return [];
|
|
54
79
|
}
|
|
55
80
|
}
|
|
56
|
-
|
|
81
|
+
findRelatedEdges(nodeId, direction = 'both') {
|
|
57
82
|
return this.graphCore.getRelatedEdges(nodeId, direction);
|
|
58
83
|
}
|
|
59
|
-
|
|
84
|
+
findNeighborNodes(nodeId, direction = 'both') {
|
|
60
85
|
if (direction === 'in')
|
|
61
86
|
return this.graphCore.getAncestors(nodeId);
|
|
62
87
|
if (direction === 'out')
|
|
63
88
|
return this.graphCore.getSuccessors(nodeId);
|
|
64
89
|
return this.graphCore.getNeighbors(nodeId);
|
|
65
90
|
}
|
|
91
|
+
findChildren(comboId, treeKey) {
|
|
92
|
+
if (!this.graphCore.hasNode(comboId))
|
|
93
|
+
return;
|
|
94
|
+
return this.graphCore.getChildren(comboId, treeKey);
|
|
95
|
+
}
|
|
66
96
|
/**
|
|
67
97
|
* Subscribe the lifecycle of graph.
|
|
68
98
|
*/
|
|
@@ -96,6 +126,12 @@ export class DataController {
|
|
|
96
126
|
case 'update':
|
|
97
127
|
this.updateData(data);
|
|
98
128
|
break;
|
|
129
|
+
case 'moveCombo':
|
|
130
|
+
this.moveCombo(data);
|
|
131
|
+
break;
|
|
132
|
+
case 'addCombo':
|
|
133
|
+
this.addCombo(data);
|
|
134
|
+
break;
|
|
99
135
|
default:
|
|
100
136
|
// 'replace' | 'mergeReplace' | 'union'
|
|
101
137
|
this.changeData(data, changeType);
|
|
@@ -116,49 +152,98 @@ export class DataController {
|
|
|
116
152
|
* @param changeType type of data change, 'replace' means discard the old data. 'mergeReplace' means merge the common part. 'union' means merge whole sets of old and new one
|
|
117
153
|
*/
|
|
118
154
|
changeData(data, changeType) {
|
|
155
|
+
var _a;
|
|
119
156
|
const { userGraphCore } = this;
|
|
120
157
|
if (changeType === 'replace') {
|
|
121
|
-
this.userGraphCore = new GraphLib(
|
|
158
|
+
this.userGraphCore = new GraphLib({
|
|
159
|
+
nodes: data.nodes.concat(((_a = data.combos) === null || _a === void 0 ? void 0 : _a.map((combo) => ({
|
|
160
|
+
id: combo.id,
|
|
161
|
+
data: Object.assign(Object.assign({}, combo.data), { _isCombo: true }),
|
|
162
|
+
}))) || []),
|
|
163
|
+
edges: data.edges,
|
|
164
|
+
onChanged: (event) => this.updateGraphCore(event),
|
|
165
|
+
});
|
|
122
166
|
const { data: transformedData } = this.transformData();
|
|
123
|
-
|
|
167
|
+
const { nodes = [], edges = [], combos = [] } = transformedData;
|
|
168
|
+
this.graphCore = new GraphLib({
|
|
169
|
+
nodes: nodes.concat((combos === null || combos === void 0 ? void 0 : combos.map((combo) => ({
|
|
170
|
+
id: combo.id,
|
|
171
|
+
data: Object.assign(Object.assign({}, combo.data), { _isCombo: true }),
|
|
172
|
+
}))) || []),
|
|
173
|
+
edges,
|
|
174
|
+
});
|
|
175
|
+
if (combos === null || combos === void 0 ? void 0 : combos.length) {
|
|
176
|
+
this.comboTreeView = new GraphView({
|
|
177
|
+
graph: this.graphCore,
|
|
178
|
+
cache: 'manual',
|
|
179
|
+
});
|
|
180
|
+
this.graphCore.attachTreeStructure('combo');
|
|
181
|
+
nodes.forEach((node) => {
|
|
182
|
+
if (node.data.parentId) {
|
|
183
|
+
if (validateComboStrucutre(this.graph, node.id, node.data.parentId)) {
|
|
184
|
+
this.graphCore.setParent(node.id, node.data.parentId, 'combo');
|
|
185
|
+
}
|
|
186
|
+
else {
|
|
187
|
+
this.graphCore.mergeNodeData(node.id, { parentId: undefined });
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
});
|
|
191
|
+
combos.forEach((combo) => {
|
|
192
|
+
if (combo.data.parentId) {
|
|
193
|
+
if (validateComboStrucutre(this.graph, combo.id, combo.data.parentId)) {
|
|
194
|
+
this.graphCore.setParent(combo.id, combo.data.parentId, 'combo');
|
|
195
|
+
}
|
|
196
|
+
else {
|
|
197
|
+
this.graphCore.mergeNodeData(combo.id, { parentId: undefined });
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
});
|
|
201
|
+
}
|
|
124
202
|
}
|
|
125
203
|
else {
|
|
126
|
-
const
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
204
|
+
const prevData = deconstructData({
|
|
205
|
+
nodes: userGraphCore.getAllNodes(),
|
|
206
|
+
edges: userGraphCore.getAllEdges(),
|
|
207
|
+
});
|
|
208
|
+
const { nodes = [], edges = [], combos = [] } = data;
|
|
209
|
+
const nodesAndCombos = nodes.concat(combos.map((combo) => ({
|
|
210
|
+
id: combo.id,
|
|
211
|
+
data: Object.assign(Object.assign({}, combo.data), { _isCombo: true }),
|
|
212
|
+
})));
|
|
213
|
+
// =========== node & combos ============
|
|
214
|
+
if (!prevData.nodes.length) {
|
|
215
|
+
userGraphCore.addNodes(nodesAndCombos);
|
|
131
216
|
}
|
|
132
217
|
else {
|
|
133
218
|
if (changeType === 'mergeReplace') {
|
|
134
219
|
// remove the nodes which are not in data but in userGraphCore
|
|
135
|
-
const
|
|
136
|
-
|
|
137
|
-
if (!
|
|
220
|
+
const nodeAndComboIds = nodesAndCombos.map((node) => node.id);
|
|
221
|
+
prevData.nodes.forEach((prevNode) => {
|
|
222
|
+
if (!nodeAndComboIds.includes(prevNode.id))
|
|
138
223
|
userGraphCore.removeNode(prevNode.id);
|
|
139
224
|
});
|
|
140
225
|
}
|
|
141
226
|
// add or update node
|
|
142
|
-
|
|
143
|
-
if (userGraphCore.hasNode(
|
|
227
|
+
nodesAndCombos.forEach((item) => {
|
|
228
|
+
if (userGraphCore.hasNode(item.id)) {
|
|
144
229
|
// update node which is in the graphCore
|
|
145
|
-
userGraphCore.mergeNodeData(
|
|
230
|
+
userGraphCore.mergeNodeData(item.id, item.data);
|
|
146
231
|
}
|
|
147
232
|
else {
|
|
148
233
|
// add node which is in data but not in graphCore
|
|
149
|
-
userGraphCore.addNode(
|
|
234
|
+
userGraphCore.addNode(item);
|
|
150
235
|
}
|
|
151
236
|
});
|
|
152
237
|
}
|
|
153
|
-
|
|
154
|
-
if (!
|
|
238
|
+
// =========== edge ============
|
|
239
|
+
if (!prevData.edges.length) {
|
|
155
240
|
userGraphCore.addEdges(edges);
|
|
156
241
|
}
|
|
157
242
|
else {
|
|
158
243
|
if (changeType === 'mergeReplace') {
|
|
159
244
|
// remove the edges which are not in data but in userGraphCore
|
|
160
245
|
const edgeIds = edges.map((edge) => edge.id);
|
|
161
|
-
|
|
246
|
+
prevData.edges.forEach((prevEdge) => {
|
|
162
247
|
if (!edgeIds.includes(prevEdge.id))
|
|
163
248
|
userGraphCore.removeEdge(prevEdge.id);
|
|
164
249
|
});
|
|
@@ -183,19 +268,28 @@ export class DataController {
|
|
|
183
268
|
*/
|
|
184
269
|
removeData(data) {
|
|
185
270
|
const { userGraphCore } = this;
|
|
186
|
-
const { nodes, edges, combos } = data;
|
|
187
|
-
const
|
|
271
|
+
const { nodes = [], edges = [], combos = [] } = data;
|
|
272
|
+
const nodesAndCombos = nodes.concat(combos);
|
|
273
|
+
const prevNodesAndCombos = userGraphCore.getAllNodes();
|
|
188
274
|
const prevEdges = userGraphCore.getAllEdges();
|
|
189
|
-
|
|
190
|
-
|
|
275
|
+
if (prevNodesAndCombos.length && nodesAndCombos.length) {
|
|
276
|
+
// update the parentId
|
|
277
|
+
nodesAndCombos.forEach((item) => {
|
|
278
|
+
const { parentId } = item.data;
|
|
279
|
+
this.graphCore.getChildren(item.id, 'combo').forEach((child) => {
|
|
280
|
+
userGraphCore.mergeNodeData(child.id, { parentId });
|
|
281
|
+
});
|
|
282
|
+
});
|
|
191
283
|
// remove the node
|
|
192
|
-
userGraphCore.removeNodes(
|
|
284
|
+
userGraphCore.removeNodes(nodesAndCombos.map((node) => node.id));
|
|
193
285
|
}
|
|
194
286
|
if (prevEdges.length && edges.length) {
|
|
195
287
|
// add or update edge
|
|
196
|
-
|
|
288
|
+
const ids = edges
|
|
289
|
+
.map((edge) => edge.id)
|
|
290
|
+
.filter((id) => userGraphCore.hasEdge(id));
|
|
291
|
+
userGraphCore.removeEdges(ids);
|
|
197
292
|
}
|
|
198
|
-
// TODO: combo
|
|
199
293
|
}
|
|
200
294
|
/**
|
|
201
295
|
* Update part of old data.
|
|
@@ -203,10 +297,11 @@ export class DataController {
|
|
|
203
297
|
*/
|
|
204
298
|
updateData(data) {
|
|
205
299
|
const { userGraphCore } = this;
|
|
206
|
-
const { nodes, edges, combos } = data;
|
|
207
|
-
const prevNodes =
|
|
208
|
-
|
|
209
|
-
|
|
300
|
+
const { nodes = [], edges = [], combos = [] } = data;
|
|
301
|
+
const { nodes: prevNodes, edges: prevEdges, combos: prevCombos, } = deconstructData({
|
|
302
|
+
nodes: userGraphCore.getAllNodes(),
|
|
303
|
+
edges: userGraphCore.getAllEdges(),
|
|
304
|
+
});
|
|
210
305
|
if (prevNodes.length) {
|
|
211
306
|
// update node
|
|
212
307
|
nodes.forEach((newModel) => {
|
|
@@ -234,7 +329,135 @@ export class DataController {
|
|
|
234
329
|
}
|
|
235
330
|
});
|
|
236
331
|
}
|
|
237
|
-
|
|
332
|
+
if (prevCombos.length) {
|
|
333
|
+
// update combos
|
|
334
|
+
const modelsToMove = [];
|
|
335
|
+
combos.forEach((newModel) => {
|
|
336
|
+
const { id, data } = newModel;
|
|
337
|
+
const { x: comboNewX, y: comboNewY } = data, others = __rest(data, ["x", "y"]);
|
|
338
|
+
if (comboNewX !== undefined || comboNewY !== undefined) {
|
|
339
|
+
if (this.graphCore.getChildren(id, 'combo').length) {
|
|
340
|
+
// combo's position is updated, update the succeed nodes' positions
|
|
341
|
+
const oldBounds = this.graph.getRenderBBox(id, true);
|
|
342
|
+
if (!oldBounds)
|
|
343
|
+
return;
|
|
344
|
+
const [comboOldX, comboOldY] = oldBounds.center;
|
|
345
|
+
const dx = comboNewX - comboOldX;
|
|
346
|
+
const dy = comboNewY - comboOldY;
|
|
347
|
+
graphComboTreeDfs(this.graph, [newModel], (succeed) => {
|
|
348
|
+
const { x, y, _isCombo } = succeed.data;
|
|
349
|
+
if (!_isCombo) {
|
|
350
|
+
modelsToMove.push({
|
|
351
|
+
id: succeed.id,
|
|
352
|
+
data: {
|
|
353
|
+
x: x + dx,
|
|
354
|
+
y: y + dy,
|
|
355
|
+
},
|
|
356
|
+
});
|
|
357
|
+
}
|
|
358
|
+
}, 'BT');
|
|
359
|
+
}
|
|
360
|
+
else {
|
|
361
|
+
// empty combo, modify the position directly
|
|
362
|
+
modelsToMove.push({
|
|
363
|
+
id,
|
|
364
|
+
data: {
|
|
365
|
+
x: comboNewX,
|
|
366
|
+
y: comboNewY,
|
|
367
|
+
},
|
|
368
|
+
});
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
// update other properties
|
|
372
|
+
if (Object.keys(others).length) {
|
|
373
|
+
const mergedData = mergeOneLevelData(userGraphCore.getNode(id), {
|
|
374
|
+
id,
|
|
375
|
+
data: others,
|
|
376
|
+
});
|
|
377
|
+
userGraphCore.mergeNodeData(id, mergedData);
|
|
378
|
+
}
|
|
379
|
+
});
|
|
380
|
+
// update succeed nodes
|
|
381
|
+
modelsToMove.forEach((newModel) => {
|
|
382
|
+
const { id, data } = newModel;
|
|
383
|
+
userGraphCore.mergeNodeData(id, data);
|
|
384
|
+
});
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
/**
|
|
388
|
+
* Relatively move the position of combo a dinstance (dx and dy in combo data).
|
|
389
|
+
* @param data graph data which contains the combo dx dy info
|
|
390
|
+
*/
|
|
391
|
+
moveCombo(data) {
|
|
392
|
+
const { combos = [] } = data;
|
|
393
|
+
const succeedNodesModels = [];
|
|
394
|
+
combos.forEach((newModel) => {
|
|
395
|
+
const { dx = 0, dy = 0 } = newModel.data;
|
|
396
|
+
if (!dx && !dy)
|
|
397
|
+
return;
|
|
398
|
+
if (this.graphCore.getChildren(newModel.id, 'combo').length) {
|
|
399
|
+
// combo's position is updated, update the succeed nodes' positions
|
|
400
|
+
graphComboTreeDfs(this.graph, [newModel], (succeed) => {
|
|
401
|
+
const { x, y, _isCombo } = succeed.data;
|
|
402
|
+
if (!_isCombo ||
|
|
403
|
+
!this.graphCore.getChildren(succeed.id, 'combo').length) {
|
|
404
|
+
succeedNodesModels.push({
|
|
405
|
+
id: succeed.id,
|
|
406
|
+
data: {
|
|
407
|
+
x: x + dx,
|
|
408
|
+
y: y + dy,
|
|
409
|
+
},
|
|
410
|
+
});
|
|
411
|
+
}
|
|
412
|
+
}, 'BT');
|
|
413
|
+
}
|
|
414
|
+
else {
|
|
415
|
+
// empty combo, move it directly
|
|
416
|
+
const comboModel = this.graphCore.getNode(newModel.id);
|
|
417
|
+
const { x = 0, y = 0 } = comboModel.data;
|
|
418
|
+
succeedNodesModels.push({
|
|
419
|
+
id: newModel.id,
|
|
420
|
+
data: {
|
|
421
|
+
x: x + dx,
|
|
422
|
+
y: y + dy,
|
|
423
|
+
},
|
|
424
|
+
});
|
|
425
|
+
}
|
|
426
|
+
});
|
|
427
|
+
// update succeed nodes
|
|
428
|
+
const { userGraphCore } = this;
|
|
429
|
+
succeedNodesModels.forEach((newModel) => {
|
|
430
|
+
const { id, data } = newModel;
|
|
431
|
+
if (data) {
|
|
432
|
+
const mergedData = mergeOneLevelData(userGraphCore.getNode(id), newModel);
|
|
433
|
+
userGraphCore.mergeNodeData(id, mergedData);
|
|
434
|
+
}
|
|
435
|
+
});
|
|
436
|
+
}
|
|
437
|
+
addCombo(data) {
|
|
438
|
+
const { combos = [] } = data;
|
|
439
|
+
if (!(combos === null || combos === void 0 ? void 0 : combos.length))
|
|
440
|
+
return;
|
|
441
|
+
const { userGraphCore } = this;
|
|
442
|
+
const { id, data: comboData } = combos[0];
|
|
443
|
+
const { _children = [] } = comboData, others = __rest(comboData, ["_children"]);
|
|
444
|
+
// add or update combo
|
|
445
|
+
if (userGraphCore.hasNode(id)) {
|
|
446
|
+
// update node which is in the graphCore
|
|
447
|
+
userGraphCore.mergeNodeData(id, Object.assign(Object.assign({}, others), { _isCombo: true }));
|
|
448
|
+
}
|
|
449
|
+
else {
|
|
450
|
+
// add node which is in data but not in graphCore
|
|
451
|
+
userGraphCore.addNode({ id, data: Object.assign(Object.assign({}, others), { _isCombo: true }) });
|
|
452
|
+
}
|
|
453
|
+
// update strucutre
|
|
454
|
+
_children.forEach((childId) => {
|
|
455
|
+
if (!this.graphCore.hasNode(childId)) {
|
|
456
|
+
console.warn(`Adding child ${childId} to combo ${id} failed. The child ${childId} does not exist`);
|
|
457
|
+
return;
|
|
458
|
+
}
|
|
459
|
+
userGraphCore.mergeNodeData(childId, { parentId: id });
|
|
460
|
+
});
|
|
238
461
|
}
|
|
239
462
|
/**
|
|
240
463
|
* Update graphCore with transformed userGraphCore data.
|
|
@@ -244,11 +467,11 @@ export class DataController {
|
|
|
244
467
|
// === step 1: clone data from userGraphCore (userData) ===
|
|
245
468
|
// === step 2: transform the data with transform extensions, output innerData and idMaps ===
|
|
246
469
|
const { data: transformedData, idMaps } = this.transformData();
|
|
247
|
-
const { nodes, edges, combos } = transformedData;
|
|
248
|
-
const
|
|
470
|
+
const { nodes = [], edges = [], combos = [] } = transformedData;
|
|
471
|
+
const prevNodesAndCombos = graphCore.getAllNodes();
|
|
249
472
|
// function to update one data in graphCore with different model type ('node' or 'edge')
|
|
250
|
-
const syncUpdateToGraphCore = (id, newValue, oldValue,
|
|
251
|
-
if (
|
|
473
|
+
const syncUpdateToGraphCore = (id, newValue, oldValue, isNodeOrCombo, diff = []) => {
|
|
474
|
+
if (isNodeOrCombo) {
|
|
252
475
|
if (newValue.data)
|
|
253
476
|
graphCore.updateNodeData(id, newValue.data);
|
|
254
477
|
}
|
|
@@ -261,26 +484,69 @@ export class DataController {
|
|
|
261
484
|
if (diff.includes('target'))
|
|
262
485
|
graphCore.updateEdgeTarget(id, newValue.target);
|
|
263
486
|
}
|
|
264
|
-
// TODO: combo
|
|
265
487
|
};
|
|
266
488
|
graphCore.batch(() => {
|
|
489
|
+
var _a;
|
|
267
490
|
// === step 3: sync to graphCore according to the changes in userGraphCore ==
|
|
268
491
|
if (!(idMaps === null || idMaps === void 0 ? void 0 : idMaps.length) || idMaps.length !== this.extensions.length) {
|
|
269
492
|
// situation 1: not every extension has corresponding idMap, use default mapping: suppose id is not changed by transforms
|
|
270
493
|
// and diff the value in graphCore whose id is not in userGraphCore
|
|
271
494
|
const newModelMap = {};
|
|
272
|
-
|
|
495
|
+
const parentMap = {};
|
|
496
|
+
const changeMap = {};
|
|
497
|
+
event.changes.forEach((change) => {
|
|
498
|
+
const { value, id } = change;
|
|
499
|
+
changeMap[id || value.id] = true;
|
|
500
|
+
});
|
|
501
|
+
nodes.forEach((model) => {
|
|
502
|
+
newModelMap[model.id] = { type: 'node', model };
|
|
503
|
+
if (model.data.hasOwnProperty('parentId')) {
|
|
504
|
+
parentMap[model.id] = {
|
|
505
|
+
new: model.data.parentId,
|
|
506
|
+
old: undefined,
|
|
507
|
+
};
|
|
508
|
+
}
|
|
509
|
+
});
|
|
273
510
|
edges.forEach((model) => (newModelMap[model.id] = { type: 'edge', model }));
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
511
|
+
combos.forEach((model) => {
|
|
512
|
+
newModelMap[model.id] = { type: 'combo', model };
|
|
513
|
+
if (model.data.hasOwnProperty('parentId')) {
|
|
514
|
+
parentMap[model.id] = {
|
|
515
|
+
new: model.data.parentId,
|
|
516
|
+
old: undefined,
|
|
517
|
+
};
|
|
518
|
+
}
|
|
519
|
+
});
|
|
520
|
+
prevNodesAndCombos.forEach((prevModel) => {
|
|
521
|
+
var _a, _b, _c;
|
|
522
|
+
const { id } = prevModel;
|
|
523
|
+
if (((_a = parentMap[id]) === null || _a === void 0 ? void 0 : _a.new) !== undefined ||
|
|
524
|
+
prevModel.data.parentId !== undefined) {
|
|
525
|
+
parentMap[id] = {
|
|
526
|
+
new: (_b = parentMap[id]) === null || _b === void 0 ? void 0 : _b.new,
|
|
527
|
+
old: prevModel.data.parentId,
|
|
528
|
+
};
|
|
529
|
+
}
|
|
530
|
+
else {
|
|
531
|
+
delete parentMap[id];
|
|
532
|
+
}
|
|
277
533
|
const { model: newModel } = newModelMap[id] || {};
|
|
278
534
|
// remove
|
|
279
|
-
if (!newModel)
|
|
535
|
+
if (!newModel) {
|
|
536
|
+
if (prevModel.data._isCombo) {
|
|
537
|
+
graphCore.getChildren(id, 'combo').forEach((child) => {
|
|
538
|
+
parentMap[child.id] = Object.assign(Object.assign({}, parentMap[child.id]), { new: prevModel.data.parentId });
|
|
539
|
+
});
|
|
540
|
+
}
|
|
541
|
+
if (prevModel.data.parentId) {
|
|
542
|
+
graphCore.setParent(id, undefined, 'combo');
|
|
543
|
+
}
|
|
280
544
|
graphCore.removeNode(id);
|
|
545
|
+
delete parentMap[prevModel.id];
|
|
546
|
+
}
|
|
281
547
|
// update
|
|
282
|
-
else if ((
|
|
283
|
-
syncUpdateToGraphCore(id, newModel,
|
|
548
|
+
else if (((_c = diffAt(newModel, prevModel, true)) === null || _c === void 0 ? void 0 : _c.length) || changeMap[id])
|
|
549
|
+
syncUpdateToGraphCore(id, newModel, prevModel, true);
|
|
284
550
|
// delete from the map indicates this model is visited
|
|
285
551
|
delete newModelMap[id];
|
|
286
552
|
});
|
|
@@ -301,11 +567,21 @@ export class DataController {
|
|
|
301
567
|
});
|
|
302
568
|
// add
|
|
303
569
|
Object.values(newModelMap).forEach(({ type, model }) => {
|
|
304
|
-
if (type === 'node')
|
|
570
|
+
if (type === 'node' || type === 'combo')
|
|
305
571
|
graphCore.addNode(model);
|
|
306
572
|
else if (type === 'edge')
|
|
307
573
|
graphCore.addEdge(model);
|
|
308
|
-
|
|
574
|
+
});
|
|
575
|
+
// update parents after adding all items
|
|
576
|
+
Object.keys(parentMap).forEach((id) => {
|
|
577
|
+
if (parentMap[id].new === parentMap[id].old)
|
|
578
|
+
return;
|
|
579
|
+
if (!validateComboStrucutre(this.graph, id, parentMap[id].new)) {
|
|
580
|
+
graphCore.mergeNodeData(id, { parentId: parentMap[id].old });
|
|
581
|
+
return;
|
|
582
|
+
}
|
|
583
|
+
graphCore.mergeNodeData(id, { parentId: parentMap[id].new });
|
|
584
|
+
graphCore.setParent(id, parentMap[id].new, 'combo');
|
|
309
585
|
});
|
|
310
586
|
}
|
|
311
587
|
else {
|
|
@@ -314,14 +590,16 @@ export class DataController {
|
|
|
314
590
|
const finalIdMap = {};
|
|
315
591
|
const newModelMap = {};
|
|
316
592
|
const prevModelMap = {};
|
|
317
|
-
nodes
|
|
593
|
+
nodes
|
|
594
|
+
.concat(edges)
|
|
595
|
+
.concat(combos)
|
|
596
|
+
.forEach((model) => {
|
|
318
597
|
finalIdMap[model.id] = getComesFromLinkedList(model.id, idMaps);
|
|
319
598
|
newModelMap[model.id] = model;
|
|
320
599
|
});
|
|
321
|
-
|
|
600
|
+
prevNodesAndCombos.concat(graphCore.getAllEdges()).forEach((model) => {
|
|
322
601
|
prevModelMap[model.id] = model;
|
|
323
602
|
});
|
|
324
|
-
// TODO: combo
|
|
325
603
|
// map changes for search
|
|
326
604
|
const changeMap = {};
|
|
327
605
|
const { changes } = event;
|
|
@@ -345,13 +623,15 @@ export class DataController {
|
|
|
345
623
|
const comesFromIds = finalIdMap[newId];
|
|
346
624
|
const newValue = newModelMap[newId];
|
|
347
625
|
const oldValue = prevModelMap[newId];
|
|
348
|
-
const
|
|
626
|
+
const isNodeOrCombo = graphCore.hasNode(newId);
|
|
349
627
|
if (newValue && !oldValue) {
|
|
350
|
-
const addFunc =
|
|
628
|
+
const addFunc = isNodeOrCombo
|
|
629
|
+
? graphCore.addNode
|
|
630
|
+
: graphCore.addEdge;
|
|
351
631
|
addFunc(newValue);
|
|
352
632
|
}
|
|
353
633
|
else if (!newValue && oldValue) {
|
|
354
|
-
const removeFunc =
|
|
634
|
+
const removeFunc = isNodeOrCombo
|
|
355
635
|
? graphCore.removeNode
|
|
356
636
|
: graphCore.removeEdge;
|
|
357
637
|
removeFunc(newId);
|
|
@@ -359,19 +639,31 @@ export class DataController {
|
|
|
359
639
|
else {
|
|
360
640
|
if (!(comesFromIds === null || comesFromIds === void 0 ? void 0 : comesFromIds.length)) {
|
|
361
641
|
// no comesForm, find same id in userGraphCore to follow the change, if it not found, diff new and old data value of graphCore (inner data)
|
|
362
|
-
const diff = diffAt(newValue, oldValue,
|
|
642
|
+
const diff = diffAt(newValue, oldValue, isNodeOrCombo);
|
|
363
643
|
if (diff === null || diff === void 0 ? void 0 : diff.length)
|
|
364
|
-
syncUpdateToGraphCore(newId, newValue, oldValue,
|
|
644
|
+
syncUpdateToGraphCore(newId, newValue, oldValue, isNodeOrCombo, diff);
|
|
365
645
|
}
|
|
366
646
|
else {
|
|
367
647
|
// follow the corresponding data event in userGraphCore
|
|
368
648
|
const comesFromChanges = changeMap[comesFromIds[0]];
|
|
369
649
|
if (comesFromChanges === null || comesFromChanges === void 0 ? void 0 : comesFromChanges.length)
|
|
370
|
-
syncUpdateToGraphCore(newId, newValue, oldValue,
|
|
650
|
+
syncUpdateToGraphCore(newId, newValue, oldValue, isNodeOrCombo);
|
|
371
651
|
}
|
|
372
652
|
}
|
|
373
653
|
});
|
|
654
|
+
// update parents after updating all items
|
|
655
|
+
graphCore.getAllNodes().forEach((node) => {
|
|
656
|
+
if (!validateComboStrucutre(this.graph, node.id, node.data.parentId)) {
|
|
657
|
+
// restore if the new parent is invalid
|
|
658
|
+
graphCore.mergeNodeData(node.id, {
|
|
659
|
+
parentId: prevModelMap[node.id].data.parentId,
|
|
660
|
+
});
|
|
661
|
+
return;
|
|
662
|
+
}
|
|
663
|
+
graphCore.setParent(node.id, node.data.parentId, 'combo');
|
|
664
|
+
});
|
|
374
665
|
}
|
|
666
|
+
(_a = this.comboTreeView) === null || _a === void 0 ? void 0 : _a.refreshCache();
|
|
375
667
|
});
|
|
376
668
|
}
|
|
377
669
|
/**
|
|
@@ -381,12 +673,10 @@ export class DataController {
|
|
|
381
673
|
transformData() {
|
|
382
674
|
const { userGraphCore } = this;
|
|
383
675
|
// === step 1: clone data from userGraphCore (userData) ===
|
|
384
|
-
const userData = {
|
|
385
|
-
// TODO: should be deepClone
|
|
676
|
+
const userData = deconstructData({
|
|
386
677
|
nodes: userGraphCore.getAllNodes(),
|
|
387
678
|
edges: userGraphCore.getAllEdges(),
|
|
388
|
-
|
|
389
|
-
};
|
|
679
|
+
});
|
|
390
680
|
let dataCloned = clone(userData);
|
|
391
681
|
// === step 2: transform the data with transform extensions, output innerData and idMaps ===
|
|
392
682
|
const idMaps = [];
|
|
@@ -457,6 +747,8 @@ const diffAt = (newModel, oldModel, isNode) => {
|
|
|
457
747
|
else
|
|
458
748
|
continue;
|
|
459
749
|
}
|
|
750
|
+
if (isNaN(newValue) && isNaN(oldValue))
|
|
751
|
+
continue;
|
|
460
752
|
if (newValue !== oldValue)
|
|
461
753
|
return diff.concat('data');
|
|
462
754
|
}
|