@antv/infographic 0.2.13 → 0.2.14
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/infographic.min.js +123 -116
- package/dist/infographic.min.js.map +1 -1
- package/esm/editor/commands/UpdateOptions.d.ts +4 -4
- package/esm/editor/commands/UpdateOptions.js +6 -3
- package/esm/editor/editor.d.ts +5 -1
- package/esm/editor/editor.js +16 -5
- package/esm/editor/index.d.ts +1 -0
- package/esm/editor/index.js +1 -0
- package/esm/editor/interactions/brush-select.d.ts +0 -1
- package/esm/editor/interactions/brush-select.js +2 -10
- package/esm/editor/interactions/drag-canvas.d.ts +35 -0
- package/esm/editor/interactions/drag-canvas.js +161 -0
- package/esm/editor/interactions/drag-element.js +4 -3
- package/esm/editor/interactions/index.d.ts +1 -0
- package/esm/editor/interactions/index.js +1 -0
- package/esm/editor/interactions/zoom-wheel.d.ts +9 -0
- package/esm/editor/interactions/zoom-wheel.js +32 -15
- package/esm/editor/managers/index.d.ts +1 -0
- package/esm/editor/managers/index.js +1 -0
- package/esm/editor/managers/state.d.ts +4 -2
- package/esm/editor/managers/state.js +14 -13
- package/esm/editor/managers/sync-registry.d.ts +15 -0
- package/esm/editor/managers/sync-registry.js +51 -0
- package/esm/editor/plugins/{edit-bar/components → components}/button.js +1 -1
- package/esm/editor/plugins/{edit-bar/components → components}/color-picker.js +1 -1
- package/esm/editor/plugins/{edit-bar/components → components}/icons.d.ts +1 -0
- package/esm/editor/plugins/{edit-bar/components → components}/icons.js +1 -0
- package/esm/editor/plugins/{edit-bar/components → components}/popover.js +2 -2
- package/esm/editor/plugins/{edit-bar/components → components}/select.js +1 -1
- package/esm/editor/plugins/core-sync.d.ts +8 -0
- package/esm/editor/plugins/core-sync.js +30 -0
- package/esm/editor/plugins/edit-bar/edit-items/align-elements.js +1 -1
- package/esm/editor/plugins/edit-bar/edit-items/font-align.js +1 -1
- package/esm/editor/plugins/edit-bar/edit-items/font-color.js +1 -1
- package/esm/editor/plugins/edit-bar/edit-items/font-family.js +1 -1
- package/esm/editor/plugins/edit-bar/edit-items/font-size.js +1 -1
- package/esm/editor/plugins/edit-bar/edit-items/icon-color.js +1 -1
- package/esm/editor/plugins/edit-bar/index.d.ts +2 -2
- package/esm/editor/plugins/edit-bar/index.js +1 -1
- package/esm/editor/plugins/index.d.ts +2 -0
- package/esm/editor/plugins/index.js +2 -0
- package/esm/editor/plugins/reset-viewbox.d.ts +33 -0
- package/esm/editor/plugins/reset-viewbox.js +186 -0
- package/esm/editor/types/editor.d.ts +13 -0
- package/esm/editor/types/index.d.ts +1 -0
- package/esm/editor/types/interaction.d.ts +9 -0
- package/esm/editor/types/state.d.ts +4 -2
- package/esm/editor/types/sync.d.ts +26 -0
- package/esm/editor/types/sync.js +1 -0
- package/esm/editor/utils/data.js +3 -1
- package/esm/editor/utils/event.d.ts +1 -0
- package/esm/editor/utils/event.js +8 -0
- package/esm/editor/utils/index.d.ts +1 -0
- package/esm/editor/utils/index.js +1 -0
- package/esm/editor/utils/object.d.ts +15 -0
- package/esm/editor/utils/object.js +70 -0
- package/esm/index.d.ts +4 -3
- package/esm/index.js +3 -2
- package/esm/options/types.d.ts +1 -0
- package/esm/runtime/options.js +7 -2
- package/esm/templates/built-in.js +24 -0
- package/esm/utils/measure-text.js +9 -6
- package/esm/utils/padding.d.ts +1 -0
- package/esm/utils/padding.js +6 -2
- package/esm/version.d.ts +1 -1
- package/esm/version.js +1 -1
- package/lib/editor/commands/UpdateOptions.d.ts +4 -4
- package/lib/editor/commands/UpdateOptions.js +6 -3
- package/lib/editor/editor.d.ts +5 -1
- package/lib/editor/editor.js +16 -5
- package/lib/editor/index.d.ts +1 -0
- package/lib/editor/index.js +1 -0
- package/lib/editor/interactions/brush-select.d.ts +0 -1
- package/lib/editor/interactions/brush-select.js +1 -9
- package/lib/editor/interactions/drag-canvas.d.ts +35 -0
- package/lib/editor/interactions/drag-canvas.js +165 -0
- package/lib/editor/interactions/drag-element.js +4 -3
- package/lib/editor/interactions/index.d.ts +1 -0
- package/lib/editor/interactions/index.js +3 -1
- package/lib/editor/interactions/zoom-wheel.d.ts +9 -0
- package/lib/editor/interactions/zoom-wheel.js +32 -15
- package/lib/editor/managers/index.d.ts +1 -0
- package/lib/editor/managers/index.js +1 -0
- package/lib/editor/managers/state.d.ts +4 -2
- package/lib/editor/managers/state.js +12 -11
- package/lib/editor/managers/sync-registry.d.ts +15 -0
- package/lib/editor/managers/sync-registry.js +55 -0
- package/lib/editor/plugins/{edit-bar/components → components}/button.js +1 -1
- package/lib/editor/plugins/{edit-bar/components → components}/color-picker.js +1 -1
- package/lib/editor/plugins/{edit-bar/components → components}/icons.d.ts +1 -0
- package/lib/editor/plugins/{edit-bar/components → components}/icons.js +2 -1
- package/lib/editor/plugins/{edit-bar/components → components}/popover.js +2 -2
- package/lib/editor/plugins/{edit-bar/components → components}/select.js +1 -1
- package/lib/editor/plugins/core-sync.d.ts +8 -0
- package/lib/editor/plugins/core-sync.js +34 -0
- package/lib/editor/plugins/edit-bar/edit-items/align-elements.js +1 -1
- package/lib/editor/plugins/edit-bar/edit-items/font-align.js +1 -1
- package/lib/editor/plugins/edit-bar/edit-items/font-color.js +1 -1
- package/lib/editor/plugins/edit-bar/edit-items/font-family.js +1 -1
- package/lib/editor/plugins/edit-bar/edit-items/font-size.js +1 -1
- package/lib/editor/plugins/edit-bar/edit-items/icon-color.js +1 -1
- package/lib/editor/plugins/edit-bar/index.d.ts +2 -2
- package/lib/editor/plugins/edit-bar/index.js +1 -1
- package/lib/editor/plugins/index.d.ts +2 -0
- package/lib/editor/plugins/index.js +5 -1
- package/lib/editor/plugins/reset-viewbox.d.ts +33 -0
- package/lib/editor/plugins/reset-viewbox.js +190 -0
- package/lib/editor/types/editor.d.ts +13 -0
- package/lib/editor/types/index.d.ts +1 -0
- package/lib/editor/types/interaction.d.ts +9 -0
- package/lib/editor/types/state.d.ts +4 -2
- package/lib/editor/types/sync.d.ts +26 -0
- package/lib/editor/types/sync.js +2 -0
- package/lib/editor/utils/data.js +3 -1
- package/lib/editor/utils/event.d.ts +1 -0
- package/lib/editor/utils/event.js +9 -0
- package/lib/editor/utils/index.d.ts +1 -0
- package/lib/editor/utils/index.js +1 -0
- package/lib/editor/utils/object.d.ts +15 -0
- package/lib/editor/utils/object.js +73 -0
- package/lib/index.d.ts +4 -3
- package/lib/index.js +9 -2
- package/lib/options/types.d.ts +1 -0
- package/lib/runtime/options.js +6 -1
- package/lib/templates/built-in.js +24 -0
- package/lib/utils/measure-text.js +9 -6
- package/lib/utils/padding.d.ts +1 -0
- package/lib/utils/padding.js +7 -2
- package/lib/version.d.ts +1 -1
- package/lib/version.js +1 -1
- package/package.json +1 -1
- package/src/editor/commands/UpdateOptions.ts +11 -6
- package/src/editor/editor.ts +26 -5
- package/src/editor/index.ts +1 -0
- package/src/editor/interactions/brush-select.ts +2 -8
- package/src/editor/interactions/drag-canvas.ts +203 -0
- package/src/editor/interactions/drag-element.ts +5 -4
- package/src/editor/interactions/index.ts +1 -0
- package/src/editor/interactions/zoom-wheel.ts +49 -13
- package/src/editor/managers/index.ts +1 -0
- package/src/editor/managers/state.ts +21 -21
- package/src/editor/managers/sync-registry.ts +65 -0
- package/src/editor/plugins/{edit-bar/components → components}/button.ts +1 -1
- package/src/editor/plugins/{edit-bar/components → components}/color-picker.ts +1 -1
- package/src/editor/plugins/{edit-bar/components → components}/icons.ts +4 -0
- package/src/editor/plugins/{edit-bar/components → components}/popover.ts +2 -2
- package/src/editor/plugins/{edit-bar/components → components}/select.ts +1 -1
- package/src/editor/plugins/core-sync.ts +44 -0
- package/src/editor/plugins/edit-bar/edit-items/align-elements.ts +2 -2
- package/src/editor/plugins/edit-bar/edit-items/font-align.ts +1 -1
- package/src/editor/plugins/edit-bar/edit-items/font-color.ts +1 -1
- package/src/editor/plugins/edit-bar/edit-items/font-family.ts +1 -1
- package/src/editor/plugins/edit-bar/edit-items/font-size.ts +3 -3
- package/src/editor/plugins/edit-bar/edit-items/icon-color.ts +1 -1
- package/src/editor/plugins/edit-bar/index.ts +2 -2
- package/src/editor/plugins/index.ts +2 -0
- package/src/editor/plugins/reset-viewbox.ts +258 -0
- package/src/editor/types/editor.ts +17 -0
- package/src/editor/types/index.ts +1 -0
- package/src/editor/types/interaction.ts +31 -0
- package/src/editor/types/state.ts +14 -2
- package/src/editor/types/sync.ts +31 -0
- package/src/editor/utils/data.ts +2 -1
- package/src/editor/utils/event.ts +7 -0
- package/src/editor/utils/index.ts +1 -0
- package/src/editor/utils/object.ts +106 -0
- package/src/index.ts +26 -2
- package/src/options/types.ts +4 -0
- package/src/runtime/options.ts +8 -1
- package/src/templates/built-in.ts +28 -0
- package/src/utils/measure-text.ts +6 -6
- package/src/utils/padding.ts +10 -2
- package/src/version.ts +1 -1
- /package/esm/editor/plugins/{edit-bar/components → components}/button.d.ts +0 -0
- /package/esm/editor/plugins/{edit-bar/components → components}/color-picker.d.ts +0 -0
- /package/esm/editor/plugins/{edit-bar/components → components}/index.d.ts +0 -0
- /package/esm/editor/plugins/{edit-bar/components → components}/index.js +0 -0
- /package/esm/editor/plugins/{edit-bar/components → components}/popover.d.ts +0 -0
- /package/esm/editor/plugins/{edit-bar/components → components}/select.d.ts +0 -0
- /package/lib/editor/plugins/{edit-bar/components → components}/button.d.ts +0 -0
- /package/lib/editor/plugins/{edit-bar/components → components}/color-picker.d.ts +0 -0
- /package/lib/editor/plugins/{edit-bar/components → components}/index.d.ts +0 -0
- /package/lib/editor/plugins/{edit-bar/components → components}/index.js +0 -0
- /package/lib/editor/plugins/{edit-bar/components → components}/popover.d.ts +0 -0
- /package/lib/editor/plugins/{edit-bar/components → components}/select.d.ts +0 -0
- /package/src/editor/plugins/{edit-bar/components → components}/index.ts +0 -0
package/esm/index.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
export * from './designs';
|
|
2
2
|
export { getItemProps, getThemeColors } from './designs/utils';
|
|
3
|
-
export {
|
|
4
|
-
export {
|
|
3
|
+
export { BatchCommand, UpdateElementCommand, UpdateOptionsCommand, UpdateTextCommand, } from './editor/commands';
|
|
4
|
+
export { BrushSelect, ClickSelect, DblClickEditText, DragCanvas, DragElement, HotkeyHistory, Interaction, SelectHighlight, ZoomWheel, } from './editor/interactions';
|
|
5
|
+
export { EditBar, Plugin, ResetViewBox, ResizeElement } from './editor/plugins';
|
|
5
6
|
export { exportToSVG } from './exporter';
|
|
6
7
|
export { Defs, Ellipse, Fragment, Group, Path, Polygon, Rect, Text, cloneElement, createFragment, createLayout, getCombinedBounds, getElementBounds, getElementsBounds, jsx, jsxDEV, jsxs, renderSVG, } from './jsx';
|
|
7
8
|
export { getFont, getFonts, getPalette, getPaletteColor, getPalettes, registerFont, registerPalette, registerPattern, setDefaultFont, } from './renderer';
|
|
@@ -12,7 +13,7 @@ export { getTemplate, getTemplates, registerTemplate } from './templates';
|
|
|
12
13
|
export { getTheme, getThemes, registerTheme } from './themes';
|
|
13
14
|
export { parseSVG, setFontExtendFactor } from './utils';
|
|
14
15
|
export { VERSION } from './version';
|
|
15
|
-
export type { EditBarOptions } from './editor';
|
|
16
|
+
export type { EditBarOptions, ICommand, ICommandManager, IEditor, IInteraction, IInteractionManager, IPlugin, IPluginManager, IStateManager, ISyncRegistry, InteractionInitOptions, KeyCode, PluginInitOptions, SelectMode, Selection, SyncHandler, } from './editor';
|
|
16
17
|
export type { ExportOptions, PNGExportOptions, SVGExportOptions, } from './exporter';
|
|
17
18
|
export type { Bounds, ComponentType, DefsProps, EllipseProps, FragmentProps, GroupProps, JSXElement, JSXElementConstructor, JSXNode, PathProps, Point, PolygonProps, RectProps, RenderableNode, SVGAttributes, SVGProps, TextProps, WithChildren, } from './jsx';
|
|
18
19
|
export type { InfographicOptions, ParsedInfographicOptions } from './options';
|
package/esm/index.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
export * from './designs/index.js';
|
|
2
2
|
export { getItemProps, getThemeColors } from './designs/utils/index.js';
|
|
3
|
-
export {
|
|
4
|
-
export {
|
|
3
|
+
export { BatchCommand, UpdateElementCommand, UpdateOptionsCommand, UpdateTextCommand, } from './editor/commands/index.js';
|
|
4
|
+
export { BrushSelect, ClickSelect, DblClickEditText, DragCanvas, DragElement, HotkeyHistory, Interaction, SelectHighlight, ZoomWheel, } from './editor/interactions/index.js';
|
|
5
|
+
export { EditBar, Plugin, ResetViewBox, ResizeElement } from './editor/plugins/index.js';
|
|
5
6
|
export { exportToSVG } from './exporter/index.js';
|
|
6
7
|
export { Defs, Ellipse, Fragment, Group, Path, Polygon, Rect, Text, cloneElement, createFragment, createLayout, getCombinedBounds, getElementBounds, getElementsBounds, jsx, jsxDEV, jsxs, renderSVG, } from './jsx/index.js';
|
|
7
8
|
export { getFont, getFonts, getPalette, getPaletteColor, getPalettes, registerFont, registerPalette, registerPattern, setDefaultFont, } from './renderer/index.js';
|
package/esm/options/types.d.ts
CHANGED
|
@@ -49,6 +49,7 @@ export interface ParsedInfographicOptions {
|
|
|
49
49
|
interactions?: IInteraction[];
|
|
50
50
|
shapes?: ElementProps[];
|
|
51
51
|
}
|
|
52
|
+
export type UpdatableInfographicOptions = Partial<Omit<ParsedInfographicOptions, 'container'>>;
|
|
52
53
|
interface SVGOptions {
|
|
53
54
|
style?: Record<string, string | number>;
|
|
54
55
|
attributes?: Record<string, string | number | boolean>;
|
package/esm/runtime/options.js
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
|
-
import { BrushSelect, ClickSelect, DblClickEditText, DragElement, EditBar, HotkeyHistory, ResizeElement, SelectHighlight, ZoomWheel, } from '../editor/index.js';
|
|
2
|
-
const createDefaultPlugins = () => [
|
|
1
|
+
import { BrushSelect, ClickSelect, DblClickEditText, DragCanvas, DragElement, EditBar, HotkeyHistory, ResetViewBox, ResizeElement, SelectHighlight, ZoomWheel, } from '../editor/index.js';
|
|
2
|
+
const createDefaultPlugins = () => [
|
|
3
|
+
new EditBar(),
|
|
4
|
+
new ResizeElement(),
|
|
5
|
+
new ResetViewBox(),
|
|
6
|
+
];
|
|
3
7
|
const createDefaultInteractions = () => [
|
|
8
|
+
new DragCanvas(),
|
|
4
9
|
new DblClickEditText(),
|
|
5
10
|
new BrushSelect(),
|
|
6
11
|
new ClickSelect(),
|
|
@@ -147,6 +147,18 @@ const BUILT_IN_TEMPLATES = Object.assign(Object.assign(Object.assign(Object.assi
|
|
|
147
147
|
structure: { type: 'relation-circle' },
|
|
148
148
|
items: [{ type: 'icon-badge' }],
|
|
149
149
|
},
|
|
150
|
+
}, 'relation-network-icon-badge': {
|
|
151
|
+
design: {
|
|
152
|
+
title: 'default',
|
|
153
|
+
structure: { type: 'relation-network' },
|
|
154
|
+
items: [{ type: 'icon-badge' }],
|
|
155
|
+
},
|
|
156
|
+
}, 'relation-network-simple-circle-node': {
|
|
157
|
+
design: {
|
|
158
|
+
title: 'default',
|
|
159
|
+
structure: { type: 'relation-network' },
|
|
160
|
+
items: [{ type: 'simple-circle-node' }],
|
|
161
|
+
},
|
|
150
162
|
}, 'sequence-steps-badge-card': {
|
|
151
163
|
design: {
|
|
152
164
|
title: 'default',
|
|
@@ -304,6 +316,18 @@ const BUILT_IN_TEMPLATES = Object.assign(Object.assign(Object.assign(Object.assi
|
|
|
304
316
|
structure: { type: 'list-sector', startAngle: -180, endAngle: 0 },
|
|
305
317
|
items: [{ type: 'plain-text' }],
|
|
306
318
|
},
|
|
319
|
+
}, 'list-waterfall-badge-card': {
|
|
320
|
+
design: {
|
|
321
|
+
title: 'default',
|
|
322
|
+
structure: { type: 'list-waterfall' },
|
|
323
|
+
items: [{ type: 'badge-card' }],
|
|
324
|
+
},
|
|
325
|
+
}, 'list-waterfall-compact-card': {
|
|
326
|
+
design: {
|
|
327
|
+
title: 'default',
|
|
328
|
+
structure: { type: 'list-waterfall' },
|
|
329
|
+
items: [{ type: 'compact-card' }],
|
|
330
|
+
},
|
|
307
331
|
}, 'sequence-roadmap-vertical-plain-text': {
|
|
308
332
|
design: {
|
|
309
333
|
title: 'default',
|
|
@@ -2,22 +2,25 @@ import { measureText as measure, registerFont } from 'measury';
|
|
|
2
2
|
import AlibabaPuHuiTi from 'measury/fonts/AlibabaPuHuiTi-Regular';
|
|
3
3
|
import { DEFAULT_FONT } from '../renderer/index.js';
|
|
4
4
|
import { encodeFontFamily } from './font.js';
|
|
5
|
-
import { isBrowser } from './is-browser.js';
|
|
6
5
|
let FONT_EXTEND_FACTOR = 1.01;
|
|
7
6
|
export const setFontExtendFactor = (factor) => {
|
|
8
7
|
FONT_EXTEND_FACTOR = factor;
|
|
9
8
|
};
|
|
10
9
|
registerFont(AlibabaPuHuiTi);
|
|
11
|
-
let canvasContext =
|
|
10
|
+
let canvasContext = undefined;
|
|
12
11
|
let measureSpan = null;
|
|
13
12
|
function getCanvasContext() {
|
|
14
|
-
if (
|
|
13
|
+
if (typeof document === 'undefined')
|
|
14
|
+
return null;
|
|
15
|
+
if (canvasContext !== undefined)
|
|
15
16
|
return canvasContext;
|
|
16
17
|
const canvas = document.createElement('canvas');
|
|
17
18
|
canvasContext = canvas.getContext('2d');
|
|
18
19
|
return canvasContext;
|
|
19
20
|
}
|
|
20
21
|
function getMeasureSpan() {
|
|
22
|
+
if (typeof document === 'undefined')
|
|
23
|
+
return null;
|
|
21
24
|
if (!document.body)
|
|
22
25
|
return null;
|
|
23
26
|
if (measureSpan)
|
|
@@ -75,6 +78,8 @@ function measureTextInBrowser(content, { fontFamily, fontSize, fontWeight, lineH
|
|
|
75
78
|
span.style.lineHeight = `${lineHeightPx}px`;
|
|
76
79
|
span.textContent = content;
|
|
77
80
|
const rect = span.getBoundingClientRect();
|
|
81
|
+
if (content && rect.width <= 0 && rect.height <= 0)
|
|
82
|
+
return null;
|
|
78
83
|
return { width: rect.width, height: rect.height };
|
|
79
84
|
}
|
|
80
85
|
export function measureText(text = '', attrs) {
|
|
@@ -94,9 +99,7 @@ export function measureText(text = '', attrs) {
|
|
|
94
99
|
lineHeight,
|
|
95
100
|
};
|
|
96
101
|
const fallback = () => measure(content, options);
|
|
97
|
-
const metrics =
|
|
98
|
-
? ((_a = measureTextInBrowser(content, options)) !== null && _a !== void 0 ? _a : fallback())
|
|
99
|
-
: fallback();
|
|
102
|
+
const metrics = (_a = measureTextInBrowser(content, options)) !== null && _a !== void 0 ? _a : fallback();
|
|
100
103
|
// 额外添加 1% 宽高
|
|
101
104
|
return {
|
|
102
105
|
width: Math.ceil(metrics.width * FONT_EXTEND_FACTOR),
|
package/esm/utils/padding.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import type { Padding, ParsedPadding } from '../types';
|
|
2
2
|
export declare function parsePadding(padding: Padding | undefined): ParsedPadding;
|
|
3
3
|
export declare function setSVGPadding(svg: SVGSVGElement, padding: ParsedPadding): void;
|
|
4
|
+
export declare function getBoundViewBox(svg: SVGSVGElement, padding: ParsedPadding): string;
|
package/esm/utils/padding.js
CHANGED
|
@@ -61,7 +61,7 @@ function setSVGPaddingInNode(svg, padding) {
|
|
|
61
61
|
viewBox: `${viewBox.x - left} ${viewBox.y - top} ${viewBox.width + left + right} ${viewBox.height + top + bottom}`,
|
|
62
62
|
});
|
|
63
63
|
}
|
|
64
|
-
function
|
|
64
|
+
export function getBoundViewBox(svg, padding) {
|
|
65
65
|
const bbox = svg.getBBox();
|
|
66
66
|
const clientRect = svg.getBoundingClientRect();
|
|
67
67
|
const scaleX = clientRect.width > 0 ? bbox.width / clientRect.width : 1;
|
|
@@ -75,8 +75,12 @@ function setSVGPaddingInBrowser(svg, padding) {
|
|
|
75
75
|
const newY = bbox.y - topSvg;
|
|
76
76
|
const newWidth = bbox.width + leftSvg + rightSvg;
|
|
77
77
|
const newHeight = bbox.height + topSvg + bottomSvg;
|
|
78
|
+
return `${newX} ${newY} ${newWidth} ${newHeight}`;
|
|
79
|
+
}
|
|
80
|
+
function setSVGPaddingInBrowser(svg, padding) {
|
|
81
|
+
const viewBox = getBoundViewBox(svg, padding);
|
|
78
82
|
setAttributes(svg, {
|
|
79
|
-
viewBox
|
|
83
|
+
viewBox,
|
|
80
84
|
});
|
|
81
85
|
}
|
|
82
86
|
function waitForLayout(element, callback) {
|
package/esm/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION = "0.2.
|
|
1
|
+
export declare const VERSION = "0.2.14";
|
package/esm/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const VERSION = '0.2.
|
|
1
|
+
export const VERSION = '0.2.14';
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { UpdatableInfographicOptions } from '../../options';
|
|
2
2
|
import type { ICommand, IStateManager } from '../types';
|
|
3
3
|
export declare class UpdateOptionsCommand implements ICommand {
|
|
4
4
|
private options;
|
|
5
5
|
private original?;
|
|
6
|
-
constructor(options:
|
|
6
|
+
constructor(options: UpdatableInfographicOptions, original?: UpdatableInfographicOptions | undefined);
|
|
7
7
|
apply(state: IStateManager): Promise<void>;
|
|
8
8
|
undo(state: IStateManager): Promise<void>;
|
|
9
9
|
serialize(): {
|
|
10
10
|
type: string;
|
|
11
|
-
options: Partial<ParsedInfographicOptions
|
|
12
|
-
original: ParsedInfographicOptions | undefined;
|
|
11
|
+
options: Partial<Omit<import("../../options").ParsedInfographicOptions, "container">>;
|
|
12
|
+
original: Partial<Omit<import("../../options").ParsedInfographicOptions, "container">> | undefined;
|
|
13
13
|
};
|
|
14
14
|
}
|
|
@@ -17,11 +17,14 @@ class UpdateOptionsCommand {
|
|
|
17
17
|
}
|
|
18
18
|
apply(state) {
|
|
19
19
|
return __awaiter(this, void 0, void 0, function* () {
|
|
20
|
-
const prev = state.getOptions();
|
|
21
20
|
if (!this.original) {
|
|
22
|
-
|
|
21
|
+
const prev = state.getOptions();
|
|
22
|
+
this.original = {};
|
|
23
|
+
Object.keys(this.options).forEach((key) => {
|
|
24
|
+
this.original[key] = prev[key];
|
|
25
|
+
});
|
|
23
26
|
}
|
|
24
|
-
state.updateOptions(
|
|
27
|
+
state.updateOptions(this.options);
|
|
25
28
|
});
|
|
26
29
|
}
|
|
27
30
|
undo(state) {
|
package/lib/editor/editor.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { ParsedInfographicOptions } from '../options';
|
|
2
2
|
import type { IEventEmitter } from '../types';
|
|
3
3
|
import { InteractionManager } from './managers';
|
|
4
|
-
import type { ICommandManager, IEditor, IPluginManager, IStateManager } from './types';
|
|
4
|
+
import type { ICommandManager, IEditor, IPluginManager, IStateManager, ISyncRegistry, SyncHandler } from './types';
|
|
5
5
|
export declare class Editor implements IEditor {
|
|
6
6
|
private emitter;
|
|
7
7
|
private document;
|
|
@@ -10,7 +10,11 @@ export declare class Editor implements IEditor {
|
|
|
10
10
|
commander: ICommandManager;
|
|
11
11
|
plugin: IPluginManager;
|
|
12
12
|
interaction: InteractionManager;
|
|
13
|
+
syncRegistry: ISyncRegistry;
|
|
13
14
|
constructor(emitter: IEventEmitter, document: SVGSVGElement, options: ParsedInfographicOptions);
|
|
15
|
+
registerSync(path: string, handler: SyncHandler, options?: {
|
|
16
|
+
immediate?: boolean;
|
|
17
|
+
}): () => void;
|
|
14
18
|
getDocument(): SVGSVGElement;
|
|
15
19
|
destroy(): void;
|
|
16
20
|
}
|
package/lib/editor/editor.js
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Editor = void 0;
|
|
4
4
|
const managers_1 = require("./managers");
|
|
5
|
+
const sync_registry_1 = require("./managers/sync-registry");
|
|
6
|
+
const plugins_1 = require("./plugins");
|
|
5
7
|
class Editor {
|
|
6
8
|
constructor(emitter, document, options) {
|
|
7
9
|
this.emitter = emitter;
|
|
@@ -15,6 +17,12 @@ class Editor {
|
|
|
15
17
|
const state = new managers_1.StateManager();
|
|
16
18
|
const plugin = new managers_1.PluginManager();
|
|
17
19
|
const interaction = new managers_1.InteractionManager();
|
|
20
|
+
const syncRegistry = new sync_registry_1.SyncRegistry(() => state.getOptions());
|
|
21
|
+
this.commander = commander;
|
|
22
|
+
this.state = state;
|
|
23
|
+
this.plugin = plugin;
|
|
24
|
+
this.interaction = interaction;
|
|
25
|
+
this.syncRegistry = syncRegistry;
|
|
18
26
|
commander.init({ state, emitter });
|
|
19
27
|
state.init({
|
|
20
28
|
emitter,
|
|
@@ -22,12 +30,15 @@ class Editor {
|
|
|
22
30
|
commander,
|
|
23
31
|
options,
|
|
24
32
|
});
|
|
33
|
+
// Load core plugin: CoreSyncPlugin (handles viewBox/padding sync)
|
|
34
|
+
const corePlugin = new plugins_1.CoreSyncPlugin();
|
|
35
|
+
const userPlugins = options.plugins || [];
|
|
25
36
|
plugin.init({
|
|
26
37
|
emitter,
|
|
27
38
|
editor: this,
|
|
28
39
|
commander,
|
|
29
40
|
state,
|
|
30
|
-
},
|
|
41
|
+
}, [corePlugin, ...userPlugins]);
|
|
31
42
|
interaction.init({
|
|
32
43
|
emitter,
|
|
33
44
|
editor: this,
|
|
@@ -35,10 +46,9 @@ class Editor {
|
|
|
35
46
|
state,
|
|
36
47
|
interactions: options.interactions,
|
|
37
48
|
});
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
this.
|
|
41
|
-
this.interaction = interaction;
|
|
49
|
+
}
|
|
50
|
+
registerSync(path, handler, options) {
|
|
51
|
+
return this.syncRegistry.register(path, handler, options);
|
|
42
52
|
}
|
|
43
53
|
getDocument() {
|
|
44
54
|
return this.document;
|
|
@@ -49,6 +59,7 @@ class Editor {
|
|
|
49
59
|
this.plugin.destroy();
|
|
50
60
|
this.commander.destroy();
|
|
51
61
|
this.state.destroy();
|
|
62
|
+
this.syncRegistry.destroy();
|
|
52
63
|
}
|
|
53
64
|
}
|
|
54
65
|
exports.Editor = Editor;
|
package/lib/editor/index.d.ts
CHANGED
package/lib/editor/index.js
CHANGED
|
@@ -15,6 +15,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
exports.Editor = void 0;
|
|
18
|
+
__exportStar(require("./commands"), exports);
|
|
18
19
|
var editor_1 = require("./editor");
|
|
19
20
|
Object.defineProperty(exports, "Editor", { enumerable: true, get: function () { return editor_1.Editor; } });
|
|
20
21
|
__exportStar(require("./interactions"), exports);
|
|
@@ -25,7 +25,7 @@ class BrushSelect extends base_1.Interaction {
|
|
|
25
25
|
return;
|
|
26
26
|
if (event.button !== 0)
|
|
27
27
|
return;
|
|
28
|
-
if (
|
|
28
|
+
if ((0, utils_2.isTextSelectionTarget)(event.target))
|
|
29
29
|
return;
|
|
30
30
|
if (this.hasElementAtStart(event.target))
|
|
31
31
|
return;
|
|
@@ -173,13 +173,5 @@ class BrushSelect extends base_1.Interaction {
|
|
|
173
173
|
return true;
|
|
174
174
|
return Boolean((_a = target.closest) === null || _a === void 0 ? void 0 : _a.call(target, '[data-element-type]'));
|
|
175
175
|
}
|
|
176
|
-
isTextSelectionTarget(target) {
|
|
177
|
-
if (!(target instanceof HTMLElement))
|
|
178
|
-
return false;
|
|
179
|
-
if (target.isContentEditable)
|
|
180
|
-
return true;
|
|
181
|
-
const tag = target.tagName.toLowerCase();
|
|
182
|
-
return tag === 'input' || tag === 'textarea';
|
|
183
|
-
}
|
|
184
176
|
}
|
|
185
177
|
exports.BrushSelect = BrushSelect;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { IInteraction, InteractionInitOptions, KeyCode } from '../types';
|
|
2
|
+
import { Interaction } from './base';
|
|
3
|
+
export interface DragCanvasOptions {
|
|
4
|
+
trigger?: KeyCode[];
|
|
5
|
+
}
|
|
6
|
+
export declare class DragCanvas extends Interaction implements IInteraction {
|
|
7
|
+
name: string;
|
|
8
|
+
/**
|
|
9
|
+
* 触发交互的按键代码。
|
|
10
|
+
* 参考标准的 KeyboardEvent.code 值:
|
|
11
|
+
* https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/code/code_values
|
|
12
|
+
* @default ['Space']
|
|
13
|
+
*/
|
|
14
|
+
trigger: KeyCode[];
|
|
15
|
+
constructor(options?: DragCanvasOptions);
|
|
16
|
+
private isTriggerPressed;
|
|
17
|
+
private pointerId?;
|
|
18
|
+
private startPoint?;
|
|
19
|
+
private document;
|
|
20
|
+
private startViewBoxString?;
|
|
21
|
+
private completeInteraction?;
|
|
22
|
+
private isHovering;
|
|
23
|
+
init(options: InteractionInitOptions): void;
|
|
24
|
+
destroy(): void;
|
|
25
|
+
private handleKeyDown;
|
|
26
|
+
private handlePointerDown;
|
|
27
|
+
private handlePointerMove;
|
|
28
|
+
private handlePointerUp;
|
|
29
|
+
private handleKeyUp;
|
|
30
|
+
private stopDrag;
|
|
31
|
+
private setCursor;
|
|
32
|
+
private handleBlur;
|
|
33
|
+
private onMouseEnter;
|
|
34
|
+
private onMouseLeave;
|
|
35
|
+
}
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.DragCanvas = void 0;
|
|
13
|
+
const utils_1 = require("../../utils");
|
|
14
|
+
const commands_1 = require("../commands");
|
|
15
|
+
const utils_2 = require("../utils");
|
|
16
|
+
const base_1 = require("./base");
|
|
17
|
+
class DragCanvas extends base_1.Interaction {
|
|
18
|
+
constructor(options) {
|
|
19
|
+
super();
|
|
20
|
+
this.name = 'drag-canvas';
|
|
21
|
+
/**
|
|
22
|
+
* 触发交互的按键代码。
|
|
23
|
+
* 参考标准的 KeyboardEvent.code 值:
|
|
24
|
+
* https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/code/code_values
|
|
25
|
+
* @default ['Space']
|
|
26
|
+
*/
|
|
27
|
+
this.trigger = ['Space'];
|
|
28
|
+
this.isTriggerPressed = false;
|
|
29
|
+
// 防止组件快捷键侵入性过强
|
|
30
|
+
this.isHovering = false;
|
|
31
|
+
this.handleKeyDown = (event) => {
|
|
32
|
+
if (!this.interaction.isActive())
|
|
33
|
+
return;
|
|
34
|
+
if ((0, utils_2.isTextSelectionTarget)(event.target))
|
|
35
|
+
return;
|
|
36
|
+
// 增加焦点的判断,防止对空格的preventDefault侵入性过强
|
|
37
|
+
const target = event.target;
|
|
38
|
+
const isBody = target === document.body || target === document.documentElement;
|
|
39
|
+
const isEditor = target === this.document || this.document.contains(target);
|
|
40
|
+
if (!isBody && !isEditor)
|
|
41
|
+
return;
|
|
42
|
+
if (!this.trigger.includes(event.code))
|
|
43
|
+
return;
|
|
44
|
+
if (!this.isHovering && !this.isTriggerPressed)
|
|
45
|
+
return;
|
|
46
|
+
event.preventDefault();
|
|
47
|
+
event.stopPropagation();
|
|
48
|
+
this.interaction.executeExclusiveInteraction(this, () => __awaiter(this, void 0, void 0, function* () {
|
|
49
|
+
return new Promise((resolve) => {
|
|
50
|
+
this.completeInteraction = resolve;
|
|
51
|
+
this.isTriggerPressed = true;
|
|
52
|
+
const viewBox = (0, utils_1.getViewBox)(this.document);
|
|
53
|
+
this.startViewBoxString = (0, utils_1.viewBoxToString)(viewBox);
|
|
54
|
+
this.setCursor('grab');
|
|
55
|
+
this.document.addEventListener('pointerdown', this.handlePointerDown);
|
|
56
|
+
window.addEventListener('keyup', this.handleKeyUp);
|
|
57
|
+
});
|
|
58
|
+
}));
|
|
59
|
+
};
|
|
60
|
+
this.handlePointerDown = (event) => {
|
|
61
|
+
if (event.button !== 0)
|
|
62
|
+
return;
|
|
63
|
+
event.preventDefault();
|
|
64
|
+
event.stopPropagation();
|
|
65
|
+
const svg = this.document;
|
|
66
|
+
this.startPoint = (0, utils_2.clientToViewport)(svg, event.clientX, event.clientY);
|
|
67
|
+
this.pointerId = event.pointerId;
|
|
68
|
+
this.setCursor('grabbing');
|
|
69
|
+
window.addEventListener('pointermove', this.handlePointerMove);
|
|
70
|
+
window.addEventListener('pointerup', this.handlePointerUp);
|
|
71
|
+
window.addEventListener('pointercancel', this.handlePointerUp);
|
|
72
|
+
};
|
|
73
|
+
this.handlePointerMove = (event) => {
|
|
74
|
+
if (event.pointerId !== this.pointerId || !this.startPoint)
|
|
75
|
+
return;
|
|
76
|
+
event.preventDefault();
|
|
77
|
+
event.stopPropagation();
|
|
78
|
+
const svg = this.document;
|
|
79
|
+
const current = (0, utils_2.clientToViewport)(svg, event.clientX, event.clientY);
|
|
80
|
+
const dx = current.x - this.startPoint.x;
|
|
81
|
+
const dy = current.y - this.startPoint.y;
|
|
82
|
+
const viewBox = (0, utils_1.getViewBox)(svg);
|
|
83
|
+
const { x, y, width, height } = viewBox;
|
|
84
|
+
const newX = x - dx;
|
|
85
|
+
const newY = y - dy;
|
|
86
|
+
this.state.updateOptions({
|
|
87
|
+
viewBox: (0, utils_1.viewBoxToString)({ x: newX, y: newY, width, height }),
|
|
88
|
+
});
|
|
89
|
+
};
|
|
90
|
+
this.handlePointerUp = (event) => {
|
|
91
|
+
if (event.pointerId !== this.pointerId)
|
|
92
|
+
return;
|
|
93
|
+
this.startPoint = undefined;
|
|
94
|
+
this.pointerId = undefined;
|
|
95
|
+
this.setCursor('grab');
|
|
96
|
+
window.removeEventListener('pointermove', this.handlePointerMove);
|
|
97
|
+
window.removeEventListener('pointerup', this.handlePointerUp);
|
|
98
|
+
window.removeEventListener('pointercancel', this.handlePointerUp);
|
|
99
|
+
};
|
|
100
|
+
this.handleKeyUp = (event) => {
|
|
101
|
+
if (!this.trigger.includes(event.code))
|
|
102
|
+
return;
|
|
103
|
+
this.stopDrag();
|
|
104
|
+
};
|
|
105
|
+
this.stopDrag = () => {
|
|
106
|
+
var _a;
|
|
107
|
+
if (this.startViewBoxString) {
|
|
108
|
+
const svg = this.document;
|
|
109
|
+
const viewBox = (0, utils_1.getViewBox)(svg);
|
|
110
|
+
const currentViewBoxString = (0, utils_1.viewBoxToString)(viewBox);
|
|
111
|
+
if (this.startViewBoxString !== currentViewBoxString) {
|
|
112
|
+
const command = new commands_1.UpdateOptionsCommand({ viewBox: currentViewBoxString }, { viewBox: this.startViewBoxString });
|
|
113
|
+
void this.commander.execute(command);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
this.startViewBoxString = undefined;
|
|
117
|
+
this.isTriggerPressed = false;
|
|
118
|
+
this.setCursor('default');
|
|
119
|
+
this.startPoint = undefined;
|
|
120
|
+
this.pointerId = undefined;
|
|
121
|
+
window.removeEventListener('keyup', this.handleKeyUp);
|
|
122
|
+
this.document.removeEventListener('pointerdown', this.handlePointerDown);
|
|
123
|
+
window.removeEventListener('pointermove', this.handlePointerMove);
|
|
124
|
+
window.removeEventListener('pointerup', this.handlePointerUp);
|
|
125
|
+
window.removeEventListener('pointercancel', this.handlePointerUp);
|
|
126
|
+
(_a = this.completeInteraction) === null || _a === void 0 ? void 0 : _a.call(this);
|
|
127
|
+
this.completeInteraction = undefined;
|
|
128
|
+
};
|
|
129
|
+
this.setCursor = (behavior) => {
|
|
130
|
+
document.body.style.cursor = behavior;
|
|
131
|
+
};
|
|
132
|
+
this.handleBlur = () => {
|
|
133
|
+
this.stopDrag();
|
|
134
|
+
};
|
|
135
|
+
this.onMouseEnter = () => {
|
|
136
|
+
this.isHovering = true;
|
|
137
|
+
};
|
|
138
|
+
this.onMouseLeave = () => {
|
|
139
|
+
this.isHovering = false;
|
|
140
|
+
};
|
|
141
|
+
if (options === null || options === void 0 ? void 0 : options.trigger) {
|
|
142
|
+
this.trigger = options.trigger;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
init(options) {
|
|
146
|
+
super.init(options);
|
|
147
|
+
this.document = this.editor.getDocument();
|
|
148
|
+
this.document.addEventListener('mouseenter', this.onMouseEnter);
|
|
149
|
+
this.document.addEventListener('mouseleave', this.onMouseLeave);
|
|
150
|
+
window.addEventListener('keydown', this.handleKeyDown);
|
|
151
|
+
window.addEventListener('blur', this.handleBlur);
|
|
152
|
+
}
|
|
153
|
+
destroy() {
|
|
154
|
+
window.removeEventListener('keydown', this.handleKeyDown);
|
|
155
|
+
window.removeEventListener('keyup', this.handleKeyUp);
|
|
156
|
+
this.document.removeEventListener('pointerdown', this.handlePointerDown);
|
|
157
|
+
window.removeEventListener('pointermove', this.handlePointerMove);
|
|
158
|
+
window.removeEventListener('pointerup', this.handlePointerUp);
|
|
159
|
+
window.removeEventListener('pointercancel', this.handlePointerUp);
|
|
160
|
+
window.removeEventListener('blur', this.handleBlur);
|
|
161
|
+
this.document.removeEventListener('mouseenter', this.onMouseEnter);
|
|
162
|
+
this.document.removeEventListener('mouseleave', this.onMouseLeave);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
exports.DragCanvas = DragCanvas;
|
|
@@ -116,9 +116,6 @@ class DragElement extends base_1.Interaction {
|
|
|
116
116
|
return true;
|
|
117
117
|
if (!this.startTarget)
|
|
118
118
|
return false;
|
|
119
|
-
if (this.willReplaceSelection) {
|
|
120
|
-
this.interaction.select([this.startTarget], 'replace');
|
|
121
|
-
}
|
|
122
119
|
this.dragItems = this.selectionForDrag
|
|
123
120
|
.filter((element) => (0, utils_1.isEditableText)(element))
|
|
124
121
|
.map((element) => this.createDragItem(element))
|
|
@@ -128,6 +125,10 @@ class DragElement extends base_1.Interaction {
|
|
|
128
125
|
let started = false;
|
|
129
126
|
this.interaction.executeExclusiveInteraction(this, () => __awaiter(this, void 0, void 0, function* () {
|
|
130
127
|
return new Promise((resolve) => {
|
|
128
|
+
// 只有拿到锁之后,才真正执行选中逻辑
|
|
129
|
+
if (this.willReplaceSelection && this.startTarget) {
|
|
130
|
+
this.interaction.select([this.startTarget], 'replace');
|
|
131
|
+
}
|
|
131
132
|
this.completeInteraction = resolve;
|
|
132
133
|
started = true;
|
|
133
134
|
});
|
|
@@ -2,6 +2,7 @@ export { Interaction } from './base';
|
|
|
2
2
|
export { BrushSelect } from './brush-select';
|
|
3
3
|
export { ClickSelect } from './click-select';
|
|
4
4
|
export { DblClickEditText } from './dblclick-edit-text';
|
|
5
|
+
export { DragCanvas } from './drag-canvas';
|
|
5
6
|
export { DragElement } from './drag-element';
|
|
6
7
|
export { HotkeyHistory } from './hotkey-history';
|
|
7
8
|
export { SelectHighlight } from './select-highlight';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ZoomWheel = exports.SelectHighlight = exports.HotkeyHistory = exports.DragElement = exports.DblClickEditText = exports.ClickSelect = exports.BrushSelect = exports.Interaction = void 0;
|
|
3
|
+
exports.ZoomWheel = exports.SelectHighlight = exports.HotkeyHistory = exports.DragElement = exports.DragCanvas = exports.DblClickEditText = exports.ClickSelect = exports.BrushSelect = exports.Interaction = void 0;
|
|
4
4
|
var base_1 = require("./base");
|
|
5
5
|
Object.defineProperty(exports, "Interaction", { enumerable: true, get: function () { return base_1.Interaction; } });
|
|
6
6
|
var brush_select_1 = require("./brush-select");
|
|
@@ -9,6 +9,8 @@ var click_select_1 = require("./click-select");
|
|
|
9
9
|
Object.defineProperty(exports, "ClickSelect", { enumerable: true, get: function () { return click_select_1.ClickSelect; } });
|
|
10
10
|
var dblclick_edit_text_1 = require("./dblclick-edit-text");
|
|
11
11
|
Object.defineProperty(exports, "DblClickEditText", { enumerable: true, get: function () { return dblclick_edit_text_1.DblClickEditText; } });
|
|
12
|
+
var drag_canvas_1 = require("./drag-canvas");
|
|
13
|
+
Object.defineProperty(exports, "DragCanvas", { enumerable: true, get: function () { return drag_canvas_1.DragCanvas; } });
|
|
12
14
|
var drag_element_1 = require("./drag-element");
|
|
13
15
|
Object.defineProperty(exports, "DragElement", { enumerable: true, get: function () { return drag_element_1.DragElement; } });
|
|
14
16
|
var hotkey_history_1 = require("./hotkey-history");
|
|
@@ -1,7 +1,16 @@
|
|
|
1
1
|
import type { IInteraction, InteractionInitOptions } from '../types';
|
|
2
2
|
import { Interaction } from './base';
|
|
3
|
+
export interface ZoomWheelOptions {
|
|
4
|
+
minViewBoxSize?: number;
|
|
5
|
+
maxViewBoxSize?: number;
|
|
6
|
+
}
|
|
3
7
|
export declare class ZoomWheel extends Interaction implements IInteraction {
|
|
4
8
|
name: string;
|
|
9
|
+
private minViewBoxSize;
|
|
10
|
+
private maxViewBoxSize;
|
|
11
|
+
constructor(options?: ZoomWheelOptions);
|
|
12
|
+
private initialViewBox;
|
|
13
|
+
private handleKeyUp;
|
|
5
14
|
private wheelListener;
|
|
6
15
|
private getMousePoint;
|
|
7
16
|
private getCenterPoint;
|