@rifrocket/fdt-plugin-svg-import
v3.3.0
Published
SVG import registered via the core plugin system — a net-new (not ported from v1) plugin proving the extension points are real.
Readme
@rifrocket/fdt-plugin-svg-import
SVG import for Fabric Design Tool.
A pure engine plugin that registers an "svg" importer — not an object type. SVG import adds parsed content directly to the canvas rather than creating one object-type instance, so it goes through registerImporter, not registerObjectType.
Features
- Call the registered importer directly — unlike JSON import, SVG import does not go through
engine.importFile().importSVGonly callscanvas.add(), self-syncingengine.store's object list via the canvas's ownobject:addedevent, so it doesn't needimportFile()'s full-replace resync logic (that's for importers that wholesale-replace canvas contents, likeplugin-import-json) importSvgToEngine(engine, svgString)— the one-hop convenience for that, instead ofengine.registry.importers.get("svg")(engine.getFabricCanvas(), svgString)by hand. Goes through the registered importer (honoring a.replace()'d one), not the pureimportSVGfunction directly- ⚠️ Not undoable.
importSVGadds objects straight to the canvas outside the history-tracked add/remove command path (engine.addObject()), so imported SVG content isn't an undo step - Net-new plugin (not ported from any prior version) — proof that the extension points work for import formats core doesn't special-case
Included in <DesignEditor preset="default">; dropped from preset="minimal".
Install
npm install @rifrocket/fdt-plugin-svg-importPeer dependencies: fabric.
Depends on @rifrocket/fabricjs-design-tool.
Quick start
import { svgImportPlugin, importSvgToEngine } from "@rifrocket/fdt-plugin-svg-import";
engine.use(svgImportPlugin);
await importSvgToEngine(engine, svgMarkupString);
// equivalent to: await engine.registry.importers.get("svg")(engine.getFabricCanvas(), svgMarkupString);Documentation
License
MIT © Fabric Design Tool Contributors
