Skip to content

API overview

Three packages. core is the only one that is required.

PackageContentsRuntime dependencies
@headless-canvas/coreEditor, shapes, state, transforms, tools, control primitivesNone
@headless-canvas/uiDefault controls, stylesheet, clipboard bindingcore
@headless-canvas/reactReact bindingscore, ui, react

@headless-canvas/core

AreaExports
EditorEditor, EditorOptions, CreateShapeInput, ZIndexAnchor
ControlsControls, HandleId, HandleDescriptor, SelectionBoxDescriptor, A11yShapeDescriptor, RESIZE_HANDLES
ShapesShapeUtil, ShapeUtilRegistry, ShapeRegistry, ShapeBase, AnyShape, ShapeId, ZIndex, asShapeId, asZIndex, RenderInfo, the seven built-in *ShapeUtils, defaultShapeUtils
Shape propsRectProps, EllipseProps, LineProps, PathProps, TextProps, ImageProps, GroupProps, Fill, Stroke, Shadow, PaintProps, GradientStop
PaintingresolveFill, applyStrokeStyle, applyShadow, paintPath, fontString
GeometrypointInPolygon, distanceToSegment, distanceToPolyline, parsePath, emitPath, pathData, flattenPath, pathBounds, simplifyPolyline, polylineToPath, PathCommand, PathSink
MathsVec, Bounds, OrientedBounds, Matrix and their operations
ViewportCamera, screenToWorldPoint, worldToScreenPoint, cameraMatrix, visibleBounds, clampZoom, DEFAULT_ZOOM_RANGE
TransformsdecomposeTransform, worldTransformOf, worldCorners, inheritedOpacity
StateStore, StoreSnapshot, TransactOptions, CommitEvent, Patch, invertPatch, invertPatches
HistoryHistory, HistoryEntry, HistoryOptions
DocumentsHcDocument, SCHEMA_VERSION, serialize, deserialize, SerializeOptions, DeserializeResult
RenderingRenderer, RenderItem, RenderScene, Canvas2dRenderer, worldAabb, exportToBlob, ExportOptions, HcTaintedCanvasError
SVG exportexportToSvg, SvgExportOptions, SvgExportParams, SvgNode, SvgRenderInfo
ResourcesResourceCache, ResourceCacheOptions, ResourceStatus, ResourceRequest
ToolsTool, ToolState, HcPointerEvent, SelectTool, HandTool, DrawTool, DrawToolOptions, defaultDrawOptions, strokeFromPoints, StrokeGeometry
SnappingSnapSettings, SnapGuide, SnapResult, defaultSnapSettings
NotificationsNotification, NotificationEmitter
i18nMessages, defaultMessages, formatMessage
UtilitiescreateId, RTree, SpatialIndex, compareIndexes, generateIndexBetween, generateNIndexesBetween, DEV

@headless-canvas/ui

ts
function createDefaultControls(
  editor: Editor,
  options?: { accessibleList?: boolean },
): { dispose(): void }

function createClipboardBinding(
  editor: Editor,
  options?: ClipboardBindingOptions,
): ClipboardBinding

function createTextEditor(
  editor: Editor,
  options?: { submitOnEnter?: boolean },
): { dispose(): void }

Plus the stylesheet, imported from its own subpath so it is never injected at runtime:

ts
import '@headless-canvas/ui/styles.css'

The class names and data attributes it defines are public API — see the CSS contract.

@headless-canvas/react

See the React reference.

Stability

Everything on these pages follows semver from v1.0. So does the CSS contract: renaming a class or a data attribute is a breaking change, exactly as renaming a method would be.

Anything not documented here is internal, whatever its export status.

During the 0.x series, minor versions may contain breaking changes; they will be listed in the changelog.

Released under the MIT License.