@mocanvas/editor · interface

EditorOptions

interface EditorOptions

This one ships without a description. The signature above is read from the package, and the guides cover the area it belongs to.


Properties · 19

assets?: AssetStore

Where asset bytes live. Defaults to the store's own (store.props.assets), which is where an app that built its store with createStore({ assets }) already put it — pass this only to give one editor a different store than its document has.

assetUtils?: readonly TLAssetUtilConstructorLike[]

Asset utils to register. See Editor.assetUtils.

bindingUtils?: readonly BindingUtilConstructor[]
colorScheme?: TLColorScheme

Light, dark, or follow the host window. Defaults to "light".

engine?: EngineBridge

The WebAssembly engine. Optional: when omitted, the engine registered through registerEngineProvider is used — mocanvas registers one that returns whatever loadEngine() last produced. Pass it explicitly to run two editors on separate engines.

getContainer?: () => HTMLElement

The element the editor lives in. Optional, and optional is the point: an editor with no screen — an agent on a server, a fold job, a test — has no element to give, and requiring one made the headless path start by inventing a fake DOM node. Everything inside already copes (see safeContainer); it was only the type that insisted.

Omitted, Editor.getContainer throws if anything asks for it, which is a sentence rather than a mystery further down.

getInitialMetaForShape?: (shape: UnknownShape) => UnknownShape["meta"]

The meta every newly created shape starts with — the seam an app uses to stamp provenance (author, campaign, template) onto shapes without intercepting every creation site.

getShapeVisibility?: TLGetShapeVisibility

The host's hook for hiding shapes without deleting them — layers, filters, a review mode. Consulted per shape in the render path, so it must be cheap and pure. See TLGetShapeVisibility.

initialState?: string

Id of the tool to start in. Defaults to the first tool.

initialTheme?: TLThemeId

Which theme starts out current. Defaults to "default".

options?: Partial<EditorConfig>
overlayUtils?: readonly TLAnyOverlayUtilConstructor[]

Canvas overlay painters to register with Editor.overlays.

shapeUtils: readonly ShapeUtilConstructor[]
store: EditorStore
textOptions?: TLTextOptions

Rich-text configuration. Also readable as options.text; this top-level spelling is the one the consumer passes, and the two are the same object — Editor.textOptions resolves whichever was given.

themes?: TLThemesInput

Themes to register, merged over the built-in default.

tools: readonly StateNodeConstructor[]
user?: CurrentUser

Who is using this editor, as the owner of their preferences — the *controlled* form: an app that holds the preferences in its own state passes them in and gets every write back, instead of the editor keeping a copy the app cannot see. Defaults to an editor-owned atom.

userStore?: UserStore

Where the editor asks about people, for attribution. Optional: with no store, getAttributionUser answers null and display names fall back to the id, which is exactly what a single-player board wants.

mocanvas is built by Symbio. Free for non-commercial, non-profit and development use; commercial use needs an agreement. Not affiliated with or endorsed by tldraw.