@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
|
@@ -804,7 +804,11 @@ export abstract class BaseNode {
|
|
|
804
804
|
* @param shapeMap The shape map that contains all of the elements to show on the node.
|
|
805
805
|
* @param zoom The zoom level of the graph.
|
|
806
806
|
*/
|
|
807
|
-
public onZoom = (
|
|
807
|
+
public onZoom = (
|
|
808
|
+
shapeMap: NodeShapeMap | ComboShapeMap,
|
|
809
|
+
zoom: number,
|
|
810
|
+
cacheHiddenShape = {},
|
|
811
|
+
) => {
|
|
808
812
|
// zoomLevel changed
|
|
809
813
|
if (this.lodStrategy) {
|
|
810
814
|
const { levels } = this.lodStrategy;
|
|
@@ -825,7 +829,7 @@ export abstract class BaseNode {
|
|
|
825
829
|
// zoomLevel changed, from higher to lower, hide something
|
|
826
830
|
for (let i = currentLevel + 1; i <= maxLevel; i++) {
|
|
827
831
|
levelShapes[String(i)]?.forEach((id) => {
|
|
828
|
-
if (!shapeMap[id]) return;
|
|
832
|
+
if (!shapeMap[id] || cacheHiddenShape[id]) return;
|
|
829
833
|
shapeMap[id].hide();
|
|
830
834
|
hiddenShape[id] = true;
|
|
831
835
|
});
|
|
@@ -874,8 +878,7 @@ export abstract class BaseNode {
|
|
|
874
878
|
const balanceRatio = 1 / zoom || 1;
|
|
875
879
|
this.zoomCache.balanceRatio = balanceRatio;
|
|
876
880
|
if (!labelShape || !labelShape.isVisible()) return;
|
|
877
|
-
const {
|
|
878
|
-
const { position = 'bottom' } = labelStyle;
|
|
881
|
+
const { position = 'bottom' } = this.mergedStyles.labelShape;
|
|
879
882
|
|
|
880
883
|
const keyShapeLocal = keyShape.getLocalBounds();
|
|
881
884
|
if (zoom < 1) {
|
|
@@ -917,21 +920,20 @@ export abstract class BaseNode {
|
|
|
917
920
|
const scaleTransform = `scale(${balanceRatio}, ${balanceRatio})`;
|
|
918
921
|
labelShape.style.transform = `${oriTransform} ${scaleTransform}`;
|
|
919
922
|
this.scaleTransformCache = scaleTransform;
|
|
920
|
-
|
|
921
|
-
labelShape.style.wordWrapWidth = wordWrapWidth;
|
|
923
|
+
labelShape.style.wordWrapWidth = this.zoomCache.wordWrapWidth * zoom;
|
|
922
924
|
|
|
923
925
|
if (!labelBackgroundShape || !labelBackgroundShape.isVisible()) return;
|
|
924
926
|
|
|
925
|
-
const
|
|
927
|
+
const [paddingTop, paddingRight, paddingBottom, paddingLeft] = this
|
|
928
|
+
.mergedStyles.labelBackgroundShape.padding as number[];
|
|
929
|
+
const sidePadding = paddingRight + paddingLeft;
|
|
926
930
|
const { width, height, x, y } = labelBackgroundShape.attributes;
|
|
927
|
-
const [paddingTop, paddingRight, paddingBottom, paddingLeft] =
|
|
928
|
-
padding as number[];
|
|
929
931
|
|
|
930
932
|
switch (position) {
|
|
931
933
|
case 'top':
|
|
932
934
|
// if it is zoom-out, do not scale the gap between keyShape and labelShape, differentiate from zoom-in by adjusting transformOrigin
|
|
933
935
|
labelBackgroundShape.style.transformOrigin = `${
|
|
934
|
-
paddingLeft + (width -
|
|
936
|
+
paddingLeft + (width - sidePadding) / 2
|
|
935
937
|
} ${zoom < 1 ? height - paddingBottom : keyShapeLocal.min[1] - y}`;
|
|
936
938
|
break;
|
|
937
939
|
case 'left':
|
|
@@ -946,7 +948,7 @@ export abstract class BaseNode {
|
|
|
946
948
|
break;
|
|
947
949
|
case 'bottom':
|
|
948
950
|
labelBackgroundShape.style.transformOrigin = `${
|
|
949
|
-
paddingLeft + (width -
|
|
951
|
+
paddingLeft + (width - sidePadding) / 2
|
|
950
952
|
} ${
|
|
951
953
|
zoom < 1
|
|
952
954
|
? paddingTop + (height - paddingTop - paddingBottom) / 2
|
|
@@ -956,14 +958,13 @@ export abstract class BaseNode {
|
|
|
956
958
|
default:
|
|
957
959
|
// center
|
|
958
960
|
labelBackgroundShape.style.transformOrigin = `${
|
|
959
|
-
paddingLeft + (width -
|
|
961
|
+
paddingLeft + (width - sidePadding) / 2
|
|
960
962
|
} ${paddingTop + (height - paddingTop - paddingBottom) / 2}`;
|
|
961
963
|
}
|
|
962
964
|
|
|
963
965
|
const { labelShapeGeometry: labelBBox } = this.boundsCache;
|
|
964
966
|
const labelWidth = labelBBox.max[0] - labelBBox.min[0];
|
|
965
|
-
const xAxistRatio =
|
|
966
|
-
(labelWidth * balanceRatio + paddingLeft + paddingRight) / width;
|
|
967
|
+
const xAxistRatio = (labelWidth * balanceRatio + sidePadding) / width;
|
|
967
968
|
|
|
968
969
|
labelBackgroundShape.style.transform = `scale(${xAxistRatio}, ${balanceRatio})`;
|
|
969
970
|
}
|
|
@@ -7,9 +7,9 @@ import {
|
|
|
7
7
|
NodeShapeStyles,
|
|
8
8
|
} from '../../../types/node';
|
|
9
9
|
import { convertToNumber } from '../../../util/type';
|
|
10
|
-
import { BaseNode } from './base';
|
|
11
10
|
import { ComboModelData, ComboShapeMap } from '../../../types/combo';
|
|
12
11
|
import { ShapeTagMap } from '../../../util/shape';
|
|
12
|
+
import { BaseNode } from './base';
|
|
13
13
|
|
|
14
14
|
export class ImageNode extends BaseNode {
|
|
15
15
|
override defaultStyles = {
|
|
@@ -11,7 +11,7 @@ export class ComboCommand implements Command {
|
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
undo(graph: IGraph) {
|
|
14
|
-
graph.
|
|
14
|
+
graph.executeWithNoStack(() => {
|
|
15
15
|
this.action === 'expandCombo'
|
|
16
16
|
? graph.collapseCombo(this.ids)
|
|
17
17
|
: graph.expandCombo(this.ids);
|
|
@@ -19,7 +19,7 @@ export class ComboCommand implements Command {
|
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
redo(graph: IGraph) {
|
|
22
|
-
graph.
|
|
22
|
+
graph.executeWithNoStack(() => {
|
|
23
23
|
this.action === 'collapseCombo'
|
|
24
24
|
? graph.collapseCombo(this.ids)
|
|
25
25
|
: graph.expandCombo(this.ids);
|
|
@@ -200,7 +200,7 @@ export class History extends Base {
|
|
|
200
200
|
/**
|
|
201
201
|
* Pause stacking operations.
|
|
202
202
|
*/
|
|
203
|
-
|
|
203
|
+
pauseStack(): void {
|
|
204
204
|
this.withoutStackingCounter++;
|
|
205
205
|
|
|
206
206
|
if (this.withoutStackingCounter === 1) {
|
|
@@ -212,7 +212,7 @@ export class History extends Base {
|
|
|
212
212
|
/**
|
|
213
213
|
* Resume stacking operations.
|
|
214
214
|
*/
|
|
215
|
-
|
|
215
|
+
resumeStack(): void {
|
|
216
216
|
if (this.withoutStackingCounter > 0) {
|
|
217
217
|
this.withoutStackingCounter--;
|
|
218
218
|
}
|
|
@@ -260,14 +260,14 @@ export class History extends Base {
|
|
|
260
260
|
}
|
|
261
261
|
|
|
262
262
|
/**
|
|
263
|
-
* Begin a
|
|
264
|
-
* Any operations performed between `
|
|
263
|
+
* Begin a historyBatch operation.
|
|
264
|
+
* Any operations performed between `startHistoryBatch` and `stopHistoryBatch` are grouped together.
|
|
265
265
|
* treated as a single operation when undoing or redoing.
|
|
266
266
|
*/
|
|
267
|
-
public
|
|
267
|
+
public startHistoryBatch() {
|
|
268
268
|
if (this.isBatching) {
|
|
269
269
|
throw new Error(
|
|
270
|
-
'Ensure that
|
|
270
|
+
'Ensure that historyBatch processing is stopped before starting.',
|
|
271
271
|
);
|
|
272
272
|
}
|
|
273
273
|
this.initBatchCommands();
|
|
@@ -275,14 +275,14 @@ export class History extends Base {
|
|
|
275
275
|
}
|
|
276
276
|
|
|
277
277
|
/**
|
|
278
|
-
* End a
|
|
279
|
-
* Any operations performed between `
|
|
278
|
+
* End a historyBatch operation.
|
|
279
|
+
* Any operations performed between `startHistoryBatch` and `stopHistoryBatch` are grouped together.
|
|
280
280
|
* treated as a single operation when undoing or redoing.
|
|
281
281
|
*/
|
|
282
|
-
public
|
|
282
|
+
public stopHistoryBatch() {
|
|
283
283
|
if (!this.isBatching) {
|
|
284
284
|
throw new Error(
|
|
285
|
-
'Ensure that
|
|
285
|
+
'Ensure that historyBatch processing is started before stopping.',
|
|
286
286
|
);
|
|
287
287
|
}
|
|
288
288
|
this.push(this.batchCommands);
|
|
@@ -290,13 +290,13 @@ export class History extends Base {
|
|
|
290
290
|
}
|
|
291
291
|
|
|
292
292
|
/**
|
|
293
|
-
* Execute the provided function in a
|
|
293
|
+
* Execute the provided function in a historyBatch mode
|
|
294
294
|
* @param callback
|
|
295
295
|
*/
|
|
296
|
-
public
|
|
297
|
-
this.
|
|
296
|
+
public historyBatch(callback) {
|
|
297
|
+
this.startHistoryBatch();
|
|
298
298
|
callback();
|
|
299
|
-
this.
|
|
299
|
+
this.stopHistoryBatch();
|
|
300
300
|
}
|
|
301
301
|
|
|
302
302
|
public getEvents() {
|
|
@@ -26,14 +26,14 @@ export class ItemDataCommand implements Command {
|
|
|
26
26
|
|
|
27
27
|
private removeChangedData(graph) {
|
|
28
28
|
const ids = this.changes.map((data) => data.value?.id).filter(Boolean);
|
|
29
|
-
graph.
|
|
29
|
+
graph.executeWithNoStack(() => {
|
|
30
30
|
graph.removeData(this.type, ids);
|
|
31
31
|
});
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
private addChangedData(graph) {
|
|
35
35
|
const models = this.changes.map((data) => data.value).filter(Boolean);
|
|
36
|
-
graph.
|
|
36
|
+
graph.executeWithNoStack(() => {
|
|
37
37
|
graph.addData(this.type, models);
|
|
38
38
|
});
|
|
39
39
|
}
|
|
@@ -61,13 +61,13 @@ export class ItemDataCommand implements Command {
|
|
|
61
61
|
});
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
-
graph.
|
|
64
|
+
graph.pauseStack();
|
|
65
65
|
if (onlyMove) {
|
|
66
66
|
graph.updatePosition(this.type, models, this.upsertAncestors);
|
|
67
67
|
} else {
|
|
68
68
|
graph.updateData(this.type, models);
|
|
69
69
|
}
|
|
70
|
-
graph.
|
|
70
|
+
graph.resumeStack();
|
|
71
71
|
}
|
|
72
72
|
|
|
73
73
|
undo(graph: IGraph) {
|
|
@@ -11,7 +11,7 @@ export class LayerUpdatedCommand implements Command {
|
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
undo(graph: IGraph) {
|
|
14
|
-
graph.
|
|
14
|
+
graph.executeWithNoStack(() => {
|
|
15
15
|
this.action === 'front'
|
|
16
16
|
? graph.backItem(this.ids)
|
|
17
17
|
: graph.frontItem(this.ids);
|
|
@@ -19,7 +19,7 @@ export class LayerUpdatedCommand implements Command {
|
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
redo(graph: IGraph) {
|
|
22
|
-
graph.
|
|
22
|
+
graph.executeWithNoStack(() => {
|
|
23
23
|
this.action === 'front'
|
|
24
24
|
? graph.frontItem(this.ids)
|
|
25
25
|
: graph.backItem(this.ids);
|
|
@@ -20,7 +20,7 @@ export class StateUpdatedCommand implements Command {
|
|
|
20
20
|
private updateItemsStates(graph, stateOptions) {
|
|
21
21
|
stateOptions?.map((option) => {
|
|
22
22
|
const { ids, states, value } = option;
|
|
23
|
-
graph.
|
|
23
|
+
graph.executeWithNoStack(() => {
|
|
24
24
|
graph.setItemState(ids, states, value);
|
|
25
25
|
});
|
|
26
26
|
});
|
|
@@ -20,13 +20,13 @@ export class VisibilityUpdatedCommand implements Command {
|
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
private toggleItemsVisible(graph: IGraph, values) {
|
|
23
|
-
graph.
|
|
23
|
+
graph.pauseStack();
|
|
24
24
|
each(values, (value) =>
|
|
25
25
|
value.visible
|
|
26
26
|
? graph.showItem(value.ids, this.disableAnimate)
|
|
27
27
|
: graph.hideItem(value.ids, this.disableAnimate),
|
|
28
28
|
);
|
|
29
|
-
graph.
|
|
29
|
+
graph.resumeStack();
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
undo(graph: IGraph) {
|
|
@@ -51,7 +51,8 @@ interface HullComponentFullOptions extends HullComponentOptions {
|
|
|
51
51
|
export default class Hull {
|
|
52
52
|
graph: IGraph;
|
|
53
53
|
|
|
54
|
-
|
|
54
|
+
// TODO: PathArray is not exported by @antv/util 2.x but by 3.x. Correct the type String | PathArray after upgrading @antv/util
|
|
55
|
+
path: any;
|
|
55
56
|
|
|
56
57
|
members: (NodeModel | ComboModel)[];
|
|
57
58
|
|
|
@@ -172,9 +173,9 @@ export default class Hull {
|
|
|
172
173
|
const shape = this.graph.drawTransient('path', this.options.id, {
|
|
173
174
|
style: {
|
|
174
175
|
path: this.path,
|
|
176
|
+
pointerEvents: 'none',
|
|
175
177
|
...this.options.style,
|
|
176
178
|
},
|
|
177
|
-
capture: false,
|
|
178
179
|
});
|
|
179
180
|
const { labelShape } = this.options;
|
|
180
181
|
if (labelShape?.text) {
|
|
@@ -183,10 +184,10 @@ export default class Hull {
|
|
|
183
184
|
const formattedLabelStyle = this.getLabelStyle(labelShape, shapeBounds);
|
|
184
185
|
this.graph.drawTransient('text', `${this.options.id}-label`, {
|
|
185
186
|
style: {
|
|
187
|
+
pointerEvents: 'none',
|
|
186
188
|
...labelShapeStyle,
|
|
187
189
|
...formattedLabelStyle,
|
|
188
190
|
},
|
|
189
|
-
capture: false,
|
|
190
191
|
});
|
|
191
192
|
}
|
|
192
193
|
shape.toBack();
|
|
@@ -426,8 +427,10 @@ export default class Hull {
|
|
|
426
427
|
|
|
427
428
|
public updateStyle(style: ShapeStyle) {
|
|
428
429
|
this.graph.drawTransient('path', this.options.id, {
|
|
429
|
-
style
|
|
430
|
-
|
|
430
|
+
style: {
|
|
431
|
+
...style,
|
|
432
|
+
pointerEvents: 'none',
|
|
433
|
+
},
|
|
431
434
|
});
|
|
432
435
|
}
|
|
433
436
|
|
|
@@ -54,6 +54,8 @@ export class Minimap extends Base {
|
|
|
54
54
|
private dx: number;
|
|
55
55
|
/** Distance from left of minimap graph to the left of minimap container. */
|
|
56
56
|
private dy: number;
|
|
57
|
+
/** Cache the visibility while items' visibility changed. And apply them onto the minimap with debounce. */
|
|
58
|
+
private visibleCache: { [id: string]: boolean } = {};
|
|
57
59
|
|
|
58
60
|
constructor(options?: MiniMapConfig) {
|
|
59
61
|
super(options);
|
|
@@ -80,11 +82,11 @@ export class Minimap extends Base {
|
|
|
80
82
|
|
|
81
83
|
public getEvents() {
|
|
82
84
|
return {
|
|
83
|
-
afterupdateitem: this.handleUpdateCanvas,
|
|
84
85
|
afteritemstatechange: this.handleUpdateCanvas,
|
|
85
86
|
afterlayout: this.handleUpdateCanvas,
|
|
86
87
|
viewportchange: this.handleUpdateCanvas,
|
|
87
88
|
afteritemchange: this.handleUpdateCanvas,
|
|
89
|
+
afteritemvisibilitychange: this.handleVisibilityChange,
|
|
88
90
|
};
|
|
89
91
|
}
|
|
90
92
|
|
|
@@ -115,12 +117,12 @@ export class Minimap extends Base {
|
|
|
115
117
|
style='position:absolute;
|
|
116
118
|
left:0;
|
|
117
119
|
top:0;
|
|
118
|
-
box-sizing:border-box;
|
|
119
120
|
border: 2px solid #1980ff;
|
|
121
|
+
box-sizing:border-box;
|
|
120
122
|
background: rgba(0, 0, 255, 0.1);
|
|
121
123
|
cursor:move'
|
|
122
124
|
draggable=${isSafari || isFireFox ? false : true}
|
|
123
|
-
|
|
125
|
+
/>`);
|
|
124
126
|
|
|
125
127
|
// Last mouse x position
|
|
126
128
|
let x = 0;
|
|
@@ -128,11 +130,25 @@ export class Minimap extends Base {
|
|
|
128
130
|
let y = 0;
|
|
129
131
|
// Whether in dragging status
|
|
130
132
|
let dragging = false;
|
|
133
|
+
let resizing = false;
|
|
131
134
|
|
|
132
135
|
const dragstartevent = isSafari || isFireFox ? 'mousedown' : 'dragstart';
|
|
136
|
+
this.container.addEventListener('mousemove', (e) => {
|
|
137
|
+
const moveAtBorder = getMoveAtBorder(viewport, e);
|
|
138
|
+
if (moveAtBorder) {
|
|
139
|
+
this.container.style.cursor = cursorMap[moveAtBorder];
|
|
140
|
+
viewport.style.cursor = cursorMap[moveAtBorder];
|
|
141
|
+
} else {
|
|
142
|
+
this.container.style.cursor = 'unset';
|
|
143
|
+
viewport.style.cursor = 'move';
|
|
144
|
+
}
|
|
145
|
+
});
|
|
133
146
|
viewport.addEventListener(
|
|
134
147
|
dragstartevent,
|
|
135
148
|
((e: IG6GraphEvent) => {
|
|
149
|
+
resizing = getMoveAtBorder(viewport, e);
|
|
150
|
+
if (resizing) return;
|
|
151
|
+
|
|
136
152
|
if ((e as any).dataTransfer) {
|
|
137
153
|
const img = new Image();
|
|
138
154
|
img.src =
|
|
@@ -159,6 +175,30 @@ export class Minimap extends Base {
|
|
|
159
175
|
);
|
|
160
176
|
|
|
161
177
|
const dragListener = (e: IG6GraphEvent) => {
|
|
178
|
+
const { style } = viewport;
|
|
179
|
+
const left = parseInt(style.left, 10);
|
|
180
|
+
const top = parseInt(style.top, 10);
|
|
181
|
+
const width = parseInt(style.width, 10);
|
|
182
|
+
const height = parseInt(style.height, 10);
|
|
183
|
+
|
|
184
|
+
if (resizing) {
|
|
185
|
+
const { clientX, clientY } = e;
|
|
186
|
+
const afterResize = { left, top, width, height };
|
|
187
|
+
if (resizing.includes('left')) {
|
|
188
|
+
afterResize.left = `${clientX}px`;
|
|
189
|
+
afterResize.width = `${left + width - clientX}px`;
|
|
190
|
+
} else if (resizing.includes('right')) {
|
|
191
|
+
afterResize.width = `${clientX - left}px`;
|
|
192
|
+
}
|
|
193
|
+
if (resizing.includes('top')) {
|
|
194
|
+
afterResize.top = `${clientY}`;
|
|
195
|
+
afterResize.height = `${top + height - clientY}`;
|
|
196
|
+
} else if (resizing.includes('bottom')) {
|
|
197
|
+
afterResize.height = `${clientY - top}`;
|
|
198
|
+
}
|
|
199
|
+
modifyCSS(viewport, afterResize);
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
162
202
|
if (!dragging || isNil(e.clientX) || isNil(e.clientY)) {
|
|
163
203
|
return;
|
|
164
204
|
}
|
|
@@ -168,12 +208,6 @@ export class Minimap extends Base {
|
|
|
168
208
|
let dx = x - e.clientX;
|
|
169
209
|
let dy = y - e.clientY;
|
|
170
210
|
|
|
171
|
-
const { style } = viewport;
|
|
172
|
-
const left = parseInt(style.left, 10);
|
|
173
|
-
const top = parseInt(style.top, 10);
|
|
174
|
-
const width = parseInt(style.width, 10);
|
|
175
|
-
const height = parseInt(style.height, 10);
|
|
176
|
-
|
|
177
211
|
// If the viewport is already on the left or right, stop moving x.
|
|
178
212
|
if (left - dx < 0 || left - dx + width >= size[0]) {
|
|
179
213
|
dx = 0;
|
|
@@ -201,6 +235,7 @@ export class Minimap extends Base {
|
|
|
201
235
|
|
|
202
236
|
const dragendListener = () => {
|
|
203
237
|
dragging = false;
|
|
238
|
+
resizing = false;
|
|
204
239
|
this.options.refresh = true;
|
|
205
240
|
};
|
|
206
241
|
const dragendevent = isSafari || isFireFox ? 'mouseup' : 'dragend';
|
|
@@ -549,6 +584,34 @@ export class Minimap extends Base {
|
|
|
549
584
|
false,
|
|
550
585
|
);
|
|
551
586
|
|
|
587
|
+
private handleVisibilityChange = (params) => {
|
|
588
|
+
const { ids, value } = params;
|
|
589
|
+
ids.forEach((id) => {
|
|
590
|
+
this.visibleCache[id] = value;
|
|
591
|
+
});
|
|
592
|
+
this.debounceCloneVisibility();
|
|
593
|
+
};
|
|
594
|
+
|
|
595
|
+
private debounceCloneVisibility = debounce(
|
|
596
|
+
() => {
|
|
597
|
+
const nodeGroup = this.canvas.getRoot().getElementById('node-group');
|
|
598
|
+
const edgeGroup = this.canvas.getRoot().getElementById('edge-group');
|
|
599
|
+
nodeGroup.childNodes.concat(edgeGroup.childNodes).forEach((child) => {
|
|
600
|
+
const id = child.getAttribute?.('data-item-id');
|
|
601
|
+
if (this.visibleCache.hasOwnProperty(id)) {
|
|
602
|
+
if (this.visibleCache[id]) {
|
|
603
|
+
child.childNodes.forEach((shape) => shape.show());
|
|
604
|
+
} else if (this.visibleCache[id] === false) {
|
|
605
|
+
child.childNodes.forEach((shape) => shape.hide());
|
|
606
|
+
}
|
|
607
|
+
}
|
|
608
|
+
});
|
|
609
|
+
this.visibleCache = {};
|
|
610
|
+
},
|
|
611
|
+
50,
|
|
612
|
+
false,
|
|
613
|
+
);
|
|
614
|
+
|
|
552
615
|
public init(graph: IGraph) {
|
|
553
616
|
super.init(graph);
|
|
554
617
|
const promise = this.initContainer();
|
|
@@ -696,3 +759,44 @@ export class Minimap extends Base {
|
|
|
696
759
|
if (container?.parentNode) container.parentNode.removeChild(container);
|
|
697
760
|
}
|
|
698
761
|
}
|
|
762
|
+
|
|
763
|
+
const getMoveAtBorder = (dom, evt) => {
|
|
764
|
+
const bounds = dom.getBoundingClientRect();
|
|
765
|
+
const { clientX, clientY } = evt;
|
|
766
|
+
if (Math.abs(clientX - bounds.x) < 4 && Math.abs(clientY - bounds.y) < 4) {
|
|
767
|
+
return 'left-top';
|
|
768
|
+
} else if (
|
|
769
|
+
Math.abs(clientX - bounds.x) < 4 &&
|
|
770
|
+
Math.abs(clientY - bounds.y - bounds.height) < 4
|
|
771
|
+
) {
|
|
772
|
+
return 'left-bottom';
|
|
773
|
+
} else if (
|
|
774
|
+
Math.abs(clientX - bounds.x - bounds.width) < 4 &&
|
|
775
|
+
Math.abs(clientY - bounds.y) < 4
|
|
776
|
+
) {
|
|
777
|
+
return 'right-top';
|
|
778
|
+
} else if (
|
|
779
|
+
Math.abs(clientX - bounds.x - bounds.width) < 4 &&
|
|
780
|
+
Math.abs(clientY - bounds.y - bounds.height) < 4
|
|
781
|
+
) {
|
|
782
|
+
return 'right-bottom';
|
|
783
|
+
} else if (Math.abs(clientX - bounds.x) < 4) {
|
|
784
|
+
return 'left';
|
|
785
|
+
} else if (Math.abs(clientY - bounds.y) < 4) {
|
|
786
|
+
return 'top';
|
|
787
|
+
} else if (Math.abs(clientY - bounds.y - bounds.height) < 4) {
|
|
788
|
+
return 'bottom';
|
|
789
|
+
}
|
|
790
|
+
return false;
|
|
791
|
+
};
|
|
792
|
+
|
|
793
|
+
const cursorMap = {
|
|
794
|
+
'left-top': 'nwse-resize',
|
|
795
|
+
'right-bottom': 'nwse-resize',
|
|
796
|
+
'right-top': 'nesw-resize',
|
|
797
|
+
'left-bottom': 'nesw-resize',
|
|
798
|
+
left: 'ew-resize',
|
|
799
|
+
right: 'ew-resize',
|
|
800
|
+
top: 'ns-resize',
|
|
801
|
+
bottom: 'ns-resize',
|
|
802
|
+
};
|