@rifrocket/fdt-plugin-shapes-basic-panel
v3.3.0
Published
A ready-made shape-creation UI for @rifrocket/fdt-plugin-shapes-basic's registered object types, registered into the "tool-rail" panel slot.
Readme
@rifrocket/fdt-plugin-shapes-basic-panel
A ready-made shape-creation UI for Fabric Design Tool.
A panel-slot wrapper plugin: @rifrocket/fdt-plugin-shapes-basic registers 20 object types (text, rect, circle, line, ellipse, rounded-rectangle, and 14 polygon shapes), but ships no UI to actually create one — a consumer previously had to build their own picker calling engine.addObjectOfType() from scratch. This package is that missing UI: one button per registered type.
Features
ShapePicker— bare, unstyled buttons (one per shape type), each callingengine.addObjectOfType(typeId, {})— the same public API any consumer's own picker would callcreateShapesBasicPanelPlugin()— installsShapePickerinto the"tool-rail"panel slot viaregistry.registerPanel(); declaresdependsOn: ["shapes-basic"];uninstall()removes only its own engine's panel registrationBASIC_SHAPE_TYPE_IDS— the exact list of type idsShapePickerrenders a button for, kept in sync withplugin-shapes-basic's ownSHAPE_COORDINATESexport rather than hand-duplicated
Install
npm install @rifrocket/fdt-plugin-shapes-basic-panelPeer dependencies: fabric, react, react-dom.
Depends on @rifrocket/fabricjs-design-tool, @rifrocket/fdt-plugin-shapes-basic (for its type-id list), and @rifrocket/fdt-react.
Quick start
import { shapesBasicPlugin } from "@rifrocket/fdt-plugin-shapes-basic";
import { createShapesBasicPanelPlugin } from "@rifrocket/fdt-plugin-shapes-basic-panel";
engine.use(shapesBasicPlugin);
engine.use(createShapesBasicPanelPlugin()); // renders ShapePicker into "tool-rail"<DesignEditor preset="default" plugins={{ add: [createShapesBasicPanelPlugin()] }} /><Editor>/<DesignEditor>/<MultiPageDesignEditor> all render a "tool-rail" slot by default — install this plugin and a shape picker appears with zero further wiring. A host with its own styled shape gallery (e.g. apps/demo's categorized/searchable ShapeGallery) can suppress the slot via slots={{ "tool-rail": () => null }} and render its own UI directly instead, importing BASIC_SHAPE_TYPE_IDS if it wants the same type-id list this package uses.
Not bundled into <DesignEditor>'s built-in presets — like @rifrocket/fdt-plugin-alignment/-snapping/-devtools/-effects-panel, it depends on @rifrocket/fdt-react, which would be a circular dependency if plugin-shapes-basic itself (bundled into every preset, and therefore required to stay React-free) depended on it back.
Documentation
License
MIT © Fabric Design Tool Contributors
