@antv/g6 5.0.0-beta.29 → 5.0.0-beta.30
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 -3
- package/dist/lib/__tests__/demo/case/index.d.ts +7 -2
- package/dist/lib/__tests__/demo/case/layout-antv-dagre-flow-combo.d.ts +2 -0
- package/dist/lib/__tests__/demo/case/layout-antv-dagre-flow.d.ts +2 -0
- package/dist/lib/__tests__/demo/case/layout-dagre.d.ts +2 -0
- package/dist/lib/__tests__/demo/case/plugin-contextmenu.d.ts +2 -0
- package/dist/lib/__tests__/demo/case/plugin-tooltip.d.ts +2 -0
- package/dist/lib/__tests__/demo/case/plugin-watermark-image.d.ts +2 -0
- package/dist/lib/__tests__/demo/case/plugin-watermark.d.ts +2 -0
- package/dist/lib/__tests__/demo/static/common.d.ts +1 -1
- package/dist/lib/__tests__/demo/static/controller-layout-antv-dagre.d.ts +2 -0
- package/dist/lib/__tests__/setup.d.ts +1 -0
- package/dist/lib/__tests__/unit/layouts/dagre.spec.d.ts +1 -0
- package/dist/lib/__tests__/unit/plugins/plugin-contextmenu.spec.d.ts +1 -0
- package/dist/lib/__tests__/unit/plugins/plugin-watermark.spec.d.ts +1 -0
- package/dist/lib/__tests__/unit/plugins/tooltip.spec.d.ts +1 -0
- package/dist/lib/src/behaviors/drag-element.d.ts +4 -10
- package/dist/lib/src/behaviors/zoom-canvas.d.ts +1 -0
- package/dist/lib/src/elements/nodes/base-node.d.ts +1 -1
- package/dist/lib/src/exports.d.ts +2 -2
- package/dist/lib/src/layouts/index.d.ts +1 -1
- package/dist/lib/src/layouts/types.d.ts +8 -2
- package/dist/lib/src/plugins/contextmenu.d.ts +88 -0
- package/dist/lib/src/plugins/grid-line.d.ts +0 -1
- package/dist/lib/src/plugins/index.d.ts +6 -0
- package/dist/lib/src/plugins/tooltip.d.ts +39 -0
- package/dist/lib/src/plugins/watermark.d.ts +51 -0
- package/dist/lib/src/registry/extension/types.d.ts +5 -3
- package/dist/lib/src/runtime/element.d.ts +2 -2
- package/dist/lib/src/runtime/graph.d.ts +40 -0
- package/dist/lib/src/spec/behavior.d.ts +10 -2
- package/dist/lib/src/spec/plugin.d.ts +10 -2
- package/dist/lib/src/types/event.d.ts +6 -2
- package/dist/lib/src/types/plugin.d.ts +5 -0
- package/dist/lib/src/utils/contextmenu.d.ts +26 -0
- package/dist/lib/src/utils/dom.d.ts +7 -0
- package/dist/lib/src/utils/watermark.d.ts +18 -0
- package/esm/behaviors/drag-element.d.ts +4 -10
- package/esm/behaviors/drag-element.js +17 -20
- package/esm/behaviors/drag-element.js.map +1 -1
- package/esm/behaviors/zoom-canvas.d.ts +1 -0
- package/esm/behaviors/zoom-canvas.js +8 -7
- package/esm/behaviors/zoom-canvas.js.map +1 -1
- package/esm/elements/nodes/base-node.d.ts +1 -1
- package/esm/exports.d.ts +2 -2
- package/esm/layouts/index.d.ts +1 -1
- package/esm/layouts/index.js +1 -1
- package/esm/layouts/index.js.map +1 -1
- package/esm/layouts/types.d.ts +8 -2
- package/esm/plugins/contextmenu.d.ts +88 -0
- package/esm/plugins/contextmenu.js +123 -0
- package/esm/plugins/contextmenu.js.map +1 -0
- package/esm/plugins/grid-line.d.ts +0 -1
- package/esm/plugins/grid-line.js +5 -13
- package/esm/plugins/grid-line.js.map +1 -1
- package/esm/plugins/index.d.ts +6 -0
- package/esm/plugins/index.js +3 -0
- package/esm/plugins/index.js.map +1 -1
- package/esm/plugins/tooltip.d.ts +39 -0
- package/esm/plugins/tooltip.js +232 -0
- package/esm/plugins/tooltip.js.map +1 -0
- package/esm/plugins/watermark.d.ts +51 -0
- package/esm/plugins/watermark.js +53 -0
- package/esm/plugins/watermark.js.map +1 -0
- package/esm/registry/build-in.js +6 -2
- package/esm/registry/build-in.js.map +1 -1
- package/esm/registry/extension/types.d.ts +5 -3
- package/esm/runtime/behavior.js +1 -1
- package/esm/runtime/element.d.ts +2 -2
- package/esm/runtime/graph.d.ts +40 -0
- package/esm/runtime/graph.js +52 -0
- package/esm/runtime/graph.js.map +1 -1
- package/esm/runtime/layout.js +7 -1
- package/esm/runtime/layout.js.map +1 -1
- package/esm/spec/behavior.d.ts +10 -2
- package/esm/spec/plugin.d.ts +10 -2
- package/esm/types/event.d.ts +6 -2
- package/esm/types/plugin.d.ts +5 -0
- package/esm/types/plugin.js +2 -0
- package/esm/types/plugin.js.map +1 -0
- package/esm/utils/contextmenu.d.ts +26 -0
- package/esm/utils/contextmenu.js +45 -0
- package/esm/utils/contextmenu.js.map +1 -0
- package/esm/utils/dom.d.ts +7 -0
- package/esm/utils/dom.js +21 -0
- package/esm/utils/dom.js.map +1 -1
- package/esm/utils/layout.js +1 -1
- package/esm/utils/layout.js.map +1 -1
- package/esm/utils/watermark.d.ts +18 -0
- package/esm/utils/watermark.js +73 -0
- package/esm/utils/watermark.js.map +1 -0
- package/lib/behaviors/drag-element.d.ts +4 -10
- package/lib/behaviors/drag-element.js +16 -19
- package/lib/behaviors/drag-element.js.map +1 -1
- package/lib/behaviors/zoom-canvas.d.ts +1 -0
- package/lib/behaviors/zoom-canvas.js +7 -6
- package/lib/behaviors/zoom-canvas.js.map +1 -1
- package/lib/elements/nodes/base-node.d.ts +1 -1
- package/lib/exports.d.ts +2 -2
- package/lib/layouts/index.d.ts +1 -1
- package/lib/layouts/index.js +2 -1
- package/lib/layouts/index.js.map +1 -1
- package/lib/layouts/types.d.ts +8 -2
- package/lib/plugins/contextmenu.d.ts +88 -0
- package/lib/plugins/contextmenu.js +127 -0
- package/lib/plugins/contextmenu.js.map +1 -0
- package/lib/plugins/grid-line.d.ts +0 -1
- package/lib/plugins/grid-line.js +5 -13
- package/lib/plugins/grid-line.js.map +1 -1
- package/lib/plugins/index.d.ts +6 -0
- package/lib/plugins/index.js +7 -1
- package/lib/plugins/index.js.map +1 -1
- package/lib/plugins/tooltip.d.ts +39 -0
- package/lib/plugins/tooltip.js +236 -0
- package/lib/plugins/tooltip.js.map +1 -0
- package/lib/plugins/watermark.d.ts +51 -0
- package/lib/plugins/watermark.js +57 -0
- package/lib/plugins/watermark.js.map +1 -0
- package/lib/registry/build-in.js +4 -0
- package/lib/registry/build-in.js.map +1 -1
- package/lib/registry/extension/types.d.ts +5 -3
- package/lib/runtime/behavior.js +1 -1
- package/lib/runtime/element.d.ts +2 -2
- package/lib/runtime/graph.d.ts +40 -0
- package/lib/runtime/graph.js +52 -0
- package/lib/runtime/graph.js.map +1 -1
- package/lib/runtime/layout.js +7 -1
- package/lib/runtime/layout.js.map +1 -1
- package/lib/spec/behavior.d.ts +10 -2
- package/lib/spec/plugin.d.ts +10 -2
- package/lib/types/event.d.ts +6 -2
- package/lib/types/plugin.d.ts +5 -0
- package/lib/types/plugin.js +3 -0
- package/lib/types/plugin.js.map +1 -0
- package/lib/utils/contextmenu.d.ts +26 -0
- package/lib/utils/contextmenu.js +49 -0
- package/lib/utils/contextmenu.js.map +1 -0
- package/lib/utils/dom.d.ts +7 -0
- package/lib/utils/dom.js +23 -1
- package/lib/utils/dom.js.map +1 -1
- package/lib/utils/layout.js +1 -1
- package/lib/utils/layout.js.map +1 -1
- package/lib/utils/watermark.d.ts +18 -0
- package/lib/utils/watermark.js +78 -0
- package/lib/utils/watermark.js.map +1 -0
- package/package.json +13 -5
- package/src/behaviors/drag-element.ts +20 -28
- package/src/behaviors/zoom-canvas.ts +12 -7
- package/src/layouts/index.ts +1 -0
- package/src/layouts/types.ts +17 -5
- package/src/plugins/contextmenu.ts +199 -0
- package/src/plugins/grid-line.ts +7 -14
- package/src/plugins/index.ts +6 -0
- package/src/plugins/tooltip.ts +268 -0
- package/src/plugins/watermark.ts +98 -0
- package/src/registry/build-in.ts +6 -1
- package/src/registry/extension/types.ts +5 -3
- package/src/runtime/behavior.ts +1 -1
- package/src/runtime/graph.ts +60 -0
- package/src/runtime/layout.ts +7 -1
- package/src/spec/behavior.ts +11 -2
- package/src/spec/plugin.ts +11 -2
- package/src/types/event.ts +7 -2
- package/src/types/plugin.ts +6 -0
- package/src/utils/contextmenu.ts +62 -0
- package/src/utils/dom.ts +26 -0
- package/src/utils/layout.ts +1 -1
- package/src/utils/watermark.ts +93 -0
- package/dist/lib/__tests__/demo/case/layout-dagre-flow-combo.d.ts +0 -2
- package/dist/lib/__tests__/demo/case/layout-dagre-flow.d.ts +0 -2
- package/dist/lib/__tests__/demo/static/controller-layout-dagre.d.ts +0 -2
- /package/dist/lib/__tests__/unit/{layouts/dagre-flow.spec.d.ts → behaviors/drag-element-bug.spec.d.ts} +0 -0
|
@@ -13,6 +13,8 @@ export * from './element-state';
|
|
|
13
13
|
export * from './element-visibility';
|
|
14
14
|
export * from './element-z-index';
|
|
15
15
|
export * from './graph-event';
|
|
16
|
+
export * from './layout-antv-dagre-flow';
|
|
17
|
+
export * from './layout-antv-dagre-flow-combo';
|
|
16
18
|
export * from './layout-circular-basic';
|
|
17
19
|
export * from './layout-circular-configuration-translate';
|
|
18
20
|
export * from './layout-circular-degree';
|
|
@@ -23,8 +25,7 @@ export * from './layout-compact-box-basic';
|
|
|
23
25
|
export * from './layout-compact-box-left-align';
|
|
24
26
|
export * from './layout-compact-box-top-to-bottom';
|
|
25
27
|
export * from './layout-concentric';
|
|
26
|
-
export * from './layout-dagre
|
|
27
|
-
export * from './layout-dagre-flow-combo';
|
|
28
|
+
export * from './layout-dagre';
|
|
28
29
|
export * from './layout-dendrogram-basic';
|
|
29
30
|
export * from './layout-dendrogram-tb';
|
|
30
31
|
export * from './layout-force';
|
|
@@ -42,6 +43,10 @@ export * from './layout-radial-configuration-translate';
|
|
|
42
43
|
export * from './layout-radial-prevent-overlap';
|
|
43
44
|
export * from './layout-radial-prevent-overlap-unstrict';
|
|
44
45
|
export * from './layout-radial-sort';
|
|
46
|
+
export * from './plugin-contextmenu';
|
|
45
47
|
export * from './plugin-grid-line';
|
|
48
|
+
export * from './plugin-tooltip';
|
|
49
|
+
export * from './plugin-watermark';
|
|
50
|
+
export * from './plugin-watermark-image';
|
|
46
51
|
export * from './theme';
|
|
47
52
|
export * from './viewport-fit';
|
|
@@ -7,10 +7,10 @@ export * from './controller-element';
|
|
|
7
7
|
export * from './controller-element-position';
|
|
8
8
|
export * from './controller-element-visibility';
|
|
9
9
|
export * from './controller-element-z-index';
|
|
10
|
+
export * from './controller-layout-antv-dagre';
|
|
10
11
|
export * from './controller-layout-circular';
|
|
11
12
|
export * from './controller-layout-compact-box';
|
|
12
13
|
export * from './controller-layout-d3-force';
|
|
13
|
-
export * from './controller-layout-dagre';
|
|
14
14
|
export * from './controller-layout-dendrogram';
|
|
15
15
|
export * from './controller-layout-force';
|
|
16
16
|
export * from './controller-layout-grid';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -17,12 +17,6 @@ export interface DragElementOptions extends BaseBehaviorOptions, PrefixObject<Ba
|
|
|
17
17
|
* <en/> Whether to enable the function of dragging the node
|
|
18
18
|
*/
|
|
19
19
|
enable?: boolean | ((event: BehaviorEvent<FederatedMouseEvent> | BehaviorEvent<KeyboardEvent>) => boolean);
|
|
20
|
-
/**
|
|
21
|
-
* <zh/> 支持拖拽的元素类型
|
|
22
|
-
*
|
|
23
|
-
* <en/> Supported element types for dragging
|
|
24
|
-
*/
|
|
25
|
-
draggableElement: ('node' | 'combo')[];
|
|
26
20
|
/**
|
|
27
21
|
* <zh/> 拖拽操作效果
|
|
28
22
|
* - link: 将拖拽元素置入为目标元素的子元素
|
|
@@ -64,7 +58,7 @@ export interface DragElementOptions extends BaseBehaviorOptions, PrefixObject<Ba
|
|
|
64
58
|
*
|
|
65
59
|
* <en/> Edges will not be hidden when using the drag shadow
|
|
66
60
|
*/
|
|
67
|
-
|
|
61
|
+
hideEdge?: 'none' | 'all' | EdgeDirection;
|
|
68
62
|
/**
|
|
69
63
|
* <zh/> 是否启用幽灵节点,即用一个图形代替节点跟随鼠标移动
|
|
70
64
|
*
|
|
@@ -76,17 +70,17 @@ export interface DragElementOptions extends BaseBehaviorOptions, PrefixObject<Ba
|
|
|
76
70
|
*
|
|
77
71
|
* <en/> Callback when dragging is completed
|
|
78
72
|
*/
|
|
79
|
-
|
|
73
|
+
onFinish?: (ids: ID[]) => void;
|
|
80
74
|
}
|
|
81
75
|
export declare class DragElement extends BaseBehavior<DragElementOptions> {
|
|
82
76
|
static defaultOptions: Partial<DragElementOptions>;
|
|
83
77
|
private enable;
|
|
78
|
+
private enableElements;
|
|
84
79
|
private target;
|
|
85
80
|
private shadow?;
|
|
86
81
|
private shadowOrigin;
|
|
87
82
|
private hiddenEdges;
|
|
88
83
|
private get animation();
|
|
89
|
-
private get element();
|
|
90
84
|
constructor(context: RuntimeContext, options: DragElementOptions);
|
|
91
85
|
update(options: Partial<DragElementOptions>): void;
|
|
92
86
|
private bindEvents;
|
|
@@ -100,7 +94,7 @@ export declare class DragElement extends BaseBehavior<DragElementOptions> {
|
|
|
100
94
|
private moveShadow;
|
|
101
95
|
private createShadow;
|
|
102
96
|
private showEdges;
|
|
103
|
-
private
|
|
97
|
+
private hideEdge;
|
|
104
98
|
private unbindEvents;
|
|
105
99
|
destroy(): void;
|
|
106
100
|
}
|
|
@@ -60,6 +60,7 @@ export declare class ZoomCanvas extends BaseBehavior<ZoomCanvasOptions> {
|
|
|
60
60
|
* <en/> Zoom canvas
|
|
61
61
|
* @param value - <zh/> 缩放值, > 0 放大, < 0 缩小 | <en/> Zoom value, > 0 zoom in, < 0 zoom out
|
|
62
62
|
* @param event - <zh/> 事件对象 | <en/> Event object
|
|
63
|
+
* @param animation - <zh/> 缩放动画配置 | <en/> Zoom animation configuration
|
|
63
64
|
*/
|
|
64
65
|
private zoom;
|
|
65
66
|
private onReset;
|
|
@@ -30,7 +30,7 @@ export declare abstract class BaseNode<S extends BaseNodeStyleProps = any> exten
|
|
|
30
30
|
type: string;
|
|
31
31
|
static defaultStyleProps: Partial<BaseNodeStyleProps>;
|
|
32
32
|
constructor(options: DisplayObjectConfig<S>);
|
|
33
|
-
protected getSize(attributes?: Required<S>): import("
|
|
33
|
+
protected getSize(attributes?: Required<S>): import("../../types").Vector3;
|
|
34
34
|
protected getKeyStyle(attributes: Required<S>): any;
|
|
35
35
|
protected getLabelStyle(attributes: Required<S>): false | LabelStyleProps;
|
|
36
36
|
protected getHaloStyle(attributes: Required<S>): any;
|
|
@@ -18,7 +18,7 @@ declare const Utils: {
|
|
|
18
18
|
treeToGraphData: typeof treeToGraphData;
|
|
19
19
|
};
|
|
20
20
|
declare const Theme: {
|
|
21
|
-
dark: import("
|
|
22
|
-
light: import("
|
|
21
|
+
dark: import("./themes/types").Theme;
|
|
22
|
+
light: import("./themes/types").Theme;
|
|
23
23
|
};
|
|
24
24
|
export { Theme, Utils };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/// <reference types="@/src/layouts/hierarchy" />
|
|
2
2
|
export { compactBox, dendrogram, indented, mindmap } from '@antv/hierarchy';
|
|
3
|
-
export { CircularLayout, ComboCombinedLayout, ConcentricLayout, D3ForceLayout, DagreLayout, ForceAtlas2Layout, ForceLayout, FruchtermanLayout, GridLayout, MDSLayout, RadialLayout, RandomLayout, } from '@antv/layout';
|
|
3
|
+
export { AntVDagreLayout, CircularLayout, ComboCombinedLayout, ConcentricLayout, D3ForceLayout, DagreLayout, ForceAtlas2Layout, ForceLayout, FruchtermanLayout, GridLayout, MDSLayout, RadialLayout, RandomLayout, } from '@antv/layout';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { CircularLayoutOptions, ConcentricLayoutOptions, D3ForceLayoutOptions, ForceAtlas2LayoutOptions, ForceLayoutOptions, FruchtermanLayoutOptions, GridLayoutOptions, MDSLayoutOptions, RadialLayoutOptions, RandomLayoutOptions } from '@antv/layout';
|
|
1
|
+
import type { AntVDagreLayoutOptions, CircularLayoutOptions, ConcentricLayoutOptions, D3ForceLayoutOptions, DagreLayoutOptions, ForceAtlas2LayoutOptions, ForceLayoutOptions, FruchtermanLayoutOptions, GridLayoutOptions, MDSLayoutOptions, RadialLayoutOptions, RandomLayoutOptions } from '@antv/layout';
|
|
2
2
|
import type { NodeData } from '../spec/data';
|
|
3
|
-
export type BuiltInLayoutOptions =
|
|
3
|
+
export type BuiltInLayoutOptions = AntVDagreLayout | CircularLayout | ConcentricLayout | D3ForceLayout | DagreLayout | ForceAtlas2 | ForceLayout | FruchtermanLayout | GridLayout | MDSLayout | RadialLayout | RandomLayout;
|
|
4
4
|
export interface BaseLayoutOptions extends AnimationOptions, WebWorkerLayoutOptions, PresetLayoutOptions {
|
|
5
5
|
type: string;
|
|
6
6
|
/**
|
|
@@ -43,6 +43,12 @@ interface ForceLayout extends BaseLayoutOptions, ForceLayoutOptions {
|
|
|
43
43
|
interface ForceAtlas2 extends BaseLayoutOptions, ForceAtlas2LayoutOptions {
|
|
44
44
|
type: 'forceAtlas2';
|
|
45
45
|
}
|
|
46
|
+
interface AntVDagreLayout extends BaseLayoutOptions, AntVDagreLayoutOptions {
|
|
47
|
+
type: 'antv-dagre';
|
|
48
|
+
}
|
|
49
|
+
interface DagreLayout extends BaseLayoutOptions, DagreLayoutOptions {
|
|
50
|
+
type: 'dagre';
|
|
51
|
+
}
|
|
46
52
|
export interface PresetLayoutOptions {
|
|
47
53
|
presetLayout?: BaseLayoutOptions;
|
|
48
54
|
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import type { RuntimeContext } from '../runtime/types';
|
|
2
|
+
import type { ElementEvent } from '../types/event';
|
|
3
|
+
import type { Item } from '../utils/contextmenu';
|
|
4
|
+
import type { BasePluginOptions } from './base-plugin';
|
|
5
|
+
import { BasePlugin } from './base-plugin';
|
|
6
|
+
/**
|
|
7
|
+
* <zh/> 右键菜单插件的配置项。
|
|
8
|
+
* <en/> The configuration item of the right-click menu plugin.
|
|
9
|
+
*/
|
|
10
|
+
export type ContextmenuOptions = BasePluginOptions & {
|
|
11
|
+
/**
|
|
12
|
+
* <zh/> 给菜单的 DOM 追加的 classname,便于自定义样式。默认是包含 `g6-contextmenu`。
|
|
13
|
+
* <en/> The classname appended to the menu DOM for custom styles. The default is `g6-contextmenu`.
|
|
14
|
+
*/
|
|
15
|
+
className?: string;
|
|
16
|
+
/**
|
|
17
|
+
* <zh/> 如何触发右键菜单,可以是 'click' 或者 'contextmenu',默认是 'contextmenu'。
|
|
18
|
+
* <en/> How to trigger the context menu, default is 'contextmenu'.
|
|
19
|
+
*/
|
|
20
|
+
trigger?: 'click' | 'contextmenu';
|
|
21
|
+
/**
|
|
22
|
+
* <zh/> 菜单显式 X、Y 方向的偏移量,默认是 [4, 4]。
|
|
23
|
+
* <en/> The offset X, y direction of the menu, default is [4, 4].
|
|
24
|
+
*/
|
|
25
|
+
offset?: [number, number];
|
|
26
|
+
/**
|
|
27
|
+
* <zh/> 当菜单被点击后,出发的回调方法。
|
|
28
|
+
* <en/> The callback method triggered when the menu is clicked.
|
|
29
|
+
*/
|
|
30
|
+
onClick?: (v: string, target: HTMLElement) => void;
|
|
31
|
+
/**
|
|
32
|
+
* <zh/> 返回菜单的项目列表,支持 `Promise` 类型的返回值。是 `getContent` 的快捷配置。
|
|
33
|
+
* <en/> Return the list of menu items, support the `Promise` type return value. It is a shortcut configuration of `getContent`.
|
|
34
|
+
*/
|
|
35
|
+
getItems?: (event: ElementEvent) => Item[] | Promise<Item[]>;
|
|
36
|
+
/**
|
|
37
|
+
* <zh/> 返回菜单的内容,支持 `Promise` 类型的返回值,也可以使用 `getItems` 来快捷配置。
|
|
38
|
+
* <en/> Return the content of menu, support the `Promise` type return value, you can also use `getItems` for shortcut configuration.
|
|
39
|
+
*/
|
|
40
|
+
getContent?: (event: ElementEvent) => HTMLElement | string | Promise<HTMLElement | string>;
|
|
41
|
+
/**
|
|
42
|
+
* <zh/> Loading 时候的菜单内容,用于 getContent 返回 Promise 的时候。
|
|
43
|
+
* <en/> The menu content when loading is used when getContent returns a Promise.
|
|
44
|
+
*/
|
|
45
|
+
loadingContent: HTMLElement | string;
|
|
46
|
+
/**
|
|
47
|
+
* <zh/> 插件是否可用,通过参数来判断是否支持右键菜单,默认全部可用。
|
|
48
|
+
* <en/> Whether the plugin is available, determine whether the right-click menu is supported through parameters, The default is all available.
|
|
49
|
+
*/
|
|
50
|
+
enable?: boolean | ((event: ElementEvent) => boolean);
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* <zh/> 支持处理事件,并显示右键菜单,在菜单点击之后,可以触发相应的事件。
|
|
54
|
+
* <en/> Support processing events and displaying right-click menus.
|
|
55
|
+
* After clicking the menu, you can trigger the corresponding event.
|
|
56
|
+
*/
|
|
57
|
+
export declare class Contextmenu extends BasePlugin<ContextmenuOptions> {
|
|
58
|
+
static defaultOptions: Partial<ContextmenuOptions>;
|
|
59
|
+
private $element;
|
|
60
|
+
constructor(context: RuntimeContext, options: ContextmenuOptions);
|
|
61
|
+
/**
|
|
62
|
+
* <zh/> 根据传入的元素,显示右键菜单。
|
|
63
|
+
* <en/> Display the right-click menu based on the incoming element.
|
|
64
|
+
* @param e - 事件
|
|
65
|
+
*/
|
|
66
|
+
showContextmenu(e: ElementEvent): Promise<void>;
|
|
67
|
+
/**
|
|
68
|
+
* <zh/> 隐藏右键菜单。
|
|
69
|
+
* <en/> Hide the right-click menu.
|
|
70
|
+
*/
|
|
71
|
+
hideContextmenu(): void;
|
|
72
|
+
/**
|
|
73
|
+
* <zh/> 更新右键菜单的配置项。
|
|
74
|
+
* <en/> Update the configuration of the right-click menu.
|
|
75
|
+
* @param options - 配置项
|
|
76
|
+
*/
|
|
77
|
+
update(options: Partial<ContextmenuOptions>): void;
|
|
78
|
+
/**
|
|
79
|
+
* <zh/> 销毁右键菜单。
|
|
80
|
+
* <en/> Destroy the right-click menu.
|
|
81
|
+
*/
|
|
82
|
+
destroy(): void;
|
|
83
|
+
private getDOMContent;
|
|
84
|
+
private bindEvents;
|
|
85
|
+
private unbindEvents;
|
|
86
|
+
private onTriggerEvent;
|
|
87
|
+
private onMenuItemClick;
|
|
88
|
+
}
|
|
@@ -23,7 +23,6 @@ export declare class GridLine extends BasePlugin<GridLineOptions> {
|
|
|
23
23
|
constructor(context: RuntimeContext, options: GridLineOptions);
|
|
24
24
|
update(options: Partial<GridLineOptions>): void;
|
|
25
25
|
private bindEvents;
|
|
26
|
-
private render;
|
|
27
26
|
private updateStyle;
|
|
28
27
|
private updateOffset;
|
|
29
28
|
private onTransform;
|
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
export { BasePlugin } from './base-plugin';
|
|
2
|
+
export { Contextmenu } from './contextmenu';
|
|
2
3
|
export { GridLine } from './grid-line';
|
|
4
|
+
export { Tooltip } from './tooltip';
|
|
5
|
+
export { Watermark } from './watermark';
|
|
3
6
|
export type { BasePluginOptions } from './base-plugin';
|
|
7
|
+
export type { ContextmenuOptions } from './contextmenu';
|
|
4
8
|
export type { GridLineOptions } from './grid-line';
|
|
9
|
+
export type { TooltipOptions } from './tooltip';
|
|
10
|
+
export type { WatermarkOptions } from './watermark';
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { TooltipStyleProps } from '@antv/component';
|
|
2
|
+
import type { RuntimeContext } from '../runtime/types';
|
|
3
|
+
import type { ElementDatum, ElementEvent, ElementType } from '../types';
|
|
4
|
+
import type { BasePluginOptions } from './base-plugin';
|
|
5
|
+
import { BasePlugin } from './base-plugin';
|
|
6
|
+
export interface TooltipOptions extends BasePluginOptions, Pick<TooltipStyleProps, 'position' | 'offset' | 'enterable' | 'style' | 'container'> {
|
|
7
|
+
/** <zh/> 触发方式 | <en/> Event type that triggers display of tooltip */
|
|
8
|
+
trigger?: 'hover' | 'click';
|
|
9
|
+
/** <zh/> 自定义内容 | <en/> Function for getting tooltip content */
|
|
10
|
+
getContent?: (evt: ElementEvent, items: ElementDatum[]) => HTMLElement | string;
|
|
11
|
+
/** <zh/> 是否启用 | <en/> Is enable */
|
|
12
|
+
enable?: boolean | ((evt: ElementEvent) => boolean);
|
|
13
|
+
}
|
|
14
|
+
export declare class Tooltip extends BasePlugin<TooltipOptions> {
|
|
15
|
+
static defaultOptions: Partial<TooltipOptions>;
|
|
16
|
+
private currentTarget;
|
|
17
|
+
private tooltipElement;
|
|
18
|
+
private container;
|
|
19
|
+
constructor(context: RuntimeContext, options: TooltipOptions);
|
|
20
|
+
getEvents(): {
|
|
21
|
+
[key: string]: Function;
|
|
22
|
+
};
|
|
23
|
+
update(options: Partial<TooltipOptions>): void;
|
|
24
|
+
private render;
|
|
25
|
+
private unbundEvents;
|
|
26
|
+
private bindEvents;
|
|
27
|
+
private isEnable;
|
|
28
|
+
onClick: (e: ElementEvent) => void;
|
|
29
|
+
onPointerMove: (e: ElementEvent) => void;
|
|
30
|
+
onPointerLeave: (e: ElementEvent) => void;
|
|
31
|
+
onCanvasMove: (e: ElementEvent) => void;
|
|
32
|
+
private onPointerEnter;
|
|
33
|
+
showTooltipById: (id: string, elementType?: ElementType) => void;
|
|
34
|
+
private getItems;
|
|
35
|
+
showTooltip: (e: ElementEvent) => void;
|
|
36
|
+
hideTooltip: (e?: ElementEvent) => void;
|
|
37
|
+
private initTooltip;
|
|
38
|
+
destroy(): void;
|
|
39
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { RuntimeContext } from '../runtime/types';
|
|
2
|
+
import type { BasePluginOptions } from './base-plugin';
|
|
3
|
+
import { BasePlugin } from './base-plugin';
|
|
4
|
+
export type WatermarkOptions = BasePluginOptions & {
|
|
5
|
+
/** 单独一个水印的大小,这个水印最终会用来填充整个大小,所以 repeat 后的间距大小,通过这个 width height 设置 */
|
|
6
|
+
width?: number;
|
|
7
|
+
height?: number;
|
|
8
|
+
/** 透明度 */
|
|
9
|
+
opacity?: number;
|
|
10
|
+
/** 旋转角度 */
|
|
11
|
+
rotate?: number;
|
|
12
|
+
/** 图片地址,如果有值,则使用,否则使用文本 */
|
|
13
|
+
imageURL?: string;
|
|
14
|
+
/** 水印文本 */
|
|
15
|
+
text?: string;
|
|
16
|
+
/** 文本水印的文本样式 */
|
|
17
|
+
textFill: string;
|
|
18
|
+
textFontSize: number;
|
|
19
|
+
textFontFamily: string;
|
|
20
|
+
textFontWeight: string;
|
|
21
|
+
textFontVariant: string;
|
|
22
|
+
textAlign: CanvasTextAlign;
|
|
23
|
+
textBaseline: CanvasTextBaseline;
|
|
24
|
+
/** 背景的 CSS 样式 */
|
|
25
|
+
backgroundAttachment: string;
|
|
26
|
+
backgroundBlendMode: string;
|
|
27
|
+
backgroundClip: string;
|
|
28
|
+
backgroundColor: string;
|
|
29
|
+
backgroundImage: string;
|
|
30
|
+
backgroundOrigin: string;
|
|
31
|
+
backgroundPosition: string;
|
|
32
|
+
backgroundPositionX: string;
|
|
33
|
+
backgroundPositionY: string;
|
|
34
|
+
backgroundRepeat: string;
|
|
35
|
+
backgroundSize: string;
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* <zh/> 支持使用文本和图片作为水印,实现原理是在 Graph 容器的 div 上加上 background-image 属性,然后就可以通过 css 来控制水印的位置和样式。
|
|
39
|
+
* 对于文本,会使用隐藏 canvas 转成图片的方式来实现。
|
|
40
|
+
* <en/> Support using text and images as watermarks.
|
|
41
|
+
* The principle is to add the background-image property to the div of the Graph container,
|
|
42
|
+
* and then you can control the position and style of the watermark through css. For text,
|
|
43
|
+
* it will be converted to an image using a hidden canvas.
|
|
44
|
+
*/
|
|
45
|
+
export declare class Watermark extends BasePlugin<WatermarkOptions> {
|
|
46
|
+
static defaultOptions: Partial<WatermarkOptions>;
|
|
47
|
+
private $element;
|
|
48
|
+
constructor(context: RuntimeContext, options: WatermarkOptions);
|
|
49
|
+
update(options: Partial<WatermarkOptions>): Promise<void>;
|
|
50
|
+
destroy(): void;
|
|
51
|
+
}
|
|
@@ -14,7 +14,7 @@ export declare class ElementController {
|
|
|
14
14
|
private emit;
|
|
15
15
|
private forEachElementData;
|
|
16
16
|
private getTheme;
|
|
17
|
-
getThemeStyle(elementType: ElementType): import("
|
|
17
|
+
getThemeStyle(elementType: ElementType): import("../spec/element/node").NodeStyle | import("../spec/element/edge").EdgeStyle | import("../spec/element/combo").ComboStyle;
|
|
18
18
|
getThemeStateStyle(elementType: ElementType, states: State[]): any;
|
|
19
19
|
private paletteStyle;
|
|
20
20
|
private computePaletteStyle;
|
|
@@ -57,7 +57,7 @@ export declare class ElementController {
|
|
|
57
57
|
private computeStyle;
|
|
58
58
|
getElement<T extends DisplayObject = BaseShape<any>>(id: ID): T | undefined;
|
|
59
59
|
getNodes(): Node[];
|
|
60
|
-
getEdges(): import("
|
|
60
|
+
getEdges(): import("..").BaseEdge[];
|
|
61
61
|
getCombos(): Combo[];
|
|
62
62
|
private getAnimation;
|
|
63
63
|
private getAnimationExecutor;
|
|
@@ -2,6 +2,8 @@ import EventEmitter from '@antv/event-emitter';
|
|
|
2
2
|
import type { AABB, BaseStyleProps, DataURLOptions } from '@antv/g';
|
|
3
3
|
import type { ID } from '@antv/graphlib';
|
|
4
4
|
import type { BehaviorOptions, ComboData, ComboOptions, EdgeData, EdgeOptions, G6Spec, GraphData, LayoutOptions, NodeData, NodeOptions, PluginOptions, ThemeOptions } from '../spec';
|
|
5
|
+
import { UpdateBehaviorOption } from '../spec/behavior';
|
|
6
|
+
import { UpdatePluginOption } from '../spec/plugin';
|
|
5
7
|
import type { CallableValue, DataID, EdgeDirection, ElementType, FitViewOptions, NodeLikeData, PartialEdgeData, PartialGraphData, PartialNodeLikeData, Point, Position, State, ViewportAnimationEffectTiming } from '../types';
|
|
6
8
|
import { Canvas } from './canvas';
|
|
7
9
|
import type { HierarchyKey } from './data';
|
|
@@ -42,9 +44,47 @@ export declare class Graph extends EventEmitter {
|
|
|
42
44
|
setTheme(theme: CallableValue<ThemeOptions>): void;
|
|
43
45
|
setLayout(layout: CallableValue<LayoutOptions>): void;
|
|
44
46
|
getLayout(): LayoutOptions;
|
|
47
|
+
/**
|
|
48
|
+
* <zh/> 设置交互
|
|
49
|
+
*
|
|
50
|
+
* <en/> Set behaviors
|
|
51
|
+
* @param behaviors - <zh/> 交互配置 | <en/> behavior configuration
|
|
52
|
+
*/
|
|
45
53
|
setBehaviors(behaviors: CallableValue<BehaviorOptions>): void;
|
|
54
|
+
/**
|
|
55
|
+
* <zh/> 更新交互
|
|
56
|
+
*
|
|
57
|
+
* <en/> Update behavior
|
|
58
|
+
* @param behavior - <zh/> 交互配置 | <en/> behavior configuration
|
|
59
|
+
*/
|
|
60
|
+
updateBehavior(behavior: UpdateBehaviorOption): void;
|
|
61
|
+
/**
|
|
62
|
+
* <zh/> 获取交互
|
|
63
|
+
*
|
|
64
|
+
* <en/> Get behaviors
|
|
65
|
+
* @returns <zh/> 交互配置 | <en/> behavior configuration
|
|
66
|
+
*/
|
|
46
67
|
getBehaviors(): BehaviorOptions;
|
|
68
|
+
/**
|
|
69
|
+
* <zh/> 设置插件
|
|
70
|
+
*
|
|
71
|
+
* <en/> Set plugins
|
|
72
|
+
* @param plugins - <zh/> 插件配置 | <en/> plugin configuration
|
|
73
|
+
*/
|
|
47
74
|
setPlugins(plugins: CallableValue<PluginOptions>): void;
|
|
75
|
+
/**
|
|
76
|
+
* <zh/> 更新插件
|
|
77
|
+
*
|
|
78
|
+
* <en/> Update plugin
|
|
79
|
+
* @param plugin - <zh/> 插件配置 | <en/> plugin configuration
|
|
80
|
+
*/
|
|
81
|
+
updatePlugin(plugin: UpdatePluginOption): void;
|
|
82
|
+
/**
|
|
83
|
+
* <zh/> 获取插件
|
|
84
|
+
*
|
|
85
|
+
* <en/> Get plugins
|
|
86
|
+
* @returns <zh/> 插件配置 | <en/> plugin configuration
|
|
87
|
+
*/
|
|
48
88
|
getPlugins(): PluginOptions;
|
|
49
89
|
getData(): GraphData;
|
|
50
90
|
getNodeData(): NodeData[];
|
|
@@ -1,4 +1,12 @@
|
|
|
1
1
|
import type { BuiltInBehaviorOptions } from '../behaviors/types';
|
|
2
|
-
import type { ExtensionOptions
|
|
2
|
+
import type { ExtensionOptions } from '../registry/extension/types';
|
|
3
3
|
export type BehaviorOptions = ExtensionOptions<BuiltInBehaviorOptions>;
|
|
4
|
-
export
|
|
4
|
+
export interface UpdateBehaviorOption {
|
|
5
|
+
key: string;
|
|
6
|
+
[key: string]: any;
|
|
7
|
+
}
|
|
8
|
+
export interface CustomBehaviorOption {
|
|
9
|
+
type?: string;
|
|
10
|
+
key?: string;
|
|
11
|
+
[key: string]: any;
|
|
12
|
+
}
|
|
@@ -1,4 +1,12 @@
|
|
|
1
1
|
import type { BuiltInPluginOptions } from '../plugins/types';
|
|
2
|
-
import type { ExtensionOptions
|
|
2
|
+
import type { ExtensionOptions } from '../registry/extension/types';
|
|
3
3
|
export type PluginOptions = ExtensionOptions<BuiltInPluginOptions>;
|
|
4
|
-
export
|
|
4
|
+
export interface UpdatePluginOption {
|
|
5
|
+
key: string;
|
|
6
|
+
[key: string]: any;
|
|
7
|
+
}
|
|
8
|
+
export interface CustomPluginOption {
|
|
9
|
+
type?: string;
|
|
10
|
+
key?: string;
|
|
11
|
+
[key: string]: any;
|
|
12
|
+
}
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
import type { Document } from '@antv/g';
|
|
2
|
-
import {
|
|
1
|
+
import type { Document, FederatedMouseEvent } from '@antv/g';
|
|
2
|
+
import type { BehaviorEvent } from './behavior';
|
|
3
|
+
import { Edge, ElementType, Node } from './element';
|
|
3
4
|
export type Listener = (event: any) => void;
|
|
4
5
|
export type Target = Document | Node | Edge | null;
|
|
6
|
+
export interface ElementEvent extends BehaviorEvent<FederatedMouseEvent> {
|
|
7
|
+
targetType: ElementType;
|
|
8
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* <zh/> 右键菜单显示项目。
|
|
3
|
+
* <en/> The item of the right-click menu.
|
|
4
|
+
*/
|
|
5
|
+
export type Item = {
|
|
6
|
+
/**
|
|
7
|
+
* <zh/> 菜单项显示的名字。
|
|
8
|
+
* <en/> The name of the menu item.
|
|
9
|
+
*/
|
|
10
|
+
name: string;
|
|
11
|
+
/**
|
|
12
|
+
* <zh/> 菜单项对应的值。
|
|
13
|
+
* <en/> The value corresponding to the menu item.
|
|
14
|
+
*/
|
|
15
|
+
value: string;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Get the content of the right-click menu.
|
|
19
|
+
* @param items - context menu items
|
|
20
|
+
* @returns HTML string
|
|
21
|
+
*/
|
|
22
|
+
export declare function getContentFromItems(items: Item[]): string;
|
|
23
|
+
/**
|
|
24
|
+
* Style of the right-click menu, same with `tooltip`.
|
|
25
|
+
*/
|
|
26
|
+
export declare const CONTEXTMENU_CSS = "\n .g6-contextmenu {\n font-size: 12px;\n background-color: rgba(255, 255, 255, 0.96);\n border-radius: 4px;\n overflow: hidden;\n box-shadow: rgba(0, 0, 0, 0.12) 0px 6px 12px 0px;\n transition: visibility 0.2s cubic-bezier(0.23, 1, 0.32, 1) 0s, left 0.4s cubic-bezier(0.23, 1, 0.32, 1) 0s, top 0.4s cubic-bezier(0.23, 1, 0.32, 1) 0s;\n }\n\n .g6-contextmenu-ul {\n max-width: 256px;\n min-width: 96px;\n list-style: none;\n padding: 0;\n margin: 0;\n }\n\n .g6-contextmenu-li {\n padding: 8px 12px;\n cursor: pointer;\n user-select: none;\n }\n\n .g6-contextmenu-li:hover {\n background-color: #f5f5f5;\n cursor: pointer;\n }\n";
|
|
@@ -4,3 +4,10 @@
|
|
|
4
4
|
* @returns Size of Graph
|
|
5
5
|
*/
|
|
6
6
|
export declare function sizeOf(container: HTMLElement): [number, number];
|
|
7
|
+
/**
|
|
8
|
+
* Create a plugin DOM element.
|
|
9
|
+
* @param type - plugin type
|
|
10
|
+
* @param cover - cover the container
|
|
11
|
+
* @returns plugin DOM element
|
|
12
|
+
*/
|
|
13
|
+
export declare function createPluginContainer(type: string, cover?: boolean): HTMLDivElement;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 从文本获取水印的 base64
|
|
3
|
+
* @param width - width
|
|
4
|
+
* @param height - height
|
|
5
|
+
* @param text - 样式
|
|
6
|
+
* @param style - 样式
|
|
7
|
+
* @returns 水印的 base64
|
|
8
|
+
*/
|
|
9
|
+
export declare function getTextWateramrk(width: number, height: number, text: string, style: any): Promise<string>;
|
|
10
|
+
/**
|
|
11
|
+
* Get the image base64 of the watermark.
|
|
12
|
+
* @param width - width
|
|
13
|
+
* @param height - height
|
|
14
|
+
* @param imageURL - image URL
|
|
15
|
+
* @param style - 样式
|
|
16
|
+
* @returns 水印的 base64
|
|
17
|
+
*/
|
|
18
|
+
export declare function getImageWatermark(width: number, height: number, imageURL: string, style: any): Promise<unknown>;
|