@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.
Files changed (172) hide show
  1. package/dist/g6.min.js +2 -3
  2. package/dist/lib/__tests__/demo/case/index.d.ts +7 -2
  3. package/dist/lib/__tests__/demo/case/layout-antv-dagre-flow-combo.d.ts +2 -0
  4. package/dist/lib/__tests__/demo/case/layout-antv-dagre-flow.d.ts +2 -0
  5. package/dist/lib/__tests__/demo/case/layout-dagre.d.ts +2 -0
  6. package/dist/lib/__tests__/demo/case/plugin-contextmenu.d.ts +2 -0
  7. package/dist/lib/__tests__/demo/case/plugin-tooltip.d.ts +2 -0
  8. package/dist/lib/__tests__/demo/case/plugin-watermark-image.d.ts +2 -0
  9. package/dist/lib/__tests__/demo/case/plugin-watermark.d.ts +2 -0
  10. package/dist/lib/__tests__/demo/static/common.d.ts +1 -1
  11. package/dist/lib/__tests__/demo/static/controller-layout-antv-dagre.d.ts +2 -0
  12. package/dist/lib/__tests__/setup.d.ts +1 -0
  13. package/dist/lib/__tests__/unit/layouts/dagre.spec.d.ts +1 -0
  14. package/dist/lib/__tests__/unit/plugins/plugin-contextmenu.spec.d.ts +1 -0
  15. package/dist/lib/__tests__/unit/plugins/plugin-watermark.spec.d.ts +1 -0
  16. package/dist/lib/__tests__/unit/plugins/tooltip.spec.d.ts +1 -0
  17. package/dist/lib/src/behaviors/drag-element.d.ts +4 -10
  18. package/dist/lib/src/behaviors/zoom-canvas.d.ts +1 -0
  19. package/dist/lib/src/elements/nodes/base-node.d.ts +1 -1
  20. package/dist/lib/src/exports.d.ts +2 -2
  21. package/dist/lib/src/layouts/index.d.ts +1 -1
  22. package/dist/lib/src/layouts/types.d.ts +8 -2
  23. package/dist/lib/src/plugins/contextmenu.d.ts +88 -0
  24. package/dist/lib/src/plugins/grid-line.d.ts +0 -1
  25. package/dist/lib/src/plugins/index.d.ts +6 -0
  26. package/dist/lib/src/plugins/tooltip.d.ts +39 -0
  27. package/dist/lib/src/plugins/watermark.d.ts +51 -0
  28. package/dist/lib/src/registry/extension/types.d.ts +5 -3
  29. package/dist/lib/src/runtime/element.d.ts +2 -2
  30. package/dist/lib/src/runtime/graph.d.ts +40 -0
  31. package/dist/lib/src/spec/behavior.d.ts +10 -2
  32. package/dist/lib/src/spec/plugin.d.ts +10 -2
  33. package/dist/lib/src/types/event.d.ts +6 -2
  34. package/dist/lib/src/types/plugin.d.ts +5 -0
  35. package/dist/lib/src/utils/contextmenu.d.ts +26 -0
  36. package/dist/lib/src/utils/dom.d.ts +7 -0
  37. package/dist/lib/src/utils/watermark.d.ts +18 -0
  38. package/esm/behaviors/drag-element.d.ts +4 -10
  39. package/esm/behaviors/drag-element.js +17 -20
  40. package/esm/behaviors/drag-element.js.map +1 -1
  41. package/esm/behaviors/zoom-canvas.d.ts +1 -0
  42. package/esm/behaviors/zoom-canvas.js +8 -7
  43. package/esm/behaviors/zoom-canvas.js.map +1 -1
  44. package/esm/elements/nodes/base-node.d.ts +1 -1
  45. package/esm/exports.d.ts +2 -2
  46. package/esm/layouts/index.d.ts +1 -1
  47. package/esm/layouts/index.js +1 -1
  48. package/esm/layouts/index.js.map +1 -1
  49. package/esm/layouts/types.d.ts +8 -2
  50. package/esm/plugins/contextmenu.d.ts +88 -0
  51. package/esm/plugins/contextmenu.js +123 -0
  52. package/esm/plugins/contextmenu.js.map +1 -0
  53. package/esm/plugins/grid-line.d.ts +0 -1
  54. package/esm/plugins/grid-line.js +5 -13
  55. package/esm/plugins/grid-line.js.map +1 -1
  56. package/esm/plugins/index.d.ts +6 -0
  57. package/esm/plugins/index.js +3 -0
  58. package/esm/plugins/index.js.map +1 -1
  59. package/esm/plugins/tooltip.d.ts +39 -0
  60. package/esm/plugins/tooltip.js +232 -0
  61. package/esm/plugins/tooltip.js.map +1 -0
  62. package/esm/plugins/watermark.d.ts +51 -0
  63. package/esm/plugins/watermark.js +53 -0
  64. package/esm/plugins/watermark.js.map +1 -0
  65. package/esm/registry/build-in.js +6 -2
  66. package/esm/registry/build-in.js.map +1 -1
  67. package/esm/registry/extension/types.d.ts +5 -3
  68. package/esm/runtime/behavior.js +1 -1
  69. package/esm/runtime/element.d.ts +2 -2
  70. package/esm/runtime/graph.d.ts +40 -0
  71. package/esm/runtime/graph.js +52 -0
  72. package/esm/runtime/graph.js.map +1 -1
  73. package/esm/runtime/layout.js +7 -1
  74. package/esm/runtime/layout.js.map +1 -1
  75. package/esm/spec/behavior.d.ts +10 -2
  76. package/esm/spec/plugin.d.ts +10 -2
  77. package/esm/types/event.d.ts +6 -2
  78. package/esm/types/plugin.d.ts +5 -0
  79. package/esm/types/plugin.js +2 -0
  80. package/esm/types/plugin.js.map +1 -0
  81. package/esm/utils/contextmenu.d.ts +26 -0
  82. package/esm/utils/contextmenu.js +45 -0
  83. package/esm/utils/contextmenu.js.map +1 -0
  84. package/esm/utils/dom.d.ts +7 -0
  85. package/esm/utils/dom.js +21 -0
  86. package/esm/utils/dom.js.map +1 -1
  87. package/esm/utils/layout.js +1 -1
  88. package/esm/utils/layout.js.map +1 -1
  89. package/esm/utils/watermark.d.ts +18 -0
  90. package/esm/utils/watermark.js +73 -0
  91. package/esm/utils/watermark.js.map +1 -0
  92. package/lib/behaviors/drag-element.d.ts +4 -10
  93. package/lib/behaviors/drag-element.js +16 -19
  94. package/lib/behaviors/drag-element.js.map +1 -1
  95. package/lib/behaviors/zoom-canvas.d.ts +1 -0
  96. package/lib/behaviors/zoom-canvas.js +7 -6
  97. package/lib/behaviors/zoom-canvas.js.map +1 -1
  98. package/lib/elements/nodes/base-node.d.ts +1 -1
  99. package/lib/exports.d.ts +2 -2
  100. package/lib/layouts/index.d.ts +1 -1
  101. package/lib/layouts/index.js +2 -1
  102. package/lib/layouts/index.js.map +1 -1
  103. package/lib/layouts/types.d.ts +8 -2
  104. package/lib/plugins/contextmenu.d.ts +88 -0
  105. package/lib/plugins/contextmenu.js +127 -0
  106. package/lib/plugins/contextmenu.js.map +1 -0
  107. package/lib/plugins/grid-line.d.ts +0 -1
  108. package/lib/plugins/grid-line.js +5 -13
  109. package/lib/plugins/grid-line.js.map +1 -1
  110. package/lib/plugins/index.d.ts +6 -0
  111. package/lib/plugins/index.js +7 -1
  112. package/lib/plugins/index.js.map +1 -1
  113. package/lib/plugins/tooltip.d.ts +39 -0
  114. package/lib/plugins/tooltip.js +236 -0
  115. package/lib/plugins/tooltip.js.map +1 -0
  116. package/lib/plugins/watermark.d.ts +51 -0
  117. package/lib/plugins/watermark.js +57 -0
  118. package/lib/plugins/watermark.js.map +1 -0
  119. package/lib/registry/build-in.js +4 -0
  120. package/lib/registry/build-in.js.map +1 -1
  121. package/lib/registry/extension/types.d.ts +5 -3
  122. package/lib/runtime/behavior.js +1 -1
  123. package/lib/runtime/element.d.ts +2 -2
  124. package/lib/runtime/graph.d.ts +40 -0
  125. package/lib/runtime/graph.js +52 -0
  126. package/lib/runtime/graph.js.map +1 -1
  127. package/lib/runtime/layout.js +7 -1
  128. package/lib/runtime/layout.js.map +1 -1
  129. package/lib/spec/behavior.d.ts +10 -2
  130. package/lib/spec/plugin.d.ts +10 -2
  131. package/lib/types/event.d.ts +6 -2
  132. package/lib/types/plugin.d.ts +5 -0
  133. package/lib/types/plugin.js +3 -0
  134. package/lib/types/plugin.js.map +1 -0
  135. package/lib/utils/contextmenu.d.ts +26 -0
  136. package/lib/utils/contextmenu.js +49 -0
  137. package/lib/utils/contextmenu.js.map +1 -0
  138. package/lib/utils/dom.d.ts +7 -0
  139. package/lib/utils/dom.js +23 -1
  140. package/lib/utils/dom.js.map +1 -1
  141. package/lib/utils/layout.js +1 -1
  142. package/lib/utils/layout.js.map +1 -1
  143. package/lib/utils/watermark.d.ts +18 -0
  144. package/lib/utils/watermark.js +78 -0
  145. package/lib/utils/watermark.js.map +1 -0
  146. package/package.json +13 -5
  147. package/src/behaviors/drag-element.ts +20 -28
  148. package/src/behaviors/zoom-canvas.ts +12 -7
  149. package/src/layouts/index.ts +1 -0
  150. package/src/layouts/types.ts +17 -5
  151. package/src/plugins/contextmenu.ts +199 -0
  152. package/src/plugins/grid-line.ts +7 -14
  153. package/src/plugins/index.ts +6 -0
  154. package/src/plugins/tooltip.ts +268 -0
  155. package/src/plugins/watermark.ts +98 -0
  156. package/src/registry/build-in.ts +6 -1
  157. package/src/registry/extension/types.ts +5 -3
  158. package/src/runtime/behavior.ts +1 -1
  159. package/src/runtime/graph.ts +60 -0
  160. package/src/runtime/layout.ts +7 -1
  161. package/src/spec/behavior.ts +11 -2
  162. package/src/spec/plugin.ts +11 -2
  163. package/src/types/event.ts +7 -2
  164. package/src/types/plugin.ts +6 -0
  165. package/src/utils/contextmenu.ts +62 -0
  166. package/src/utils/dom.ts +26 -0
  167. package/src/utils/layout.ts +1 -1
  168. package/src/utils/watermark.ts +93 -0
  169. package/dist/lib/__tests__/demo/case/layout-dagre-flow-combo.d.ts +0 -2
  170. package/dist/lib/__tests__/demo/case/layout-dagre-flow.d.ts +0 -2
  171. package/dist/lib/__tests__/demo/static/controller-layout-dagre.d.ts +0 -2
  172. /package/dist/lib/__tests__/unit/{layouts/dagre-flow.spec.d.ts → behaviors/drag-element-bug.spec.d.ts} +0 -0
