@antv/infographic 0.2.12 → 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 +136 -125
- package/dist/infographic.min.js.map +1 -1
- package/esm/designs/structures/chart-pie.d.ts +25 -0
- package/esm/designs/structures/chart-pie.js +182 -23
- package/esm/designs/utils/index.d.ts +1 -0
- package/esm/designs/utils/index.js +1 -0
- package/esm/designs/utils/normalize-percent.d.ts +19 -0
- package/esm/designs/utils/normalize-percent.js +32 -0
- 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 +12 -0
- package/esm/editor/interactions/zoom-wheel.js +67 -27
- 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 -7
- 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 +27 -77
- package/esm/templates/chart-pie.d.ts +2 -0
- package/esm/templates/chart-pie.js +87 -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/utils/viewbox.d.ts +20 -0
- package/esm/utils/viewbox.js +10 -0
- package/esm/version.d.ts +1 -1
- package/esm/version.js +1 -1
- package/lib/designs/structures/chart-pie.d.ts +25 -0
- package/lib/designs/structures/chart-pie.js +182 -22
- package/lib/designs/utils/index.d.ts +1 -0
- package/lib/designs/utils/index.js +1 -0
- package/lib/designs/utils/normalize-percent.d.ts +19 -0
- package/lib/designs/utils/normalize-percent.js +35 -0
- 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 +12 -0
- package/lib/editor/interactions/zoom-wheel.js +66 -26
- 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 -5
- 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 +27 -77
- package/lib/templates/chart-pie.d.ts +2 -0
- package/lib/templates/chart-pie.js +90 -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/utils/viewbox.d.ts +20 -0
- package/lib/utils/viewbox.js +12 -0
- package/lib/version.d.ts +1 -1
- package/lib/version.js +1 -1
- package/package.json +1 -2
- package/src/designs/structures/chart-pie.tsx +259 -26
- package/src/designs/utils/index.ts +1 -0
- package/src/designs/utils/normalize-percent.ts +33 -0
- 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 +102 -24
- package/src/editor/managers/index.ts +1 -0
- package/src/editor/managers/state.ts +21 -16
- 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 +30 -81
- package/src/templates/chart-pie.ts +89 -0
- package/src/utils/measure-text.ts +6 -6
- package/src/utils/padding.ts +10 -2
- package/src/utils/viewbox.ts +23 -0
- 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
|
@@ -13,6 +13,7 @@ export declare const TEXT_ICONS: {
|
|
|
13
13
|
alignCenter: ({ fill }?: IconProps) => HTMLElement;
|
|
14
14
|
alignMiddle: ({ fill }?: IconProps) => HTMLElement;
|
|
15
15
|
};
|
|
16
|
+
export declare const RESET_ICON: ({ fill }?: IconProps) => HTMLElement;
|
|
16
17
|
export declare const ELEMENT_ICONS: {
|
|
17
18
|
align: ({ fill }?: IconProps) => HTMLElement;
|
|
18
19
|
alignTop: ({ fill }?: IconProps) => HTMLElement;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ELEMENT_ICONS = exports.TEXT_ICONS = void 0;
|
|
3
|
+
exports.ELEMENT_ICONS = exports.RESET_ICON = exports.TEXT_ICONS = void 0;
|
|
4
4
|
const createIcon = (children, { viewBox = '0 0 1024 1024', size = '1.5em' } = {}) => ({ fill = 'currentColor' } = {}) => {
|
|
5
5
|
const html = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="${viewBox}" width="${size}" height="${size}" fill="${fill}">
|
|
6
6
|
${children.trim()}
|
|
@@ -19,6 +19,7 @@ exports.TEXT_ICONS = {
|
|
|
19
19
|
alignCenter: createIcon(`<path d="M768 800.339c17.673 0 32 14.327 32 32 0 17.496-14.042 31.713-31.47 31.995l-0.53 0.005H256c-17.673 0-32-14.327-32-32 0-17.497 14.042-31.713 31.47-31.996l0.53-0.004h512z m128-213.226c17.673 0 32 14.327 32 32 0 17.496-14.042 31.713-31.47 31.996l-0.53 0.004H128c-17.673 0-32-14.327-32-32 0-17.496 14.042-31.713 31.47-31.996l0.53-0.004h768zM768 373.887c17.673 0 32 14.327 32 32 0 17.496-14.042 31.713-31.47 31.996l-0.53 0.004H256c-17.673 0-32-14.327-32-32 0-17.496 14.042-31.713 31.47-31.996l0.53-0.004h512z m128-213.226c17.673 0 32 14.327 32 32 0 17.497-14.042 31.713-31.47 31.996l-0.53 0.004H128c-17.673 0-32-14.327-32-32 0-17.496 14.042-31.713 31.47-31.995l0.53-0.005h768z"></path>`),
|
|
20
20
|
alignMiddle: createIcon(`<path d="M534.246 617.448l0.377 0.371 128 127.952c12.5 12.494 12.503 32.755 0.009 45.255-12.37 12.374-32.352 12.501-44.878 0.38l-0.377-0.372-73.38-73.352V939c0 17.673-14.326 32-32 32-17.496 0-31.712-14.042-31.995-31.47l-0.004-0.53-0.001-221.314-73.374 73.348c-12.374 12.37-32.356 12.49-44.878 0.363l-0.377-0.371c-12.37-12.375-12.49-32.356-0.362-44.878l0.37-0.377 128-127.952c12.372-12.366 32.347-12.49 44.87-0.37zM896 480.508c17.673 0 32 14.327 32 32 0 17.497-14.042 31.713-31.47 31.996l-0.53 0.004H128c-17.673 0-32-14.327-32-32 0-17.496 14.042-31.713 31.47-31.995l0.53-0.005h768zM511.998 54c17.496 0 31.713 14.042 31.996 31.47l0.004 0.53-0.001 221.314 73.38-73.349c12.499-12.494 32.76-12.49 45.255 0.009 12.37 12.374 12.49 32.356 0.362 44.878l-0.37 0.377-128 127.951c-12.372 12.366-32.347 12.49-44.87 0.371l-0.377-0.37-128-127.952c-12.5-12.495-12.503-32.756-0.009-45.255 12.37-12.374 32.352-12.502 44.878-0.38l0.377 0.371 73.374 73.346V86c0-17.673 14.328-32 32-32z"></path>`),
|
|
21
21
|
};
|
|
22
|
+
exports.RESET_ICON = createIcon(`<path d="M502.714987 58.258904l-126.531056-54.617723a52.797131 52.797131 0 0 0-41.873587 96.855428A447.865322 447.865322 0 0 0 392.02307 946.707184a61.535967 61.535967 0 0 0 13.83649 1.820591 52.797131 52.797131 0 0 0 13.65443-103.773672 342.453118 342.453118 0 0 1-31.678278-651.771485l-8.374718 19.480321a52.615072 52.615072 0 0 0 27.855039 69.182448 51.522718 51.522718 0 0 0 20.572675 4.369418A52.797131 52.797131 0 0 0 476.498481 254.882703L530.205907 127.441352a52.979191 52.979191 0 0 0-27.49092-69.182448zM962.960326 509.765407A448.775617 448.775617 0 0 0 643.992829 68.090094a52.797131 52.797131 0 1 0-30.403866 101.042786A342.635177 342.635177 0 0 1 674.578753 801.059925a52.615072 52.615072 0 0 0-92.30395-50.612422l-71.913335 117.246043a52.433013 52.433013 0 0 0 17.295612 72.82363l117.063985 72.823629a52.797131 52.797131 0 1 0 54.617722-89.755123l-16.021198-10.013249A448.593558 448.593558 0 0 0 962.960326 509.765407z" p-id="1630"/>`);
|
|
22
23
|
exports.ELEMENT_ICONS = {
|
|
23
24
|
align: createIcon(`<path d="M555.188 715.059c17.673 0 32 14.327 32 32V875c0 17.673-14.327 32-32 32H171c-17.673 0-32-14.327-32-32V747.059c0-17.673 14.327-32 32-32z m-32.001 63.999H203V843h320.187v-63.942zM854 416.529c17.673 0 32 14.327 32 32v127.942c0 17.673-14.327 32-32 32H171c-17.673 0-32-14.327-32-32V448.529c0-17.673 14.327-32 32-32z m-32 64H203v63.941h619v-63.941zM683.25 118c17.673 0 32 14.327 32 32v127.941c0 17.673-14.327 32-32 32H171c-17.673 0-32-14.327-32-32V150c0-17.673 14.327-32 32-32z m-32 64H203v63.941h448.25V182z"></path>`),
|
|
24
25
|
alignTop: createIcon(`
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Popover = Popover;
|
|
4
|
-
const constants_1 = require("
|
|
5
|
-
const utils_1 = require("
|
|
4
|
+
const constants_1 = require("../../../constants");
|
|
5
|
+
const utils_1 = require("../../../utils");
|
|
6
6
|
const POPOVER_CLASS = 'infographic-edit-popover';
|
|
7
7
|
const POPOVER_CONTENT_CLASS = `${POPOVER_CLASS}__content`;
|
|
8
8
|
const POPOVER_ARROW_CLASS = `${POPOVER_CLASS}__arrow`;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Select = Select;
|
|
4
|
-
const utils_1 = require("
|
|
4
|
+
const utils_1 = require("../../../utils");
|
|
5
5
|
const SELECT_CLASS = 'infographic-edit-select';
|
|
6
6
|
const SELECT_STYLE_ID = 'infographic-edit-select-style';
|
|
7
7
|
const OPTION_CLASS = `${SELECT_CLASS}__option`;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { IPlugin, PluginInitOptions } from '../types';
|
|
2
|
+
import { Plugin } from './base';
|
|
3
|
+
export declare class CoreSyncPlugin extends Plugin implements IPlugin {
|
|
4
|
+
name: string;
|
|
5
|
+
private unregisters;
|
|
6
|
+
init(options: PluginInitOptions): void;
|
|
7
|
+
destroy(): void;
|
|
8
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CoreSyncPlugin = void 0;
|
|
4
|
+
const utils_1 = require("../../utils");
|
|
5
|
+
const base_1 = require("./base");
|
|
6
|
+
class CoreSyncPlugin extends base_1.Plugin {
|
|
7
|
+
constructor() {
|
|
8
|
+
super(...arguments);
|
|
9
|
+
this.name = 'core-sync';
|
|
10
|
+
this.unregisters = [];
|
|
11
|
+
}
|
|
12
|
+
init(options) {
|
|
13
|
+
super.init(options);
|
|
14
|
+
const svg = this.editor.getDocument();
|
|
15
|
+
// viewBox Sync
|
|
16
|
+
this.unregisters.push(this.editor.registerSync('viewBox', (val) => {
|
|
17
|
+
if (val) {
|
|
18
|
+
svg.setAttribute('viewBox', val);
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
svg.removeAttribute('viewBox');
|
|
22
|
+
}
|
|
23
|
+
}, { immediate: true }));
|
|
24
|
+
// padding Sync
|
|
25
|
+
this.unregisters.push(this.editor.registerSync('padding', (val) => {
|
|
26
|
+
if (val !== undefined)
|
|
27
|
+
(0, utils_1.setSVGPadding)(svg, (0, utils_1.parsePadding)(val));
|
|
28
|
+
}, { immediate: true }));
|
|
29
|
+
}
|
|
30
|
+
destroy() {
|
|
31
|
+
this.unregisters.forEach((fn) => fn());
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
exports.CoreSyncPlugin = CoreSyncPlugin;
|
|
@@ -5,7 +5,7 @@ const jsx_1 = require("../../../../jsx");
|
|
|
5
5
|
const utils_1 = require("../../../../utils");
|
|
6
6
|
const commands_1 = require("../../../commands");
|
|
7
7
|
const utils_2 = require("../../../utils");
|
|
8
|
-
const components_1 = require("
|
|
8
|
+
const components_1 = require("../../components");
|
|
9
9
|
const GRID_CLASS = 'infographic-align-grid';
|
|
10
10
|
const GRID_COMPACT_CLASS = `${GRID_CLASS}--compact`;
|
|
11
11
|
const GRID_STYLE_ID = 'infographic-align-grid-style';
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.FontAlign = void 0;
|
|
4
4
|
const utils_1 = require("../../../../utils");
|
|
5
5
|
const commands_1 = require("../../../commands");
|
|
6
|
-
const components_1 = require("
|
|
6
|
+
const components_1 = require("../../components");
|
|
7
7
|
// 常量定义
|
|
8
8
|
const GRID_CLASS = 'infographic-font-align-grid';
|
|
9
9
|
const GRID_STYLE_ID = 'infographic-font-align-grid-style';
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.FontColor = void 0;
|
|
4
4
|
const utils_1 = require("../../../../utils");
|
|
5
5
|
const commands_1 = require("../../../commands");
|
|
6
|
-
const components_1 = require("
|
|
6
|
+
const components_1 = require("../../components");
|
|
7
7
|
const FONT_COLOR_BUTTON_CLASS = 'infographic-font-color-btn';
|
|
8
8
|
const FONT_COLOR_STYLE_ID = 'infographic-font-color-style';
|
|
9
9
|
const DEFAULT_COLOR = '#1f1f1f';
|
|
@@ -4,7 +4,7 @@ exports.FontFamily = void 0;
|
|
|
4
4
|
const renderer_1 = require("../../../../renderer");
|
|
5
5
|
const utils_1 = require("../../../../utils");
|
|
6
6
|
const commands_1 = require("../../../commands");
|
|
7
|
-
const components_1 = require("
|
|
7
|
+
const components_1 = require("../../components");
|
|
8
8
|
const FONT_LIST_CLASS = 'infographic-font-family-list';
|
|
9
9
|
const FONT_OPTION_CLASS = `${FONT_LIST_CLASS}__option`;
|
|
10
10
|
const FONT_LIST_STYLE_ID = 'infographic-font-family-list-style';
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.FontSize = void 0;
|
|
4
4
|
const utils_1 = require("../../../../utils");
|
|
5
5
|
const commands_1 = require("../../../commands");
|
|
6
|
-
const components_1 = require("
|
|
6
|
+
const components_1 = require("../../components");
|
|
7
7
|
const FONT_SIZE_CLASS = 'infographic-font-size-grid';
|
|
8
8
|
const FONT_SIZE_STYLE_ID = 'infographic-font-size-grid-style';
|
|
9
9
|
const FONT_SIZE_OPTIONS = [
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.IconColor = void 0;
|
|
4
4
|
const utils_1 = require("../../../../utils");
|
|
5
5
|
const commands_1 = require("../../../commands");
|
|
6
|
-
const components_1 = require("
|
|
6
|
+
const components_1 = require("../../components");
|
|
7
7
|
const ICON_COLOR_BUTTON_CLASS = 'infographic-icon-color-btn';
|
|
8
8
|
const ICON_COLOR_STYLE_ID = 'infographic-icon-color-style';
|
|
9
9
|
const DEFAULT_COLOR = '#1f1f1f';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { ColorPicker, Popover, Select } from '
|
|
1
|
+
export { ColorPicker, Popover, Select } from '../components';
|
|
2
2
|
export { EditBar } from './edit-bar';
|
|
3
|
-
export type { ColorPickerHandle, ColorPickerProps, IconButtonHandle, IconButtonProps, IconProps, PopoverHandle, PopoverPlacement, PopoverProps, SelectHandle, SelectOption, SelectProps, SelectValue, } from '
|
|
3
|
+
export type { ColorPickerHandle, ColorPickerProps, IconButtonHandle, IconButtonProps, IconProps, PopoverHandle, PopoverPlacement, PopoverProps, SelectHandle, SelectOption, SelectProps, SelectValue, } from '../components';
|
|
4
4
|
export type { EditBarOptions } from './edit-bar';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.EditBar = exports.Select = exports.Popover = exports.ColorPicker = void 0;
|
|
4
|
-
var components_1 = require("
|
|
4
|
+
var components_1 = require("../components");
|
|
5
5
|
Object.defineProperty(exports, "ColorPicker", { enumerable: true, get: function () { return components_1.ColorPicker; } });
|
|
6
6
|
Object.defineProperty(exports, "Popover", { enumerable: true, get: function () { return components_1.Popover; } });
|
|
7
7
|
Object.defineProperty(exports, "Select", { enumerable: true, get: function () { return components_1.Select; } });
|
|
@@ -14,9 +14,13 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.ResizeElement = exports.Plugin = void 0;
|
|
17
|
+
exports.ResizeElement = exports.ResetViewBox = exports.CoreSyncPlugin = exports.Plugin = void 0;
|
|
18
18
|
var base_1 = require("./base");
|
|
19
19
|
Object.defineProperty(exports, "Plugin", { enumerable: true, get: function () { return base_1.Plugin; } });
|
|
20
|
+
var core_sync_1 = require("./core-sync");
|
|
21
|
+
Object.defineProperty(exports, "CoreSyncPlugin", { enumerable: true, get: function () { return core_sync_1.CoreSyncPlugin; } });
|
|
20
22
|
__exportStar(require("./edit-bar"), exports);
|
|
23
|
+
var reset_viewbox_1 = require("./reset-viewbox");
|
|
24
|
+
Object.defineProperty(exports, "ResetViewBox", { enumerable: true, get: function () { return reset_viewbox_1.ResetViewBox; } });
|
|
21
25
|
var resize_element_1 = require("./resize-element");
|
|
22
26
|
Object.defineProperty(exports, "ResizeElement", { enumerable: true, get: function () { return resize_element_1.ResizeElement; } });
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { IPlugin, PluginInitOptions } from '../types';
|
|
2
|
+
import { Plugin } from './base';
|
|
3
|
+
export interface ResetViewBoxOptions {
|
|
4
|
+
style?: Partial<CSSStyleDeclaration>;
|
|
5
|
+
className?: string;
|
|
6
|
+
getContainer?: HTMLElement | (() => HTMLElement);
|
|
7
|
+
}
|
|
8
|
+
export declare class ResetViewBox extends Plugin implements IPlugin {
|
|
9
|
+
private options?;
|
|
10
|
+
name: string;
|
|
11
|
+
private originViewBox;
|
|
12
|
+
private resetButton?;
|
|
13
|
+
private viewBoxChanged;
|
|
14
|
+
private unregisterSync?;
|
|
15
|
+
constructor(options?: ResetViewBoxOptions | undefined);
|
|
16
|
+
init(options: PluginInitOptions): void;
|
|
17
|
+
destroy(): void;
|
|
18
|
+
private handleResize;
|
|
19
|
+
private updateOriginViewBox;
|
|
20
|
+
private handleViewBoxChange;
|
|
21
|
+
protected getOrCreateResetButton: () => HTMLButtonElement;
|
|
22
|
+
/** Get CSS transform scale of an element */
|
|
23
|
+
private getTransformScale;
|
|
24
|
+
/** Find the nearest stable overflow container */
|
|
25
|
+
private findStableContainer;
|
|
26
|
+
private placeButton;
|
|
27
|
+
private updatePosition;
|
|
28
|
+
private resetViewBox;
|
|
29
|
+
private showButton;
|
|
30
|
+
private hideButton;
|
|
31
|
+
private removeButton;
|
|
32
|
+
private ensureButtonStyle;
|
|
33
|
+
}
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ResetViewBox = void 0;
|
|
4
|
+
const constants_1 = require("../../constants");
|
|
5
|
+
const utils_1 = require("../../utils");
|
|
6
|
+
const commands_1 = require("../commands");
|
|
7
|
+
const base_1 = require("./base");
|
|
8
|
+
const components_1 = require("./components");
|
|
9
|
+
const icons_1 = require("./components/icons");
|
|
10
|
+
const MARGIN_X = 25;
|
|
11
|
+
const MARGIN_Y = 25;
|
|
12
|
+
const BUTTON_SIZE = 40;
|
|
13
|
+
class ResetViewBox extends base_1.Plugin {
|
|
14
|
+
constructor(options) {
|
|
15
|
+
super();
|
|
16
|
+
this.options = options;
|
|
17
|
+
this.name = 'reset-viewBox';
|
|
18
|
+
this.viewBoxChanged = false;
|
|
19
|
+
this.handleResize = () => {
|
|
20
|
+
this.updateOriginViewBox();
|
|
21
|
+
this.updatePosition();
|
|
22
|
+
};
|
|
23
|
+
this.handleViewBoxChange = (viewBox) => {
|
|
24
|
+
const svg = this.editor.getDocument();
|
|
25
|
+
this.viewBoxChanged = viewBox !== this.originViewBox;
|
|
26
|
+
if (!this.viewBoxChanged) {
|
|
27
|
+
if (this.resetButton)
|
|
28
|
+
this.hideButton(this.resetButton);
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
const button = this.getOrCreateResetButton();
|
|
32
|
+
this.placeButton(button, svg);
|
|
33
|
+
this.showButton(button);
|
|
34
|
+
};
|
|
35
|
+
this.getOrCreateResetButton = () => {
|
|
36
|
+
if (this.resetButton)
|
|
37
|
+
return this.resetButton;
|
|
38
|
+
const { style, className } = this.options || {};
|
|
39
|
+
const button = (0, components_1.IconButton)({
|
|
40
|
+
icon: icons_1.RESET_ICON,
|
|
41
|
+
onClick: this.resetViewBox,
|
|
42
|
+
});
|
|
43
|
+
button.classList.add(RESET_BUTTON_CLASS);
|
|
44
|
+
if (className) {
|
|
45
|
+
button.classList.add(className);
|
|
46
|
+
}
|
|
47
|
+
if (style) {
|
|
48
|
+
Object.assign(button.style, style);
|
|
49
|
+
}
|
|
50
|
+
(0, utils_1.setElementRole)(button, constants_1.COMPONENT_ROLE);
|
|
51
|
+
this.resetButton = button;
|
|
52
|
+
const { getContainer } = this.options || {};
|
|
53
|
+
const resolvedContainer = typeof getContainer === 'function' ? getContainer() : getContainer;
|
|
54
|
+
const containerParent = resolvedContainer !== null && resolvedContainer !== void 0 ? resolvedContainer : document.body;
|
|
55
|
+
containerParent === null || containerParent === void 0 ? void 0 : containerParent.appendChild(button);
|
|
56
|
+
return button;
|
|
57
|
+
};
|
|
58
|
+
/** Get CSS transform scale of an element */
|
|
59
|
+
this.getTransformScale = (element) => {
|
|
60
|
+
const rect = element.getBoundingClientRect();
|
|
61
|
+
const scaleX = element.offsetWidth > 0 ? rect.width / element.offsetWidth : 1;
|
|
62
|
+
const scaleY = element.offsetHeight > 0 ? rect.height / element.offsetHeight : 1;
|
|
63
|
+
return { scaleX, scaleY };
|
|
64
|
+
};
|
|
65
|
+
/** Find the nearest stable overflow container */
|
|
66
|
+
this.findStableContainer = (svg) => {
|
|
67
|
+
let current = svg.parentElement;
|
|
68
|
+
while (current) {
|
|
69
|
+
if (current instanceof HTMLElement) {
|
|
70
|
+
const style = window.getComputedStyle(current);
|
|
71
|
+
// Look for overflow container or positioned element as stable reference
|
|
72
|
+
if ((style.overflow && style.overflow !== 'visible') ||
|
|
73
|
+
(style.overflowX && style.overflowX !== 'visible') ||
|
|
74
|
+
(style.overflowY && style.overflowY !== 'visible')) {
|
|
75
|
+
return current;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
current = current.parentElement;
|
|
79
|
+
}
|
|
80
|
+
return null;
|
|
81
|
+
};
|
|
82
|
+
this.placeButton = (button, svg) => {
|
|
83
|
+
var _a;
|
|
84
|
+
if (!svg.isConnected)
|
|
85
|
+
return;
|
|
86
|
+
const svgRect = svg.getBoundingClientRect();
|
|
87
|
+
const offsetParent = (_a = button.offsetParent) !== null && _a !== void 0 ? _a : document.documentElement;
|
|
88
|
+
// Use stable container bounds to clamp button position when SVG overflows
|
|
89
|
+
const stableContainer = this.findStableContainer(svg);
|
|
90
|
+
const containerRect = stableContainer === null || stableContainer === void 0 ? void 0 : stableContainer.getBoundingClientRect();
|
|
91
|
+
// Prefer SVG bounds, but clamp to container if SVG overflows
|
|
92
|
+
const effectiveRect = containerRect
|
|
93
|
+
? {
|
|
94
|
+
right: Math.min(svgRect.right, containerRect.right),
|
|
95
|
+
bottom: Math.min(svgRect.bottom, containerRect.bottom),
|
|
96
|
+
}
|
|
97
|
+
: svgRect;
|
|
98
|
+
if (offsetParent === document.body ||
|
|
99
|
+
offsetParent === document.documentElement) {
|
|
100
|
+
const scrollX = window.scrollX || document.documentElement.scrollLeft;
|
|
101
|
+
const scrollY = window.scrollY || document.documentElement.scrollTop;
|
|
102
|
+
const left = scrollX + effectiveRect.right - MARGIN_X - BUTTON_SIZE;
|
|
103
|
+
const top = scrollY + effectiveRect.bottom - MARGIN_Y - BUTTON_SIZE;
|
|
104
|
+
button.style.left = `${left}px`;
|
|
105
|
+
button.style.top = `${top}px`;
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
const parentRect = offsetParent.getBoundingClientRect();
|
|
109
|
+
// Compensate for parent transform scale
|
|
110
|
+
const { scaleX, scaleY } = this.getTransformScale(offsetParent);
|
|
111
|
+
// Convert to offsetParent local coordinates
|
|
112
|
+
const left = (effectiveRect.right - parentRect.left) / scaleX - MARGIN_X - BUTTON_SIZE;
|
|
113
|
+
const top = (effectiveRect.bottom - parentRect.top) / scaleY - MARGIN_Y - BUTTON_SIZE;
|
|
114
|
+
button.style.left = `${left}px`;
|
|
115
|
+
button.style.top = `${top}px`;
|
|
116
|
+
};
|
|
117
|
+
this.updatePosition = () => {
|
|
118
|
+
if (this.resetButton && this.viewBoxChanged) {
|
|
119
|
+
this.placeButton(this.resetButton, this.editor.getDocument());
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
this.resetViewBox = () => {
|
|
123
|
+
const command = new commands_1.UpdateOptionsCommand({
|
|
124
|
+
viewBox: this.originViewBox,
|
|
125
|
+
});
|
|
126
|
+
void this.commander.execute(command);
|
|
127
|
+
};
|
|
128
|
+
this.showButton = (button) => {
|
|
129
|
+
button.style.display = 'flex';
|
|
130
|
+
button.style.visibility = 'visible';
|
|
131
|
+
};
|
|
132
|
+
this.hideButton = (button) => {
|
|
133
|
+
button.style.display = 'none';
|
|
134
|
+
};
|
|
135
|
+
this.removeButton = () => {
|
|
136
|
+
var _a;
|
|
137
|
+
this.viewBoxChanged = false;
|
|
138
|
+
(_a = this.resetButton) === null || _a === void 0 ? void 0 : _a.remove();
|
|
139
|
+
this.resetButton = undefined;
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
init(options) {
|
|
143
|
+
super.init(options);
|
|
144
|
+
// Initialize originViewBox
|
|
145
|
+
this.ensureButtonStyle();
|
|
146
|
+
this.updateOriginViewBox();
|
|
147
|
+
this.unregisterSync = this.editor.registerSync('viewBox', this.handleViewBoxChange);
|
|
148
|
+
window.addEventListener('resize', this.handleResize);
|
|
149
|
+
}
|
|
150
|
+
destroy() {
|
|
151
|
+
var _a;
|
|
152
|
+
(_a = this.unregisterSync) === null || _a === void 0 ? void 0 : _a.call(this);
|
|
153
|
+
window.removeEventListener('resize', this.handleResize);
|
|
154
|
+
this.removeButton();
|
|
155
|
+
}
|
|
156
|
+
updateOriginViewBox() {
|
|
157
|
+
const svg = this.editor.getDocument();
|
|
158
|
+
// In Node env or before render, fallback to current viewBox attribute
|
|
159
|
+
if (!svg.getBBox) {
|
|
160
|
+
this.originViewBox = (0, utils_1.viewBoxToString)((0, utils_1.getViewBox)(svg));
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
// In Browser, calculate fit
|
|
164
|
+
const { padding } = this.state.getOptions();
|
|
165
|
+
this.originViewBox = (0, utils_1.getBoundViewBox)(svg, (0, utils_1.parsePadding)(padding));
|
|
166
|
+
}
|
|
167
|
+
ensureButtonStyle() {
|
|
168
|
+
(0, utils_1.injectStyleOnce)(RESET_BUTTON_STYLE_ID, `
|
|
169
|
+
button.${RESET_BUTTON_CLASS} {
|
|
170
|
+
visibility: hidden;
|
|
171
|
+
position: absolute;
|
|
172
|
+
display: flex;
|
|
173
|
+
justify-content: center;
|
|
174
|
+
align-items: center;
|
|
175
|
+
width: ${BUTTON_SIZE}px;
|
|
176
|
+
height: ${BUTTON_SIZE}px;
|
|
177
|
+
border-radius: 50%;
|
|
178
|
+
padding: 4px;
|
|
179
|
+
background-color: #fff;
|
|
180
|
+
border: 1px solid #e5e7eb;
|
|
181
|
+
z-index: 1000;
|
|
182
|
+
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
|
|
183
|
+
cursor: pointer;
|
|
184
|
+
}
|
|
185
|
+
`);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
exports.ResetViewBox = ResetViewBox;
|
|
189
|
+
const RESET_BUTTON_CLASS = 'infographic-reset-viewbox-btn';
|
|
190
|
+
const RESET_BUTTON_STYLE_ID = 'infographic-reset-viewbox-btn-style';
|
|
@@ -1,4 +1,17 @@
|
|
|
1
|
+
import type { ICommandManager } from './command';
|
|
2
|
+
import type { IInteractionManager } from './interaction';
|
|
3
|
+
import type { IPluginManager } from './plugin';
|
|
4
|
+
import type { IStateManager } from './state';
|
|
5
|
+
import type { ISyncRegistry, SyncHandler } from './sync';
|
|
1
6
|
export interface IEditor {
|
|
7
|
+
commander: ICommandManager;
|
|
8
|
+
interaction: IInteractionManager;
|
|
9
|
+
plugin: IPluginManager;
|
|
10
|
+
state: IStateManager;
|
|
11
|
+
syncRegistry: ISyncRegistry;
|
|
2
12
|
getDocument(): SVGSVGElement;
|
|
13
|
+
registerSync(path: string, handler: SyncHandler, options?: {
|
|
14
|
+
immediate?: boolean;
|
|
15
|
+
}): () => void;
|
|
3
16
|
destroy(): void;
|
|
4
17
|
}
|
|
@@ -3,6 +3,11 @@ import type { ICommandManager } from './command';
|
|
|
3
3
|
import type { IEditor } from './editor';
|
|
4
4
|
import type { Selection } from './selection';
|
|
5
5
|
import type { IStateManager } from './state';
|
|
6
|
+
/**
|
|
7
|
+
* Union type of common key codes, using (string & {}) trick to provide completion suggestions without limiting specific strings
|
|
8
|
+
* Reference: https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/code/code_values
|
|
9
|
+
*/
|
|
10
|
+
export type KeyCode = 'Space' | 'ShiftLeft' | 'ShiftRight' | 'ControlLeft' | 'ControlRight' | 'AltLeft' | 'AltRight' | 'MetaLeft' | 'MetaRight' | 'CapsLock' | 'Tab' | 'Enter' | 'Escape' | 'ArrowUp' | 'ArrowDown' | 'ArrowLeft' | 'ArrowRight' | `Key${string}` | `Digit${number}` | (string & {});
|
|
6
11
|
export interface IInteraction {
|
|
7
12
|
name: string;
|
|
8
13
|
init(options: InteractionInitOptions): void;
|
|
@@ -17,6 +22,10 @@ export interface SelectionChangePayload {
|
|
|
17
22
|
removed: Selection;
|
|
18
23
|
mode: SelectMode;
|
|
19
24
|
}
|
|
25
|
+
export interface viewBoxChangePayload {
|
|
26
|
+
type: 'viewBox:change';
|
|
27
|
+
viewBox: string | undefined;
|
|
28
|
+
}
|
|
20
29
|
export interface IInteractionManager {
|
|
21
30
|
isActive(): boolean;
|
|
22
31
|
select(items: Selection, mode: SelectMode): void;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ParsedInfographicOptions } from '../../options';
|
|
1
|
+
import type { ParsedInfographicOptions, UpdatableInfographicOptions } from '../../options';
|
|
2
2
|
import type { Element, IEventEmitter, ItemDatum } from '../../types';
|
|
3
3
|
import type { ICommandManager } from './command';
|
|
4
4
|
import type { IEditor } from './editor';
|
|
@@ -21,7 +21,9 @@ export interface IStateManager {
|
|
|
21
21
|
removeItemDatum(indexes: number[], count?: number): void;
|
|
22
22
|
updateData(key: string, value: any): void;
|
|
23
23
|
updateElement(element: Element, props: Partial<ElementProps>): void;
|
|
24
|
-
updateOptions(options:
|
|
24
|
+
updateOptions(options: UpdatableInfographicOptions, execOptions?: {
|
|
25
|
+
bubbleUp?: boolean;
|
|
26
|
+
}): void;
|
|
25
27
|
getOptions(): ParsedInfographicOptions;
|
|
26
28
|
destroy(): void;
|
|
27
29
|
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sync callback
|
|
3
|
+
* @param newValue The new value after modification
|
|
4
|
+
* @param oldValue The old value before modification. Note: This value is undefined when triggered by parent path bubbling notification (i.e., listening to a non-leaf node).
|
|
5
|
+
*/
|
|
6
|
+
export type SyncHandler = (newValue: any, oldValue: any) => void;
|
|
7
|
+
export interface ISyncRegistry {
|
|
8
|
+
/**
|
|
9
|
+
* Register synchronization logic
|
|
10
|
+
* @param path Configuration path, such as 'design.background'
|
|
11
|
+
* @param handler Sync callback
|
|
12
|
+
* @param options.immediate Whether to execute immediately (used for view initialization)
|
|
13
|
+
* @returns unregister function
|
|
14
|
+
*/
|
|
15
|
+
register(path: string, handler: SyncHandler, options?: {
|
|
16
|
+
immediate?: boolean;
|
|
17
|
+
}): () => void;
|
|
18
|
+
/**
|
|
19
|
+
* Trigger synchronization (usually called by StateManager)
|
|
20
|
+
* @param path Configuration path
|
|
21
|
+
* @param newVal New value
|
|
22
|
+
* @param oldVal Old value
|
|
23
|
+
*/
|
|
24
|
+
trigger(path: string, newVal: any, oldVal: any): void;
|
|
25
|
+
destroy(): void;
|
|
26
|
+
}
|
package/lib/editor/utils/data.js
CHANGED
|
@@ -8,8 +8,10 @@ const utils_1 = require("../../utils");
|
|
|
8
8
|
*/
|
|
9
9
|
function getChildrenDataByIndexes(data, indexes) {
|
|
10
10
|
if (indexes.length === 0)
|
|
11
|
-
return data.
|
|
11
|
+
return data.items;
|
|
12
12
|
const datum = (0, utils_1.getDatumByIndexes)(data, indexes);
|
|
13
|
+
if (datum == null)
|
|
14
|
+
return [];
|
|
13
15
|
datum.children || (datum.children = []);
|
|
14
16
|
return datum.children;
|
|
15
17
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import { Element } from '../../types';
|
|
2
2
|
export declare function getEventTarget(element: SVGElement | null): Element | null;
|
|
3
3
|
export declare function getSelectableTarget(element: SVGElement | null): Element | null;
|
|
4
|
+
export declare function isTextSelectionTarget(target: EventTarget | null): boolean;
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getEventTarget = getEventTarget;
|
|
4
4
|
exports.getSelectableTarget = getSelectableTarget;
|
|
5
|
+
exports.isTextSelectionTarget = isTextSelectionTarget;
|
|
5
6
|
const utils_1 = require("../../utils");
|
|
6
7
|
function getEventTarget(element) {
|
|
7
8
|
if (!element)
|
|
@@ -66,3 +67,11 @@ const getIconEventTarget = (element) => {
|
|
|
66
67
|
}
|
|
67
68
|
return null;
|
|
68
69
|
};
|
|
70
|
+
function isTextSelectionTarget(target) {
|
|
71
|
+
if (!(target instanceof HTMLElement))
|
|
72
|
+
return false;
|
|
73
|
+
if (target.isContentEditable)
|
|
74
|
+
return true;
|
|
75
|
+
const tag = target.tagName.toLowerCase();
|
|
76
|
+
return tag === 'input' || tag === 'textarea';
|
|
77
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export interface ApplyOptionUpdatesOptions {
|
|
2
|
+
/** Whether to notify parent paths of changes (bubbling) */
|
|
3
|
+
bubbleUp?: boolean;
|
|
4
|
+
/** Callback triggered whenever a property value changes */
|
|
5
|
+
collector?: (path: string, newVal: any, oldVal: any) => void;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Recursively applies properties from 'source' to 'target' and collects changes.
|
|
9
|
+
*
|
|
10
|
+
* @param target - The object to be updated
|
|
11
|
+
* @param source - The source object containing partial updates
|
|
12
|
+
* @param basePath - Current path prefix for nested properties
|
|
13
|
+
* @param options - Configuration options
|
|
14
|
+
*/
|
|
15
|
+
export declare function applyOptionUpdates(target: any, source: any, basePath?: string, options?: ApplyOptionUpdatesOptions): void;
|