MCPcopy
hub / github.com/antvis/Infographic / CoreSyncPlugin

Class CoreSyncPlugin

src/editor/plugins/core-sync.ts:5–44  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3import { Plugin } from './base';
4
5export class CoreSyncPlugin extends Plugin implements IPlugin {
6 name = 'core-sync';
7
8 private unregisters: (() => void)[] = [];
9
10 init(options: PluginInitOptions) {
11 super.init(options);
12 const svg = this.editor.getDocument();
13
14 // viewBox Sync
15 this.unregisters.push(
16 this.editor.registerSync(
17 'viewBox',
18 (val) => {
19 if (val) {
20 svg.setAttribute('viewBox', val);
21 } else {
22 svg.removeAttribute('viewBox');
23 }
24 },
25 { immediate: true },
26 ),
27 );
28
29 // padding Sync
30 this.unregisters.push(
31 this.editor.registerSync(
32 'padding',
33 (val) => {
34 if (val !== undefined) setSVGPadding(svg, parsePadding(val));
35 },
36 { immediate: true },
37 ),
38 );
39 }
40
41 destroy() {
42 this.unregisters.forEach((fn) => fn());
43 }
44}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected