Skip to content

Editor API Reference

The main all-in-one editor component.

interface ElucimEditorProps {
initialDocument?: ElucimDocument;
initialFrame?: number | 'last';
theme?: ElucimTheme;
editorTheme?: Record<string, string>;
onDocumentChange?: (document: ElucimDocument) => void;
onBrowseImage?: BrowseImageFn;
imageResolver?: ImageResolverFn;
className?: string;
style?: React.CSSProperties;
}
PropDescription
initialDocumentStarting canonical ElucimDocument.
initialFrameStarting frame, or 'last' to open at the final linear frame.
themeShared content ElucimTheme; editor chrome is derived from it.
editorThemeEditor chrome token overrides. Accepts bare names or full CSS variable names.
onDocumentChangeCalled after edits with canonical Elucim Document output. Skips initial mount.
onBrowseImageOpens a host-provided image picker from image fields.
imageResolverResolves opaque image refs in editor preview.
className / styleRoot editor container styling.
<ElucimEditor
initialDocument={doc}
initialFrame="last"
theme={contentTheme}
editorTheme={{ 'color-scheme': 'light', accent: '#2563eb' }}
onDocumentChange={save}
/>
ExportDescription
ElucimEditorMain editor component.
ElucimCanvasCanvas with zoom/pan, selection, preview frames, minimap hooks, and overlays.
ToolbarCreate palette and file/history/theme controls.
InspectorContextual property panel.
TimelineTimeline and state-machine motion panel.
FloatingPanelGeneric draggable/resizable panel primitive used by overlays.
SelectionOverlaySelection boxes, resize handles, and rotation handles.
DotGridZoom-adaptive canvas grid.
MinimapCanvas overview.
ZoomControlsZoom buttons and fit controls.
EditorMenuBarOptional menu bar for host integrations.
HookDescription
useViewport()Zoom/pan state and helpers.
useDrag()Move, resize, and rotate interactions.
useMarquee()Marquee selection.
useMeasuredBounds()DOM-based element bounds measurement.
InteractionBehavior
Delete / BackspaceDelete selected elements
Ctrl+ZUndo
Ctrl+Y / Ctrl+Shift+ZRedo
Ctrl+ASelect all
Ctrl+DDuplicate
Ctrl+C / Ctrl+VCopy / paste
Ctrl+G / Ctrl+Shift+GGroup / ungroup
Ctrl+] / Ctrl+[Bring forward / send backward
Ctrl+Shift+] / Ctrl+Shift+[Bring to front / send to back
Arrow keysNudge by 1px
Shift+Arrow keysNudge by 10px
Ctrl+= / Ctrl+-Zoom in / out
Ctrl+0 / Ctrl+1Fit / 100% zoom
Space + dragPan
Middle-click dragPan
Right-clickContext menu
Alt+drag elementDuplicate, then drag copy
Shift+drag resize handleConstrained resize
interface BrowseImageResult {
src?: string;
ref?: string;
displayName?: string;
width?: number;
height?: number;
alt?: string;
}
type BrowseImageFn = () => Promise<BrowseImageResult | null>;
type ImageResolverFn = (ref: string) => string | Promise<string>;

Exports:

ImagePickerProvider
useImagePicker
ImageResolverProvider
useImageResolver

See Image Assets.

function v(token: string, scheme?: 'light' | 'dark'): string;
function buildThemeVars(overrides?: Record<string, string>): React.CSSProperties;
function deriveEditorTheme(contentTheme: ElucimTheme, colorScheme: 'light' | 'dark'): Record<string, string>;
function makeRotateCursor(color?: string): string;
const EDITOR_TOKENS: Record<string, string>;
const EDITOR_TOKENS_LIGHT: Record<string, string>;
const ROTATE_CURSOR: string;

See Editor Theming.

function exportToJson(document: ElucimDocument, options?: { pretty?: boolean }): string;
function importFromJson(json: string): { document: ElucimDocument | null; errors: string[] };
function downloadAsJson(document: ElucimDocument, filename?: string): void;

importFromJson() accepts and validates canonical Elucim Document JSON. Host apps should persist onDocumentChange output.

function getElementBounds(element: object):
{ x: number; y: number; width: number; height: number } | null;
function mergeBounds(boxes: Array<{ x: number; y: number; width: number; height: number }>):
{ x: number; y: number; width: number; height: number };
function isPointInBounds(
point: { x: number; y: number },
bounds: { x: number; y: number; width: number; height: number }
): boolean;
function computeSnap(value: number, gridSize: number): number;
const ELEMENT_TEMPLATES: ElementTemplate[];
function getTemplatesByCategory(): Record<string, ElementTemplate[]>;
const CATEGORY_LABELS: Record<string, string>;

Template categories are presentation, shape, line, text, math, and data.