@antv/g6 5.0.9 → 5.0.11
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/dist/lib/behaviors/drag-canvas.d.ts +1 -0
- package/dist/lib/behaviors/fix-element-size.d.ts +88 -0
- package/dist/lib/behaviors/index.d.ts +4 -0
- package/dist/lib/behaviors/optimize-viewport-transform.d.ts +54 -0
- package/dist/lib/constants/events/graph.d.ts +13 -1
- package/dist/lib/exports.d.ts +7 -5
- package/dist/lib/plugins/history/index.d.ts +3 -4
- package/dist/lib/plugins/index.d.ts +2 -0
- package/dist/lib/plugins/minimap/index.d.ts +131 -0
- package/dist/lib/registry/build-in.d.ts +4 -4
- package/dist/lib/registry/get.d.ts +22 -0
- package/dist/lib/registry/{index.d.ts → register.d.ts} +1 -26
- package/dist/lib/registry/store.d.ts +7 -0
- package/dist/lib/runtime/canvas.d.ts +28 -7
- package/dist/lib/runtime/element.d.ts +3 -1
- package/dist/lib/runtime/graph.d.ts +5 -5
- package/dist/lib/utils/animation.d.ts +1 -1
- package/dist/lib/utils/bbox.d.ts +10 -0
- package/dist/lib/utils/event/events.d.ts +4 -4
- package/dist/lib/utils/visibility.d.ts +2 -1
- package/dist/lib/version.d.ts +1 -1
- package/esm/behaviors/create-edge.js +6 -4
- package/esm/behaviors/create-edge.js.map +1 -1
- package/esm/behaviors/drag-canvas.d.ts +1 -0
- package/esm/behaviors/drag-canvas.js +20 -14
- package/esm/behaviors/drag-canvas.js.map +1 -1
- package/esm/behaviors/fix-element-size.d.ts +88 -0
- package/esm/behaviors/fix-element-size.js +107 -0
- package/esm/behaviors/fix-element-size.js.map +1 -0
- package/esm/behaviors/hover-activate.js +5 -1
- package/esm/behaviors/hover-activate.js.map +1 -1
- package/esm/behaviors/index.d.ts +4 -0
- package/esm/behaviors/index.js +2 -0
- package/esm/behaviors/index.js.map +1 -1
- package/esm/behaviors/optimize-viewport-transform.d.ts +54 -0
- package/esm/behaviors/optimize-viewport-transform.js +71 -0
- package/esm/behaviors/optimize-viewport-transform.js.map +1 -0
- package/esm/behaviors/zoom-canvas.js +8 -11
- package/esm/behaviors/zoom-canvas.js.map +1 -1
- package/esm/constants/events/graph.d.ts +13 -1
- package/esm/constants/events/graph.js +12 -0
- package/esm/constants/events/graph.js.map +1 -1
- package/esm/elements/nodes/base-node.js +23 -2
- package/esm/elements/nodes/base-node.js.map +1 -1
- package/esm/elements/nodes/html.js +1 -1
- package/esm/elements/nodes/html.js.map +1 -1
- package/esm/elements/shapes/base-shape.js +0 -1
- package/esm/elements/shapes/base-shape.js.map +1 -1
- package/esm/elements/shapes/label.js +1 -1
- package/esm/elements/shapes/label.js.map +1 -1
- package/esm/exports.d.ts +7 -5
- package/esm/exports.js +4 -3
- package/esm/exports.js.map +1 -1
- package/esm/plugins/history/index.d.ts +3 -4
- package/esm/plugins/history/index.js +6 -7
- package/esm/plugins/history/index.js.map +1 -1
- package/esm/plugins/index.d.ts +2 -0
- package/esm/plugins/index.js +1 -0
- package/esm/plugins/index.js.map +1 -1
- package/esm/plugins/minimap/index.d.ts +131 -0
- package/esm/plugins/minimap/index.js +349 -0
- package/esm/plugins/minimap/index.js.map +1 -0
- package/esm/preset.js +1 -1
- package/esm/preset.js.map +1 -1
- package/esm/registry/build-in.d.ts +4 -4
- package/esm/registry/build-in.js +27 -11
- package/esm/registry/build-in.js.map +1 -1
- package/esm/registry/extension/index.js +1 -1
- package/esm/registry/extension/index.js.map +1 -1
- package/esm/registry/get.d.ts +22 -0
- package/esm/registry/get.js +29 -0
- package/esm/registry/get.js.map +1 -0
- package/esm/registry/{index.d.ts → register.d.ts} +1 -26
- package/esm/registry/{index.js → register.js} +2 -58
- package/esm/registry/register.js.map +1 -0
- package/esm/registry/store.d.ts +7 -0
- package/esm/registry/store.js +18 -0
- package/esm/registry/store.js.map +1 -0
- package/esm/runtime/canvas.d.ts +28 -7
- package/esm/runtime/canvas.js +68 -30
- package/esm/runtime/canvas.js.map +1 -1
- package/esm/runtime/element.d.ts +3 -1
- package/esm/runtime/element.js +9 -3
- package/esm/runtime/element.js.map +1 -1
- package/esm/runtime/graph.d.ts +5 -5
- package/esm/runtime/graph.js +18 -16
- package/esm/runtime/graph.js.map +1 -1
- package/esm/runtime/layout.js +1 -1
- package/esm/runtime/layout.js.map +1 -1
- package/esm/runtime/viewport.js +2 -1
- package/esm/runtime/viewport.js.map +1 -1
- package/esm/themes/base.js +2 -0
- package/esm/themes/base.js.map +1 -1
- package/esm/utils/animation.d.ts +1 -1
- package/esm/utils/animation.js +1 -1
- package/esm/utils/animation.js.map +1 -1
- package/esm/utils/bbox.d.ts +10 -0
- package/esm/utils/bbox.js +15 -0
- package/esm/utils/bbox.js.map +1 -1
- package/esm/utils/event/events.d.ts +4 -4
- package/esm/utils/palette.js +1 -1
- package/esm/utils/palette.js.map +1 -1
- package/esm/utils/print.js +2 -0
- package/esm/utils/print.js.map +1 -1
- package/esm/utils/router/orth.js +4 -4
- package/esm/utils/router/orth.js.map +1 -1
- package/esm/utils/theme.js +1 -1
- package/esm/utils/theme.js.map +1 -1
- package/esm/utils/visibility.d.ts +2 -1
- package/esm/utils/visibility.js +5 -2
- package/esm/utils/visibility.js.map +1 -1
- package/esm/version.d.ts +1 -1
- package/esm/version.js +1 -1
- package/esm/version.js.map +1 -1
- package/lib/behaviors/create-edge.js +6 -4
- package/lib/behaviors/create-edge.js.map +1 -1
- package/lib/behaviors/drag-canvas.d.ts +1 -0
- package/lib/behaviors/drag-canvas.js +18 -12
- package/lib/behaviors/drag-canvas.js.map +1 -1
- package/lib/behaviors/fix-element-size.d.ts +88 -0
- package/lib/behaviors/fix-element-size.js +111 -0
- package/lib/behaviors/fix-element-size.js.map +1 -0
- package/lib/behaviors/hover-activate.js +5 -1
- package/lib/behaviors/hover-activate.js.map +1 -1
- package/lib/behaviors/index.d.ts +4 -0
- package/lib/behaviors/index.js +5 -1
- package/lib/behaviors/index.js.map +1 -1
- package/lib/behaviors/optimize-viewport-transform.d.ts +54 -0
- package/lib/behaviors/optimize-viewport-transform.js +75 -0
- package/lib/behaviors/optimize-viewport-transform.js.map +1 -0
- package/lib/behaviors/zoom-canvas.js +7 -10
- package/lib/behaviors/zoom-canvas.js.map +1 -1
- package/lib/constants/events/graph.d.ts +13 -1
- package/lib/constants/events/graph.js +12 -0
- package/lib/constants/events/graph.js.map +1 -1
- package/lib/elements/nodes/base-node.js +23 -2
- package/lib/elements/nodes/base-node.js.map +1 -1
- package/lib/elements/nodes/html.js +1 -1
- package/lib/elements/nodes/html.js.map +1 -1
- package/lib/elements/shapes/base-shape.js +0 -1
- package/lib/elements/shapes/base-shape.js.map +1 -1
- package/lib/elements/shapes/label.js +1 -1
- package/lib/elements/shapes/label.js.map +1 -1
- package/lib/exports.d.ts +7 -5
- package/lib/exports.js +10 -6
- package/lib/exports.js.map +1 -1
- package/lib/plugins/history/index.d.ts +3 -4
- package/lib/plugins/history/index.js +6 -7
- package/lib/plugins/history/index.js.map +1 -1
- package/lib/plugins/index.d.ts +2 -0
- package/lib/plugins/index.js +3 -1
- package/lib/plugins/index.js.map +1 -1
- package/lib/plugins/minimap/index.d.ts +131 -0
- package/lib/plugins/minimap/index.js +353 -0
- package/lib/plugins/minimap/index.js.map +1 -0
- package/lib/preset.js +2 -2
- package/lib/preset.js.map +1 -1
- package/lib/registry/build-in.d.ts +4 -4
- package/lib/registry/build-in.js +26 -10
- package/lib/registry/build-in.js.map +1 -1
- package/lib/registry/extension/index.js +2 -2
- package/lib/registry/extension/index.js.map +1 -1
- package/lib/registry/get.d.ts +22 -0
- package/lib/registry/get.js +33 -0
- package/lib/registry/get.js.map +1 -0
- package/lib/registry/{index.d.ts → register.d.ts} +1 -26
- package/lib/registry/{index.js → register.js} +4 -63
- package/lib/registry/register.js.map +1 -0
- package/lib/registry/store.d.ts +7 -0
- package/lib/registry/store.js +21 -0
- package/lib/registry/store.js.map +1 -0
- package/lib/runtime/canvas.d.ts +28 -7
- package/lib/runtime/canvas.js +68 -30
- package/lib/runtime/canvas.js.map +1 -1
- package/lib/runtime/element.d.ts +3 -1
- package/lib/runtime/element.js +10 -4
- package/lib/runtime/element.js.map +1 -1
- package/lib/runtime/graph.d.ts +5 -5
- package/lib/runtime/graph.js +18 -16
- package/lib/runtime/graph.js.map +1 -1
- package/lib/runtime/layout.js +3 -3
- package/lib/runtime/layout.js.map +1 -1
- package/lib/runtime/viewport.js +2 -1
- package/lib/runtime/viewport.js.map +1 -1
- package/lib/themes/base.js +2 -0
- package/lib/themes/base.js.map +1 -1
- package/lib/utils/animation.d.ts +1 -1
- package/lib/utils/animation.js +2 -2
- package/lib/utils/animation.js.map +1 -1
- package/lib/utils/bbox.d.ts +10 -0
- package/lib/utils/bbox.js +16 -0
- package/lib/utils/bbox.js.map +1 -1
- package/lib/utils/event/events.d.ts +4 -4
- package/lib/utils/palette.js +3 -3
- package/lib/utils/palette.js.map +1 -1
- package/lib/utils/print.js +2 -0
- package/lib/utils/print.js.map +1 -1
- package/lib/utils/router/orth.js +3 -3
- package/lib/utils/router/orth.js.map +1 -1
- package/lib/utils/theme.js +2 -2
- package/lib/utils/theme.js.map +1 -1
- package/lib/utils/visibility.d.ts +2 -1
- package/lib/utils/visibility.js +5 -2
- package/lib/utils/visibility.js.map +1 -1
- package/lib/version.d.ts +1 -1
- package/lib/version.js +1 -1
- package/lib/version.js.map +1 -1
- package/package.json +2 -1
- package/src/behaviors/create-edge.ts +6 -4
- package/src/behaviors/drag-canvas.ts +20 -14
- package/src/behaviors/fix-element-size.ts +190 -0
- package/src/behaviors/hover-activate.ts +8 -1
- package/src/behaviors/index.ts +4 -0
- package/src/behaviors/optimize-viewport-transform.ts +127 -0
- package/src/behaviors/zoom-canvas.ts +8 -10
- package/src/constants/events/graph.ts +12 -0
- package/src/elements/nodes/base-node.ts +27 -2
- package/src/elements/nodes/html.ts +1 -1
- package/src/elements/shapes/base-shape.ts +0 -1
- package/src/elements/shapes/label.ts +1 -1
- package/src/exports.ts +9 -1
- package/src/plugins/history/index.ts +9 -10
- package/src/plugins/index.ts +2 -0
- package/src/plugins/minimap/index.ts +512 -0
- package/src/preset.ts +1 -1
- package/src/registry/build-in.ts +31 -9
- package/src/registry/extension/index.ts +1 -1
- package/src/registry/get.ts +37 -0
- package/src/registry/{index.ts → register.ts} +2 -66
- package/src/registry/store.ts +19 -0
- package/src/runtime/canvas.ts +87 -29
- package/src/runtime/element.ts +20 -4
- package/src/runtime/graph.ts +19 -15
- package/src/runtime/layout.ts +1 -1
- package/src/runtime/viewport.ts +3 -2
- package/src/themes/base.ts +2 -0
- package/src/utils/animation.ts +1 -1
- package/src/utils/bbox.ts +21 -0
- package/src/utils/palette.ts +1 -1
- package/src/utils/print.ts +2 -0
- package/src/utils/router/orth.ts +5 -3
- package/src/utils/theme.ts +1 -1
- package/src/utils/visibility.ts +9 -2
- package/src/version.ts +1 -1
- package/esm/registry/index.js.map +0 -1
- package/lib/registry/index.js.map +0 -1
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
import type { DisplayObject } from '@antv/g';
|
|
2
|
+
import { isFunction, isNumber } from '@antv/util';
|
|
3
|
+
import { GraphEvent } from '../constants';
|
|
4
|
+
import type { RuntimeContext } from '../runtime/types';
|
|
5
|
+
import type { Element, ID, IViewportEvent, State } from '../types';
|
|
6
|
+
import { cacheStyle, getCachedStyle, hasCachedStyle } from '../utils/cache';
|
|
7
|
+
import { idOf } from '../utils/id';
|
|
8
|
+
import { getDescendantShapes } from '../utils/shape';
|
|
9
|
+
import type { BaseBehaviorOptions } from './base-behavior';
|
|
10
|
+
import { BaseBehavior } from './base-behavior';
|
|
11
|
+
|
|
12
|
+
export type FixShapeConfig = {
|
|
13
|
+
/**
|
|
14
|
+
* <zh/> 指定要固定大小的元素属性对应的图形。如果不指定,则固定整个元素
|
|
15
|
+
*
|
|
16
|
+
* <en/> Specify the shape corresponding to properties to be fixed in size. If not specified, fix the entire element
|
|
17
|
+
*/
|
|
18
|
+
shape: (shapes: DisplayObject[]) => DisplayObject;
|
|
19
|
+
/**
|
|
20
|
+
* <zh/> 指定要固定大小的属性
|
|
21
|
+
*
|
|
22
|
+
* <en/> Specify properties to be fixed
|
|
23
|
+
*/
|
|
24
|
+
fields: string[];
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* <zh/> 固定元素大小交互配置项
|
|
29
|
+
*
|
|
30
|
+
* <en/> Fix element size behavior options
|
|
31
|
+
*/
|
|
32
|
+
export interface FixElementSizeOptions extends BaseBehaviorOptions {
|
|
33
|
+
/**
|
|
34
|
+
* <zh/> 是否启用固定元素大小交互。默认在缩小画布时启用
|
|
35
|
+
*
|
|
36
|
+
* <en/> Whether to enable the fix element size behavior. Enabled by default when zooming out
|
|
37
|
+
* @defaultValue `(event) => Boolean(event.data.scale < 1)`
|
|
38
|
+
*/
|
|
39
|
+
enable?: boolean | ((event: IViewportEvent) => boolean);
|
|
40
|
+
/**
|
|
41
|
+
* <zh/> 指定要固定大小的元素状态
|
|
42
|
+
*
|
|
43
|
+
* <en/> Specify the state of elements to be fixed in size
|
|
44
|
+
*/
|
|
45
|
+
state?: State;
|
|
46
|
+
/**
|
|
47
|
+
* <zh/> 节点配置项,用于定义哪些属性在视觉上保持固定大小。若未指定(即为 undefined),则整个节点将被固定
|
|
48
|
+
*
|
|
49
|
+
* <en/> Node configuration for defining which node attributes should remain fixed in size visually. If not specified (i.e., undefined), the entire node will be fixed in size.
|
|
50
|
+
* @example
|
|
51
|
+
* <zh/> 例如,在缩放过程中固定节点的 lineWidth 属性,可以配置如下:
|
|
52
|
+
*
|
|
53
|
+
* <en/> For example, to fix `lineWidth` attribute of a node during zooming, you can configure it as follows:
|
|
54
|
+
* ```ts
|
|
55
|
+
* {
|
|
56
|
+
* node: [
|
|
57
|
+
* {
|
|
58
|
+
* shape: (shapes: DisplayObject[]) => shapes.find((shape) => shape.className === 'key'),
|
|
59
|
+
* fields: ['lineWidth'],
|
|
60
|
+
* },
|
|
61
|
+
* ],
|
|
62
|
+
* }
|
|
63
|
+
* ```
|
|
64
|
+
*/
|
|
65
|
+
node?: FixShapeConfig | FixShapeConfig[];
|
|
66
|
+
/**
|
|
67
|
+
* <zh/> 边配置项,用于定义哪些属性在视觉上保持固定大小。默认固定 lineWidth、labelFontSize 属性
|
|
68
|
+
*
|
|
69
|
+
* <en/> Edge configuration for defining which edge attributes should remain fixed in size visually. By default, the lineWidth and labelFontSize attributes are fixed
|
|
70
|
+
*/
|
|
71
|
+
edge?: FixShapeConfig | FixShapeConfig[];
|
|
72
|
+
/**
|
|
73
|
+
* <zh/> Combo 配置项,用于定义哪些属性在视觉上保持固定大小。默认整个 Combo 将被固定
|
|
74
|
+
*
|
|
75
|
+
* <en/> Combo configuration for defining which combo attributes should remain fixed in size visually. By default, the entire combo will be fixed
|
|
76
|
+
*/
|
|
77
|
+
combo?: FixShapeConfig | FixShapeConfig[];
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* <zh/> 缩放画布过程中固定元素大小
|
|
82
|
+
*
|
|
83
|
+
* <en/> Fix element size while zooming
|
|
84
|
+
*/
|
|
85
|
+
export class FixElementSize extends BaseBehavior {
|
|
86
|
+
static defaultOptions: Partial<FixElementSizeOptions> = {
|
|
87
|
+
enable: (event) => event.data.scale! < 1,
|
|
88
|
+
state: 'selected',
|
|
89
|
+
edge: [
|
|
90
|
+
{
|
|
91
|
+
shape: (shapes: DisplayObject[]) => shapes.find((shape) => shape.className === 'key')!,
|
|
92
|
+
fields: ['lineWidth'],
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
shape: (shapes: DisplayObject[]) =>
|
|
96
|
+
shapes.find((shape) => shape.parentElement?.className === 'label' && shape.className === 'text')!,
|
|
97
|
+
fields: ['fontSize', 'lineHeight'],
|
|
98
|
+
},
|
|
99
|
+
],
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
private elementCache: Map<ID, Element> = new Map();
|
|
103
|
+
|
|
104
|
+
constructor(context: RuntimeContext, options: FixElementSizeOptions) {
|
|
105
|
+
super(context, Object.assign({}, FixElementSize.defaultOptions, options));
|
|
106
|
+
this.bindEvents();
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
private isZoomEvent = (event: IViewportEvent) => 'scale' in event.data;
|
|
110
|
+
|
|
111
|
+
private fixElementSize = async (event: IViewportEvent) => {
|
|
112
|
+
if (!this.isZoomEvent(event) || !this.validate(event)) return;
|
|
113
|
+
|
|
114
|
+
const { graph, element } = this.context;
|
|
115
|
+
const { state } = this.options;
|
|
116
|
+
const elementData = state
|
|
117
|
+
? [
|
|
118
|
+
...graph.getElementDataByState('node', state),
|
|
119
|
+
...graph.getElementDataByState('edge', state),
|
|
120
|
+
...graph.getElementDataByState('combo', state),
|
|
121
|
+
]
|
|
122
|
+
: Object.values(graph.getData()).flat();
|
|
123
|
+
|
|
124
|
+
if (!elementData.length) return;
|
|
125
|
+
|
|
126
|
+
const currentScale = event.data.scale || graph.getZoom();
|
|
127
|
+
elementData.forEach((elementData) => {
|
|
128
|
+
const id = idOf(elementData);
|
|
129
|
+
const el = element?.getElement(id) as Element;
|
|
130
|
+
const type = graph.getElementType(id);
|
|
131
|
+
|
|
132
|
+
const config = this.options[type];
|
|
133
|
+
|
|
134
|
+
if (!config) {
|
|
135
|
+
this.elementCache.set(id, el);
|
|
136
|
+
if (type === 'edge') {
|
|
137
|
+
el.style.transformOrigin = 'center';
|
|
138
|
+
}
|
|
139
|
+
// FIXME: 修改 Path 的 localScale 属性时遇到问题,导致边会偏移错位
|
|
140
|
+
el.setLocalScale(1 / currentScale);
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
const descendantShapes = getDescendantShapes(el);
|
|
145
|
+
const configs = Array.isArray(config) ? config : [config];
|
|
146
|
+
configs.forEach((config: FixShapeConfig) => {
|
|
147
|
+
const { shape: shapeFilter, fields } = config;
|
|
148
|
+
const shape = shapeFilter(descendantShapes);
|
|
149
|
+
|
|
150
|
+
fields.forEach((field) => {
|
|
151
|
+
if (!hasCachedStyle(shape, field)) cacheStyle(shape, field);
|
|
152
|
+
const oriFieldValue = getCachedStyle(shape, field);
|
|
153
|
+
if (!isNumber(oriFieldValue)) return;
|
|
154
|
+
shape.style[field] = oriFieldValue / currentScale;
|
|
155
|
+
});
|
|
156
|
+
});
|
|
157
|
+
});
|
|
158
|
+
};
|
|
159
|
+
|
|
160
|
+
private resetTransform = async () => {
|
|
161
|
+
if (this.elementCache) {
|
|
162
|
+
this.elementCache.forEach((el) => el.setLocalScale(1));
|
|
163
|
+
this.elementCache.clear();
|
|
164
|
+
}
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
private bindEvents() {
|
|
168
|
+
const { graph } = this.context;
|
|
169
|
+
graph.on(GraphEvent.AFTER_TRANSFORM, this.fixElementSize);
|
|
170
|
+
graph.on(GraphEvent.BEFORE_DRAW, this.resetTransform);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
private unbindEvents() {
|
|
174
|
+
const { graph } = this.context;
|
|
175
|
+
graph.off(GraphEvent.AFTER_TRANSFORM, this.fixElementSize);
|
|
176
|
+
graph.off(GraphEvent.BEFORE_DRAW, this.resetTransform);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
private validate(event: IViewportEvent) {
|
|
180
|
+
if (this.destroyed) return false;
|
|
181
|
+
const { enable } = this.options;
|
|
182
|
+
if (isFunction(enable)) return enable(event);
|
|
183
|
+
return !!enable;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
public destroy(): void {
|
|
187
|
+
this.unbindEvents();
|
|
188
|
+
super.destroy();
|
|
189
|
+
}
|
|
190
|
+
}
|
|
@@ -155,7 +155,14 @@ export class HoverActivate extends BaseBehavior<HoverActivateOptions> {
|
|
|
155
155
|
};
|
|
156
156
|
|
|
157
157
|
private validate(event: IPointerEvent) {
|
|
158
|
-
if (
|
|
158
|
+
if (
|
|
159
|
+
this.destroyed ||
|
|
160
|
+
this.isFrozen ||
|
|
161
|
+
// @ts-expect-error private property
|
|
162
|
+
// 避免动画冲突,在combo折叠展开过程中不触发悬停事件 | To prevent animation conflicts, hover events are disabled during combo expand/collapse actions
|
|
163
|
+
this.context.graph.isCollapsingExpanding
|
|
164
|
+
)
|
|
165
|
+
return false;
|
|
159
166
|
const { enable } = this.options;
|
|
160
167
|
if (isFunction(enable)) return enable(event);
|
|
161
168
|
return !!enable;
|
package/src/behaviors/index.ts
CHANGED
|
@@ -6,9 +6,11 @@ export { CreateEdge } from './create-edge';
|
|
|
6
6
|
export { DragCanvas } from './drag-canvas';
|
|
7
7
|
export { DragElement } from './drag-element';
|
|
8
8
|
export { DragElementForce } from './drag-element-force';
|
|
9
|
+
export { FixElementSize } from './fix-element-size';
|
|
9
10
|
export { FocusElement } from './focus-element';
|
|
10
11
|
export { HoverActivate } from './hover-activate';
|
|
11
12
|
export { LassoSelect } from './lasso-select';
|
|
13
|
+
export { OptimizeViewportTransform } from './optimize-viewport-transform';
|
|
12
14
|
export { ScrollCanvas } from './scroll-canvas';
|
|
13
15
|
export { ZoomCanvas } from './zoom-canvas';
|
|
14
16
|
|
|
@@ -20,8 +22,10 @@ export type { CreateEdgeOptions } from './create-edge';
|
|
|
20
22
|
export type { DragCanvasOptions } from './drag-canvas';
|
|
21
23
|
export type { DragElementOptions } from './drag-element';
|
|
22
24
|
export type { DragElementForceOptions } from './drag-element-force';
|
|
25
|
+
export type { FixElementSizeOptions } from './fix-element-size';
|
|
23
26
|
export type { FocusElementOptions } from './focus-element';
|
|
24
27
|
export type { HoverActivateOptions } from './hover-activate';
|
|
25
28
|
export type { LassoSelectOptions } from './lasso-select';
|
|
29
|
+
export type { OptimizeViewportTransformOptions } from './optimize-viewport-transform';
|
|
26
30
|
export type { ScrollCanvasOptions } from './scroll-canvas';
|
|
27
31
|
export type { ZoomCanvasOptions } from './zoom-canvas';
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import type { BaseStyleProps, DisplayObject } from '@antv/g';
|
|
2
|
+
import { debounce, isFunction } from '@antv/util';
|
|
3
|
+
import { GraphEvent } from '../constants';
|
|
4
|
+
import type { RuntimeContext } from '../runtime/types';
|
|
5
|
+
import type { IViewportEvent } from '../types/event';
|
|
6
|
+
import { setVisibility } from '../utils/visibility';
|
|
7
|
+
import type { BaseBehaviorOptions } from './base-behavior';
|
|
8
|
+
import { BaseBehavior } from './base-behavior';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* <zh/> 画布优化交互配置项
|
|
12
|
+
*
|
|
13
|
+
* <en/> Canvas optimization behavior options
|
|
14
|
+
*/
|
|
15
|
+
export interface OptimizeViewportTransformOptions extends BaseBehaviorOptions {
|
|
16
|
+
/**
|
|
17
|
+
* <zh/> 是否启用画布优化功能
|
|
18
|
+
*
|
|
19
|
+
* <en/> Whether to enable canvas optimization function
|
|
20
|
+
* @defaultValue true
|
|
21
|
+
*/
|
|
22
|
+
enable?: boolean | ((event: IViewportEvent) => boolean);
|
|
23
|
+
/**
|
|
24
|
+
* <zh/> 始终保留的图形类名。操作画布过程中会隐藏元素reservedShapes(除了指定类名的图形),以提高性能
|
|
25
|
+
*
|
|
26
|
+
* <en/> Persistently reserved shape classnames. Elements are hidden during canvas manipulation (except for shapes with specified classnames) to enhance performance.
|
|
27
|
+
* @defaultValue `{ node: ['key'] }`
|
|
28
|
+
*/
|
|
29
|
+
shapes?: {
|
|
30
|
+
node?: string[];
|
|
31
|
+
edge?: string[];
|
|
32
|
+
combo?: string[];
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* <zh/> 设置防抖时间
|
|
36
|
+
*
|
|
37
|
+
* <en/> Set debounce time
|
|
38
|
+
* @defaultValue 200
|
|
39
|
+
*/
|
|
40
|
+
debounce?: number;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* <zh/> 操作画布过程中隐藏元素
|
|
45
|
+
*
|
|
46
|
+
* <en/> Hide elements during canvas operations (dragging, zooming, scrolling)
|
|
47
|
+
*/
|
|
48
|
+
export class OptimizeViewportTransform extends BaseBehavior<OptimizeViewportTransformOptions> {
|
|
49
|
+
static defaultOptions: Partial<OptimizeViewportTransformOptions> = {
|
|
50
|
+
enable: true,
|
|
51
|
+
debounce: 200,
|
|
52
|
+
shapes: { node: ['key'] },
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
private isVisible: boolean = true;
|
|
56
|
+
|
|
57
|
+
constructor(context: RuntimeContext, options: OptimizeViewportTransformOptions) {
|
|
58
|
+
super(context, Object.assign({}, OptimizeViewportTransform.defaultOptions, options));
|
|
59
|
+
this.bindEvents();
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
private filterShapes = (shapes: DisplayObject[], classnames?: string[]) => {
|
|
63
|
+
return shapes.filter((shape) => shape.className && !classnames?.includes(shape.className));
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
private setElementsVisibility = (
|
|
67
|
+
elements: DisplayObject[],
|
|
68
|
+
visibility: BaseStyleProps['visibility'],
|
|
69
|
+
excludedClassnames?: string[],
|
|
70
|
+
) => {
|
|
71
|
+
elements.forEach((element) => {
|
|
72
|
+
setVisibility(
|
|
73
|
+
element,
|
|
74
|
+
visibility,
|
|
75
|
+
excludedClassnames && ((shapes) => this.filterShapes(shapes, excludedClassnames)),
|
|
76
|
+
);
|
|
77
|
+
});
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
private hideShapes = (event: IViewportEvent) => {
|
|
81
|
+
if (!this.validate(event) || !this.isVisible) return;
|
|
82
|
+
|
|
83
|
+
const { element } = this.context;
|
|
84
|
+
const { shapes = {} } = this.options;
|
|
85
|
+
this.setElementsVisibility(element!.getNodes(), 'hidden', shapes.node);
|
|
86
|
+
this.setElementsVisibility(element!.getEdges(), 'hidden', shapes.edge);
|
|
87
|
+
this.setElementsVisibility(element!.getCombos(), 'hidden', shapes.combo);
|
|
88
|
+
this.isVisible = false;
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
private showShapes = debounce((event: IViewportEvent) => {
|
|
92
|
+
if (!this.validate(event) || this.isVisible) return;
|
|
93
|
+
|
|
94
|
+
const { element } = this.context;
|
|
95
|
+
this.setElementsVisibility(element!.getNodes(), 'visible');
|
|
96
|
+
this.setElementsVisibility(element!.getEdges(), 'visible');
|
|
97
|
+
this.setElementsVisibility(element!.getCombos(), 'visible');
|
|
98
|
+
this.isVisible = true;
|
|
99
|
+
}, this.options.debounce);
|
|
100
|
+
|
|
101
|
+
private bindEvents() {
|
|
102
|
+
const { graph } = this.context;
|
|
103
|
+
|
|
104
|
+
graph.on(GraphEvent.BEFORE_TRANSFORM, this.hideShapes);
|
|
105
|
+
graph.on(GraphEvent.AFTER_TRANSFORM, this.showShapes);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
private unbindEvents() {
|
|
109
|
+
const { graph } = this.context;
|
|
110
|
+
|
|
111
|
+
graph.off(GraphEvent.BEFORE_TRANSFORM, this.hideShapes);
|
|
112
|
+
graph.off(GraphEvent.AFTER_TRANSFORM, this.showShapes);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
private validate(event: IViewportEvent) {
|
|
116
|
+
if (this.destroyed) return false;
|
|
117
|
+
|
|
118
|
+
const { enable } = this.options;
|
|
119
|
+
if (isFunction(enable)) return enable(event);
|
|
120
|
+
return !!enable;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
public destroy() {
|
|
124
|
+
this.unbindEvents();
|
|
125
|
+
super.destroy();
|
|
126
|
+
}
|
|
127
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { clamp,
|
|
1
|
+
import { clamp, isFunction } from '@antv/util';
|
|
2
2
|
import { CommonEvent } from '../constants';
|
|
3
3
|
import type { RuntimeContext } from '../runtime/types';
|
|
4
4
|
import type { IKeyboardEvent, IWheelEvent, Point, PointObject, ViewportAnimationEffectTiming } from '../types';
|
|
@@ -98,15 +98,15 @@ export class ZoomCanvas extends BaseBehavior<ZoomCanvasOptions> {
|
|
|
98
98
|
const { trigger } = this.options;
|
|
99
99
|
this.shortcut.unbindAll();
|
|
100
100
|
|
|
101
|
-
if (isArray(trigger)) {
|
|
102
|
-
this.
|
|
101
|
+
if (Array.isArray(trigger)) {
|
|
102
|
+
this.context.canvas.getContainer()?.addEventListener(CommonEvent.WHEEL, this.preventDefault);
|
|
103
103
|
this.shortcut.bind([...trigger, CommonEvent.WHEEL], (event) => {
|
|
104
104
|
const { deltaX, deltaY } = event;
|
|
105
105
|
this.zoom(-(deltaY ?? deltaX), event, false);
|
|
106
106
|
});
|
|
107
107
|
}
|
|
108
108
|
|
|
109
|
-
if (
|
|
109
|
+
if (typeof trigger === 'object') {
|
|
110
110
|
const {
|
|
111
111
|
zoomIn = [],
|
|
112
112
|
zoomOut = [],
|
|
@@ -170,12 +170,9 @@ export class ZoomCanvas extends BaseBehavior<ZoomCanvasOptions> {
|
|
|
170
170
|
return !!enable;
|
|
171
171
|
}
|
|
172
172
|
|
|
173
|
-
private preventDefault(
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
if (!container) return;
|
|
177
|
-
container.addEventListener(eventName, listener);
|
|
178
|
-
}
|
|
173
|
+
private preventDefault = (event: Event) => {
|
|
174
|
+
event.preventDefault();
|
|
175
|
+
};
|
|
179
176
|
|
|
180
177
|
/**
|
|
181
178
|
* <zh/> 销毁缩放画布
|
|
@@ -184,6 +181,7 @@ export class ZoomCanvas extends BaseBehavior<ZoomCanvasOptions> {
|
|
|
184
181
|
*/
|
|
185
182
|
public destroy() {
|
|
186
183
|
this.shortcut.destroy();
|
|
184
|
+
this.context.canvas.getContainer()?.removeEventListener(CommonEvent.WHEEL, this.preventDefault);
|
|
187
185
|
super.destroy();
|
|
188
186
|
}
|
|
189
187
|
}
|
|
@@ -167,4 +167,16 @@ export enum GraphEvent {
|
|
|
167
167
|
* <en/> After destruction
|
|
168
168
|
*/
|
|
169
169
|
AFTER_DESTROY = 'afterdestroy',
|
|
170
|
+
/**
|
|
171
|
+
* <zh/> 渲染器变更之前
|
|
172
|
+
*
|
|
173
|
+
* <en/> Before the renderer changes
|
|
174
|
+
*/
|
|
175
|
+
BEFORE_RENDERER_CHANGE = 'beforerendererchange',
|
|
176
|
+
/**
|
|
177
|
+
* <zh/> 渲染器变更之后
|
|
178
|
+
*
|
|
179
|
+
* <en/> After the renderer changes
|
|
180
|
+
*/
|
|
181
|
+
AFTER_RENDERER_CHANGE = 'afterrendererchange',
|
|
170
182
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { BaseStyleProps, CircleStyleProps, DisplayObject, DisplayObjectConfig, Group } from '@antv/g';
|
|
2
2
|
import { Circle as GCircle } from '@antv/g';
|
|
3
3
|
import type { CategoricalPalette } from '../../palettes/types';
|
|
4
|
+
import type { RuntimeContext } from '../../runtime/types';
|
|
4
5
|
import type { NodeData } from '../../spec';
|
|
5
6
|
import type {
|
|
6
7
|
BaseElementStyleProps,
|
|
@@ -24,6 +25,7 @@ import { omitStyleProps, subObject, subStyleProps } from '../../utils/prefix';
|
|
|
24
25
|
import { parseSize } from '../../utils/size';
|
|
25
26
|
import { mergeOptions } from '../../utils/style';
|
|
26
27
|
import { getWordWrapWidthByBox } from '../../utils/text';
|
|
28
|
+
import { setVisibility } from '../../utils/visibility';
|
|
27
29
|
import { BaseElement } from '../base-element';
|
|
28
30
|
import { effect } from '../effect';
|
|
29
31
|
import type { BadgeStyleProps, IconStyleProps, LabelStyleProps } from '../shapes';
|
|
@@ -328,8 +330,8 @@ export abstract class BaseNode<S extends BaseNodeStyleProps = BaseNodeStyleProps
|
|
|
328
330
|
|
|
329
331
|
protected getPortXY(attributes: Required<S>, style: NodePortStyleProps): Point {
|
|
330
332
|
const { placement = 'left' } = style;
|
|
331
|
-
const
|
|
332
|
-
return getPortXYByPlacement(
|
|
333
|
+
const keyShape = this.getShape('key');
|
|
334
|
+
return getPortXYByPlacement(getBoundsInOffscreen(this.context, keyShape), placement as PortPlacement);
|
|
333
335
|
}
|
|
334
336
|
|
|
335
337
|
/**
|
|
@@ -385,6 +387,7 @@ export abstract class BaseNode<S extends BaseNodeStyleProps = BaseNodeStyleProps
|
|
|
385
387
|
@effect((self, attributes) => self.getPortsStyle(attributes))
|
|
386
388
|
protected drawPortShapes(attributes: Required<S>, container: Group): void {
|
|
387
389
|
const portsStyle = this.getPortsStyle(attributes);
|
|
390
|
+
|
|
388
391
|
Object.keys(portsStyle).forEach((key) => {
|
|
389
392
|
this.upsert(`port-${key}`, GCircle, portsStyle[key] as CircleStyleProps, container);
|
|
390
393
|
});
|
|
@@ -429,3 +432,25 @@ export abstract class BaseNode<S extends BaseNodeStyleProps = BaseNodeStyleProps
|
|
|
429
432
|
this.drawLabelShape(this.parsedAttributes, this);
|
|
430
433
|
}
|
|
431
434
|
}
|
|
435
|
+
|
|
436
|
+
/**
|
|
437
|
+
*
|
|
438
|
+
* @param context
|
|
439
|
+
* @param shape
|
|
440
|
+
*/
|
|
441
|
+
function getBoundsInOffscreen(context: RuntimeContext, shape: DisplayObject) {
|
|
442
|
+
if (!context) return shape.getLocalBounds();
|
|
443
|
+
|
|
444
|
+
// 将主图形靠背至全局空间,避免受到父级 transform 的影响
|
|
445
|
+
// 合理的操作应该是靠背至离屏画布,但目前 G 有点问题
|
|
446
|
+
// Move the main graphic to the global space to avoid being affected by the parent transform
|
|
447
|
+
// The reasonable operation should be moved to the off-screen canvas, but there is a problem with G at present
|
|
448
|
+
const canvas = context.canvas.getLayer();
|
|
449
|
+
const substitute = shape.cloneNode();
|
|
450
|
+
setVisibility(substitute, 'hidden');
|
|
451
|
+
canvas.appendChild(substitute);
|
|
452
|
+
const bounds = substitute.getLocalBounds();
|
|
453
|
+
canvas.removeChild(substitute);
|
|
454
|
+
|
|
455
|
+
return bounds;
|
|
456
|
+
}
|
|
@@ -215,7 +215,7 @@ export class HTML extends BaseNode<HTMLStyleProps> {
|
|
|
215
215
|
const { x, y } = this.getViewportXY(normalizedEvent);
|
|
216
216
|
event.viewport.x = x;
|
|
217
217
|
event.viewport.y = y;
|
|
218
|
-
const
|
|
218
|
+
const [canvasX, canvasY] = this.context.canvas.getCanvasByViewport([x, y]);
|
|
219
219
|
event.canvas.x = canvasX;
|
|
220
220
|
event.canvas.y = canvasY;
|
|
221
221
|
event.global.copyFrom(event.canvas);
|
|
@@ -236,7 +236,6 @@ export abstract class BaseShape<StyleProps extends BaseShapeStyleProps> extends
|
|
|
236
236
|
* @description see: https://github.com/antvis/G/issues/1731
|
|
237
237
|
*/
|
|
238
238
|
function releaseAnimation(target: DisplayObject, animation: IAnimation) {
|
|
239
|
-
animation.oncancel = () => console.log('cancel');
|
|
240
239
|
animation?.finished.then(() => {
|
|
241
240
|
// @ts-expect-error private property
|
|
242
241
|
const index = target.activeAnimations.findIndex((_) => _ === animation);
|
|
@@ -91,7 +91,7 @@ export class Label extends BaseShape<LabelStyleProps> {
|
|
|
91
91
|
Object.assign(backgroundStyle, {
|
|
92
92
|
x: minX - left,
|
|
93
93
|
y: minY - top,
|
|
94
|
-
width: wordWrap ? Math.min(totalWidth, wordWrapWidth) : totalWidth,
|
|
94
|
+
width: wordWrap ? Math.min(totalWidth, wordWrapWidth + left + right) : totalWidth,
|
|
95
95
|
height: halfHeight * 2 + top + bottom,
|
|
96
96
|
});
|
|
97
97
|
}
|
package/src/exports.ts
CHANGED
|
@@ -7,9 +7,11 @@ export {
|
|
|
7
7
|
DragCanvas,
|
|
8
8
|
DragElement,
|
|
9
9
|
DragElementForce,
|
|
10
|
+
FixElementSize,
|
|
10
11
|
FocusElement,
|
|
11
12
|
HoverActivate,
|
|
12
13
|
LassoSelect,
|
|
14
|
+
OptimizeViewportTransform,
|
|
13
15
|
ScrollCanvas,
|
|
14
16
|
ZoomCanvas,
|
|
15
17
|
} from './behaviors';
|
|
@@ -70,12 +72,14 @@ export {
|
|
|
70
72
|
History,
|
|
71
73
|
Hull,
|
|
72
74
|
Legend,
|
|
75
|
+
Minimap,
|
|
73
76
|
Timebar,
|
|
74
77
|
Toolbar,
|
|
75
78
|
Tooltip,
|
|
76
79
|
Watermark,
|
|
77
80
|
} from './plugins';
|
|
78
|
-
export { getExtension, getExtensions
|
|
81
|
+
export { getExtension, getExtensions } from './registry/get';
|
|
82
|
+
export { register } from './registry/register';
|
|
79
83
|
export { Graph } from './runtime/graph';
|
|
80
84
|
export { BaseTransform } from './transforms';
|
|
81
85
|
export { isCollapsed } from './utils/collapsibility';
|
|
@@ -114,12 +118,15 @@ export type {
|
|
|
114
118
|
DragCanvasOptions,
|
|
115
119
|
DragElementForceOptions,
|
|
116
120
|
DragElementOptions,
|
|
121
|
+
FixElementSizeOptions,
|
|
117
122
|
FocusElementOptions,
|
|
118
123
|
HoverActivateOptions,
|
|
119
124
|
LassoSelectOptions,
|
|
125
|
+
OptimizeViewportTransformOptions,
|
|
120
126
|
ScrollCanvasOptions,
|
|
121
127
|
ZoomCanvasOptions,
|
|
122
128
|
} from './behaviors';
|
|
129
|
+
export type { FixShapeConfig } from './behaviors/fix-element-size';
|
|
123
130
|
export type { BaseComboStyleProps, CircleComboStyleProps, RectComboStyleProps } from './elements/combos';
|
|
124
131
|
export type {
|
|
125
132
|
BaseEdgeStyleProps,
|
|
@@ -163,6 +170,7 @@ export type {
|
|
|
163
170
|
HistoryOptions,
|
|
164
171
|
HullOptions,
|
|
165
172
|
LegendOptions,
|
|
173
|
+
MinimapOptions,
|
|
166
174
|
TimebarOptions,
|
|
167
175
|
ToolbarOptions,
|
|
168
176
|
TooltipOptions,
|
|
@@ -28,13 +28,13 @@ export interface HistoryOptions extends BasePluginOptions {
|
|
|
28
28
|
*
|
|
29
29
|
* <en/> Called before a command is added to the Undo/Redo queue. If this method returns false, the command will not be added to the queue. revert is true for undo operations and false for redo operations
|
|
30
30
|
*/
|
|
31
|
-
beforeAddCommand?: (cmd: Command, revert
|
|
31
|
+
beforeAddCommand?: (cmd: Command, revert: boolean) => boolean | void;
|
|
32
32
|
/**
|
|
33
33
|
* <zh/> 当一个命令被添加到 Undo/Redo 队列后被调用。revert 为 true 时表示撤销操作,为 false 时表示重做操作
|
|
34
34
|
*
|
|
35
35
|
* <en/> Called after a command is added to the Undo/Redo queue. revert is true for undo operations and false for redo operations
|
|
36
36
|
*/
|
|
37
|
-
afterAddCommand?: (cmd: Command, revert
|
|
37
|
+
afterAddCommand?: (cmd: Command, revert: boolean) => void;
|
|
38
38
|
/**
|
|
39
39
|
* <zh/> 执行命令时的回调函数
|
|
40
40
|
*
|
|
@@ -61,7 +61,6 @@ export class History extends BasePlugin<HistoryOptions> {
|
|
|
61
61
|
private batchAnimation = false;
|
|
62
62
|
public undoStack: Command[] = [];
|
|
63
63
|
public redoStack: Command[] = [];
|
|
64
|
-
private isFirstDraw = true;
|
|
65
64
|
private freezed = false;
|
|
66
65
|
|
|
67
66
|
constructor(context: RuntimeContext, options: HistoryOptions) {
|
|
@@ -105,7 +104,10 @@ export class History extends BasePlugin<HistoryOptions> {
|
|
|
105
104
|
const cmd = this.undoStack.pop();
|
|
106
105
|
if (cmd) {
|
|
107
106
|
this.executeCommand(cmd);
|
|
108
|
-
|
|
107
|
+
|
|
108
|
+
const before = this.options.beforeAddCommand?.(cmd, false);
|
|
109
|
+
if (before === false) return;
|
|
110
|
+
|
|
109
111
|
this.redoStack.push(cmd);
|
|
110
112
|
this.options.afterAddCommand?.(cmd, false);
|
|
111
113
|
this.notify(HistoryEvent.UNDO, cmd);
|
|
@@ -160,11 +162,6 @@ export class History extends BasePlugin<HistoryOptions> {
|
|
|
160
162
|
};
|
|
161
163
|
|
|
162
164
|
private addCommand = (event: GraphLifeCycleEvent) => {
|
|
163
|
-
if (this.isFirstDraw) {
|
|
164
|
-
this.isFirstDraw = false;
|
|
165
|
-
return;
|
|
166
|
-
}
|
|
167
|
-
|
|
168
165
|
if (this.freezed) return;
|
|
169
166
|
|
|
170
167
|
if (event.type === GraphEvent.AFTER_DRAW) {
|
|
@@ -202,7 +199,9 @@ export class History extends BasePlugin<HistoryOptions> {
|
|
|
202
199
|
this.undoStack.shift();
|
|
203
200
|
}
|
|
204
201
|
|
|
205
|
-
this.options.beforeAddCommand?.(cmd, true);
|
|
202
|
+
const before = this.options.beforeAddCommand?.(cmd, true);
|
|
203
|
+
if (before === false) return;
|
|
204
|
+
|
|
206
205
|
this.undoStack.push(cmd);
|
|
207
206
|
this.options.afterAddCommand?.(cmd, true);
|
|
208
207
|
}
|
package/src/plugins/index.ts
CHANGED
|
@@ -8,6 +8,7 @@ export { GridLine } from './grid-line';
|
|
|
8
8
|
export { History } from './history';
|
|
9
9
|
export { Hull } from './hull';
|
|
10
10
|
export { Legend } from './legend';
|
|
11
|
+
export { Minimap } from './minimap';
|
|
11
12
|
export { Timebar } from './timebar';
|
|
12
13
|
export { Toolbar } from './toolbar';
|
|
13
14
|
export { Tooltip } from './tooltip';
|
|
@@ -23,6 +24,7 @@ export type { GridLineOptions } from './grid-line';
|
|
|
23
24
|
export type { HistoryOptions } from './history';
|
|
24
25
|
export type { HullOptions } from './hull';
|
|
25
26
|
export type { LegendOptions } from './legend';
|
|
27
|
+
export type { MinimapOptions } from './minimap';
|
|
26
28
|
export type { TimebarOptions } from './timebar';
|
|
27
29
|
export type { ToolbarOptions } from './toolbar';
|
|
28
30
|
export type { TooltipOptions } from './tooltip';
|