| 3 | import { Plugin } from './base'; |
| 4 | |
| 5 | export 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 | } |
nothing calls this directly
no outgoing calls
no test coverage detected