@@ -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,236 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Tooltip = void 0;
4
+ const component_1 = require("@antv/component");
5
+ const util_1 = require("@antv/util");
6
+ const base_plugin_1 = require("./base-plugin");
7
+ class Tooltip extends base_plugin_1.BasePlugin {
8
+ static defaultOptions = {
9
+ trigger: 'hover',
10
+ position: 'top-right',
11
+ enterable: false,
12
+ enable: true,
13
+ style: {
14
+ '.tooltip': {
15
+ visibility: 'hidden',
16
+ },
17
+ },
18
+ };
19
+ currentTarget = null;
20
+ tooltipElement = null;
21
+ container = null;
22
+ constructor(context, options) {
23
+ super(context, Object.assign({}, Tooltip.defaultOptions, options));
24
+ this.render();
25
+ this.bindEvents();
26
+ }
27
+ getEvents() {
28
+ if (this.options.trigger === 'click') {
29
+ return {
30
+ 'node:click': this.onClick,
31
+ 'edge:click': this.onClick,
32
+ 'combo:click': this.onClick,
33
+ 'canvas:click': this.onPointerLeave,
34
+ afterremoveitem: this.onPointerLeave,
35
+ contextmenu: this.onPointerLeave,
36
+ drag: this.onPointerLeave,
37
+ };
38
+ }
39
+ return {
40
+ 'node:pointerenter': this.onPointerEnter,
41
+ 'node:pointermove': this.onPointerMove,
42
+ 'canvas:pointermove': this.onCanvasMove,
43
+ 'edge:pointerenter': this.onPointerEnter,
44
+ 'edge:pointermove': this.onPointerMove,
45
+ 'combo:pointerenter': this.onPointerEnter,
46
+ 'combo:pointermove': this.onPointerMove,
47
+ contextmenu: this.onPointerLeave,
48
+ 'node:drag': this.onPointerLeave,
49
+ };
50
+ }
51
+ update(options) {
52
+ this.unbundEvents();
53
+ super.update(options);
54
+ if (this.tooltipElement) {
55
+ this.container?.removeChild(this.tooltipElement.HTMLTooltipElement);
56
+ }
57
+ this.tooltipElement = this.initTooltip();
58
+ this.bindEvents();
59
+ }
60
+ render() {
61
+ const { canvas } = this.context;
62
+ const $container = canvas.getContainer();
63
+ if (!$container)
64
+ return;
65
+ this.container = $container;
66
+ this.tooltipElement = this.initTooltip();
67
+ }
68
+ unbundEvents() {
69
+ const { graph } = this.context;
70
+ /** The previous event binding needs to be removed when updating the trigger. */
71
+ const events = this.getEvents();
72
+ Object.keys(events).forEach((eventName) => {
73
+ graph.off(eventName, events[eventName]);
74
+ });
75
+ }
76
+ bindEvents() {
77
+ const { graph } = this.context;
78
+ const events = this.getEvents();
79
+ Object.keys(events).forEach((eventName) => {
80
+ graph.on(eventName, events[eventName]);
81
+ });
82
+ }
83
+ isEnable = (e) => {
84
+ const { enable } = this.options;
85
+ if (typeof enable === 'function') {
86
+ return enable(e);
87
+ }
88
+ return enable;
89
+ };
90
+ onClick = (e) => {
91
+ const { target: { id }, } = e;
92
+ // click the same item twice, tooltip will be hidden
93
+ if (this.currentTarget === id) {
94
+ this.currentTarget = null;
95
+ this.hideTooltip(e);
96
+ }
97
+ else {
98
+ this.currentTarget = id;
99
+ this.showTooltip(e);
100
+ }
101
+ };
102
+ onPointerMove = (e) => {
103
+ const { target } = e;
104
+ if (!this.currentTarget || target.id === this.currentTarget) {
105
+ return;
106
+ }
107
+ this.showTooltip(e);
108
+ };
109
+ onPointerLeave = (e) => {
110
+ this.hideTooltip(e);
111
+ this.currentTarget = null;
112
+ };
113
+ onCanvasMove = (e) => {
114
+ this.hideTooltip(e);
115
+ this.currentTarget = null;
116
+ };
117
+ onPointerEnter = (e) => {
118
+ this.showTooltip(e);
119
+ };
120
+ showTooltipById = (id, elementType = 'node') => {
121
+ const e = {
122
+ targetType: elementType,
123
+ target: { id },
124
+ };
125
+ this.showTooltip(e);
126
+ };
127
+ getItems = (id, targetType) => {
128
+ const { model } = this.context;
129
+ switch (targetType) {
130
+ case 'node':
131
+ return model.getNodeData([id]);
132
+ case 'edge':
133
+ return model.getEdgeData([id]);
134
+ case 'combo':
135
+ return model.getComboData([id]);
136
+ default:
137
+ return [];
138
+ }
139
+ };
140
+ showTooltip = (e) => {
141
+ const { targetType, client, target: { id, attributes = { color: '#1883FF' } }, } = e;
142
+ if (!this.tooltipElement || !this.isEnable(e))
143
+ return;
144
+ const { getContent } = this.options;
145
+ const { color, stroke } = attributes;
146
+ this.currentTarget = id;
147
+ const items = this.getItems(id, targetType);
148
+ let x;
149
+ let y;
150
+ if (client) {
151
+ x = client.x;
152
+ y = client.y;
153
+ }
154
+ else {
155
+ const style = (0, util_1.get)(items, '0.style', { x: 0, y: 0 });
156
+ x = style.x;
157
+ y = style.y;
158
+ }
159
+ let tooltipContent = {};
160
+ if (getContent) {
161
+ tooltipContent.content = getContent(e, items);
162
+ }
163
+ else {
164
+ tooltipContent = {
165
+ title: targetType,
166
+ data: items.map((item) => {
167
+ return {
168
+ name: 'ID',
169
+ value: item.id || `${item.source} -> ${item.target}`,
170
+ color: color || stroke,
171
+ };
172
+ }),
173
+ };
174
+ }
175
+ this.tooltipElement.update({
176
+ x,
177
+ y,
178
+ style: {
179
+ '.tooltip': {
180
+ visibility: 'visible',
181
+ },
182
+ },
183
+ ...tooltipContent,
184
+ });
185
+ };
186
+ hideTooltip = (e) => {
187
+ // if e is undefined, hide the tooltip, external call
188
+ if (!e) {
189
+ this.tooltipElement?.hide();
190
+ return;
191
+ }
192
+ if (!this.tooltipElement || !this.isEnable(e))
193
+ return;
194
+ const { client: { x, y }, } = e;
195
+ this.tooltipElement.hide(x, y);
196
+ };
197
+ initTooltip = () => {
198
+ const { canvas } = this.context;
199
+ const { center } = canvas.getBounds();
200
+ const $container = canvas.getContainer();
201
+ const { top, left } = $container.getBoundingClientRect();
202
+ const { style, position, enterable, container = { x: -left, y: -top } } = this.options;
203
+ const [x, y] = center;
204
+ const [width, height] = canvas.getSize();
205
+ const tooltipElement = new component_1.Tooltip({
206
+ className: 'tooltip',
207
+ style: {
208
+ x,
209
+ y,
210
+ container,
211
+ bounding: {
212
+ x: 0,
213
+ y: 0,
214
+ width,
215
+ height,
216
+ },
217
+ position,
218
+ enterable,
219
+ title: '',
220
+ offset: [10, 10],
221
+ style,
222
+ },
223
+ });
224
+ this.container?.appendChild(tooltipElement.HTMLTooltipElement);
225
+ return tooltipElement;
226
+ };
227
+ destroy() {
228
+ this.unbundEvents();
229
+ if (this.tooltipElement) {
230
+ this.container?.removeChild(this.tooltipElement.HTMLTooltipElement);
231
+ }
232
+ super.destroy();
233
+ }
234
+ }
235
+ exports.Tooltip = Tooltip;
236
+ //# sourceMappingURL=tooltip.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tooltip.js","sourceRoot":"src/","sources":["plugins/tooltip.ts"],"names":[],"mappings":";;;AACA,+CAA8D;AAC9D,qCAAiC;AAIjC,+CAA2C;AAa3C,MAAa,OAAQ,SAAQ,wBAA0B;IACrD,MAAM,CAAC,cAAc,GAA4B;QAC/C,OAAO,EAAE,OAAO;QAChB,QAAQ,EAAE,WAAW;QACrB,SAAS,EAAE,KAAK;QAChB,MAAM,EAAE,IAAI;QACZ,KAAK,EAAE;YACL,UAAU,EAAE;gBACV,UAAU,EAAE,QAAQ;aACrB;SACF;KACF,CAAC;IACM,aAAa,GAAkB,IAAI,CAAC;IACpC,cAAc,GAA4B,IAAI,CAAC;I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AAC,cAAc,CAAC,kBAAkB,CAAC,CAAC;QAC/D,OAAO,cAAc,CAAC;IACxB,CAAC,CAAC;IAEK,OAAO;QACZ,IAAI,CAAC,YAAY,EAAE,CAAC;QACpB,IAAI,IAAI,CAAC,cAAc,EAAE,CAAC;YACxB,IAAI,CAAC,SAAS,EAAE,WAAW,CAAC,IAAI,CAAC,cAAc,CAAC,kBAAkB,CAAC,CAAC;QACtE,CAAC;QACD,KAAK,CAAC,OAAO,EAAE,CAAC;IAClB,CAAC;;AAvPH,0BAwPC"}
@@ -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
+ }
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Watermark = void 0;
4
+ const dom_1 = require("../utils/dom");
5
+ const watermark_1 = require("../utils/watermark");
6
+ const base_plugin_1 = require("./base-plugin");
7
+ /**
8
+ * <zh/> 支持使用文本和图片作为水印,实现原理是在 Graph 容器的 div 上加上 background-image 属性,然后就可以通过 css 来控制水印的位置和样式。
9
+ * 对于文本,会使用隐藏 canvas 转成图片的方式来实现。
10
+ * <en/> Support using text and images as watermarks.
11
+ * The principle is to add the background-image property to the div of the Graph container,
12
+ * and then you can control the position and style of the watermark through css. For text,
13
+ * it will be converted to an image using a hidden canvas.
14
+ */
15
+ class Watermark extends base_plugin_1.BasePlugin {
16
+ static defaultOptions = {
17
+ width: 200,
18
+ height: 100,
19
+ opacity: 0.2,
20
+ rotate: Math.PI / 12,
21
+ textFill: '#000',
22
+ textFontSize: 16,
23
+ textAlign: 'center',
24
+ textBaseline: 'middle',
25
+ backgroundRepeat: 'repeat',
26
+ };
27
+ $element = (0, dom_1.createPluginContainer)('watermark');
28
+ constructor(context, options) {
29
+ super(context, Object.assign({}, Watermark.defaultOptions, options));
30
+ const $container = this.context.canvas.getContainer();
31
+ $container.appendChild(this.$element);
32
+ this.update(options);
33
+ }
34
+ async update(options) {
35
+ super.update(options);
36
+ const { width, height, text, imageURL, ...rest } = this.options;
37
+ // Set the background style.
38
+ Object.keys(rest).forEach((key) => {
39
+ if (key.startsWith('background')) {
40
+ // @ts-expect-error ignore
41
+ this.$element.style[key] = options[key];
42
+ }
43
+ });
44
+ // Set the background image.
45
+ const base64 = imageURL
46
+ ? await (0, watermark_1.getImageWatermark)(width, height, imageURL, rest)
47
+ : await (0, watermark_1.getTextWateramrk)(width, height, text, rest);
48
+ this.$element.style.backgroundImage = `url(${base64})`;
49
+ }
50
+ destroy() {
51
+ super.destroy();
52
+ // Remove the background dom.
53
+ this.$element.remove();
54
+ }
55
+ }
56
+ exports.Watermark = Watermark;
57
+ //# sourceMappingURL=watermark.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"watermark.js","sourceRoot":"src/","sources":["plugins/watermark.ts"],"names":[],"mappings":";;;AACA,sCAAqD;AACrD,kDAAyE;AAEzE,+CAA2C;AAoC3C;;;;;;;GAOG;AACH,MAAa,SAAU,SAAQ,wBAA4B;IACzD,MAAM,CAAC,cAAc,GAA8B;QACjD,KAAK,EAAE,GAAG;QACV,MAAM,EAAE,GAAG;QACX,OAAO,EAAE,GAAG;QACZ,MAAM,EAAE,IAAI,CAAC,EAAE,GAAG,EAAE;QACpB,QAAQ,EAAE,MAAM;QAChB,YAAY,EAAE,EAAE;QAChB,SAAS,EAAE,QAAQ;QACnB,YAAY,EAAE,QAAQ;QACtB,gBAAgB,EAAE,QAAQ;KAC3B,CAAC;IAEM,QAAQ,GAAgB,IAAA,2BAAqB,EAAC,WAAW,CAAC,CAAC;IAEnE,YAAY,OAAuB,EAAE,OAAyB;QAC5D,KAAK,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,SAAS,CAAC,cAAc,EAAE,OAAO,CAAC,CAAC,CAAC;QAErE,MAAM,UAAU,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,YAAY,EAAE,CAAC;QACtD,UAAW,CAAC,WAAW,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAEvC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IACvB,CAAC;IAEM,KAAK,CAAC,MAAM,CAAC,OAAkC;QACpD,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QAEtB,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,IAAI,EAAE,GAAG,IAAI,CAAC,OAAO,CAAC;QAEhE,4BAA4B;QAC5B,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE;YAChC,IAAI,GAAG,CAAC,UAAU,CAAC,YAAY,CAAC,EAAE,CAAC;gBACjC,0BAA0B;gBAC1B,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;YAC1C,CAAC;QACH,CAAC,CAAC,CAAC;QAEH,4BAA4B;QAC5B,MAAM,MAAM,GAAG,QAAQ;YACrB,CAAC,CAAC,MAAM,IAAA,6BAAiB,EAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,CAAC;YACxD,CAAC,CAAC,MAAM,IAAA,4BAAgB,EAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;QACtD,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,eAAe,GAAG,OAAO,MAAM,GAAG,CAAC;IACzD,CAAC;IAEM,OAAO;QACZ,KAAK,CAAC,OAAO,EAAE,CAAC;QAChB,6BAA6B;QAC7B,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC;IACzB,CAAC;;AAhDH,8BAiDC"}
@@ -37,6 +37,7 @@ exports.BUILT_IN_EXTENSIONS = {
37
37
  'cubic-vertical': elements_1.CubicVertical,
38
38
  },
39
39
  layout: {
40
+ 'antv-dagre': layouts_1.AntVDagreLayout,
40
41
  'combo-combined': layouts_1.ComboCombinedLayout,
41
42
  'compact-box': layouts_1.compactBox,
42
43
  'force-atlas2': layouts_1.ForceAtlas2Layout,
@@ -75,6 +76,9 @@ exports.BUILT_IN_EXTENSIONS = {
75
76
  },
76
77
  plugin: {
77
78
  'grid-line': plugins_1.GridLine,
79
+ watermark: plugins_1.Watermark,
80
+ tooltip: plugins_1.Tooltip,
81
+ contextmenu: plugins_1.Contextmenu,
78
82
  },
79
83
  };
80
84
  //# sourceMappingURL=build-in.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"build-in.js","sourceRoot":"src/","sources":["registry/build-in.ts"],"names":[],"mappings":";;;AAAA,8CAAqE;AACrE,4CAAmF;AACnF,0CAgBqB;AACrB,wCAiBoB;AACpB,0CAA+D;AAC/D,wCAAsC;AACtC,sCAAwC;AAGxC;;;GAGG;AACU,QAAA,mBAAmB,GAAsB;IACpD,SAAS,EAAE;QACT,IAAI,EAAJ,iBAAI;QACJ,SAAS,EAAT,sBAAS;QACT,uBAAuB,EAAE,gCAAmB;KAC7C;IACD,QAAQ,EAAE;QACR,aAAa,EAAE,sBAAU;QACzB,aAAa,EAAE,sBAAU;QACzB,cAAc,EAAE,uBAAW;QAC3B,iBAAiB,EAAE,0BAAc;KAClC;IACD,KAAK,EAAE;QACL,MAAM,EAAE,sBAAW;QACnB,IAAI,EAAE,oBAAS;KAChB;IACD,IAAI,EAAE;QACJ,KAAK,EAAE,gBAAK;QACZ,IAAI,EAAE,eAAI;QACV,QAAQ,EAAE,mBAAQ;QAClB,SAAS,EAAE,oBAAS;QACpB,kBAAkB,EAAE,0BAAe;QACnC,gBAAgB,EAAE,wBAAa;KAChC;IACD,MAAM,EAAE;QACN,gBAAgB,EAAE,6BAAmB;QACrC,aAAa,EAAE,oBAAU;QACzB,cAAc,EAAE,2BAAiB;QACjC,QAAQ,EAAE,wBAAc;QACxB,UAAU,EAAE,0BAAgB;QAC5B,OAAO,EAAE,uBAAa;QACtB,KAAK,EAAE,qBAAW;QAClB,UAAU,EAAV,oBAAU;QACV,KAAK,EAAE,qBAAW;QAClB,WAAW,EAAE,2BAAiB;QAC9B,IAAI,EAAE,oBAAU;QAChB,QAA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Ae;QACnC,gBAAgB,EAAE,wBAAa;KAChC;IACD,MAAM,EAAE;QACN,YAAY,EAAE,yBAAe;QAC7B,gBAAgB,EAAE,6BAAmB;QACrC,aAAa,EAAE,oBAAU;QACzB,cAAc,EAAE,2BAAiB;QACjC,QAAQ,EAAE,wBAAc;QACxB,UAAU,EAAE,0BAAgB;QAC5B,OAAO,EAAE,uBAAa;QACtB,KAAK,EAAE,qBAAW;QAClB,UAAU,EAAV,oBAAU;QACV,KAAK,EAAE,qBAAW;QAClB,WAAW,EAAE,2BAAiB;QAC9B,IAAI,EAAE,oBAAU;QAChB,QAAQ,EAAR,kBAAQ;QACR,GAAG,EAAE,mBAAS;QACd,OAAO,EAAP,iBAAO;QACP,MAAM,EAAE,sBAAY;QACpB,MAAM,EAAE,sBAAY;KACrB;IACD,IAAI,EAAE;QACJ,MAAM,EAAE,iBAAM;QACd,OAAO,EAAE,kBAAO;QAChB,KAAK,EAAE,gBAAK;QACZ,IAAI,EAAE,eAAI;QACV,IAAI,EAAE,eAAI;QACV,QAAQ,EAAE,mBAAQ;QAClB,OAAO,EAAE,kBAAO;KACjB;IACD,OAAO,EAAE;QACP,QAAQ,EAAR,mBAAQ;QACR,OAAO,EAAP,kBAAO;QACP,MAAM,EAAN,iBAAM;QACN,KAAK,EAAL,gBAAK;KACN;IACD,KAAK,EAAE;QACL,IAAI,EAAJ,aAAI;QACJ,KAAK,EAAL,cAAK;KACN;IACD,MAAM,EAAE;QACN,WAAW,EAAE,kBAAQ;QACrB,SAAS,EAAE,mBAAS;QACpB,OAAO,EAAE,iBAAO;QAChB,WAAW,EAAE,qBAAW;KACzB;CACF,CAAC"}
@@ -1,8 +1,10 @@
1
- type ExtensionMetaOptions = {
1
+ interface ExtensionMetaOptions {
2
2
  type: string;
3
3
  key: string;
4
- };
5
- type CustomExtensionOptions = Record<string, any>;
4
+ }
5
+ interface CustomExtensionOptions {
6
+ [key: string]: any;
7
+ }
6
8
  /**
7
9
  * <zh/> 扩展配置项
8
10
  *
@@ -78,7 +78,7 @@ class BehaviorController extends extension_1.ExtensionController {
78
78
  graph.emit(`${targetType}:${constants_1.CanvasEvent.DBLCLICK}`, stdEvent);
79
79
  graph.emit(constants_1.CanvasEvent.DBLCLICK, stdEvent);
80
80
  }
81
- // 右键菜单 / ContextMenu
81
+ // 右键菜单 / Contextmenu
82
82
  if (type === constants_1.CanvasEvent.POINTER_DOWN && button === 2) {
83
83
  const contextMenuEvent = {
84
84
  ...stdEvent,
@@ -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("src/spec/element/node").NodeStyle | import("src/spec/element/edge").EdgeStyle | import("src/spec/element/combo").ComboStyle;
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("src").BaseEdge[];
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[];
@@ -140,17 +140,69 @@ class Graph extends event_emitter_1.default {
140
140
  getLayout() {
141
141
  return this.options.layout;
142
142
  }
143
+ /**
144
+ * <zh/> 设置交互
145
+ *
146
+ * <en/> Set behaviors
147
+ * @param behaviors - <zh/> 交互配置 | <en/> behavior configuration
148
+ */
143
149
  setBehaviors(behaviors) {
144
150
  this.options.behaviors = (0, util_1.isFunction)(behaviors) ? behaviors(this.getBehaviors()) : behaviors;
145
151
  this.context.behavior?.setBehaviors(this.options.behaviors);
146
152
  }
153
+ /**
154
+ * <zh/> 更新交互
155
+ *
156
+ * <en/> Update behavior
157
+ * @param behavior - <zh/> 交互配置 | <en/> behavior configuration
158
+ */
159
+ updateBehavior(behavior) {
160
+ this.setBehaviors((behaviors) => behaviors.map((_behavior) => {
161
+ if ((0, util_1.isObject)(_behavior) && _behavior.key === behavior.key) {
162
+ return { ..._behavior, ...behavior };
163
+ }
164
+ return _behavior;
165
+ }));
166
+ }
167
+ /**
168
+ * <zh/> 获取交互
169
+ *
170
+ * <en/> Get behaviors
171
+ * @returns <zh/> 交互配置 | <en/> behavior configuration
172
+ */
147
173
  getBehaviors() {
148
174
  return this.options.behaviors || [];
149
175
  }
176
+ /**
177
+ * <zh/> 设置插件
178
+ *
179
+ * <en/> Set plugins
180
+ * @param plugins - <zh/> 插件配置 | <en/> plugin configuration
181
+ */
150
182
  setPlugins(plugins) {
151
183
  this.options.plugins = (0, util_1.isFunction)(plugins) ? plugins(this.getPlugins()) : plugins;
152
184
  this.context.plugin?.setPlugins(this.options.plugins);
153
185
  }
186
+ /**
187
+ * <zh/> 更新插件
188
+ *
189
+ * <en/> Update plugin
190
+ * @param plugin - <zh/> 插件配置 | <en/> plugin configuration
191
+ */
192
+ updatePlugin(plugin) {
193
+ this.setPlugins((plugins) => plugins.map((_plugin) => {
194
+ if ((0, util_1.isObject)(_plugin) && _plugin.key === plugin.key) {
195
+ return { ..._plugin, ...plugin };
196
+ }
197
+ return _plugin;
198
+ }));
199
+ }
200
+ /**
201
+ * <zh/> 获取插件
202
+ *
203
+ * <en/> Get plugins
204
+ * @returns <zh/> 插件配置 | <en/> plugin configuration
205
+ */
154
206
  getPlugins() {
155
207
  return this.options.plugins || [];
156
208
  }