Skip to content
This page is available as Markdown at /api/editor/type-aliases/editor.md. For the full documentation index, see /llms.txt, or the complete corpus at /llms-full.txt.

Editor

Editor = object

Defined in: packages/editor/src/editor.ts:54

dom: EditorDom

Defined in: packages/editor/src/editor.ts:55


getSnapshot: () => EditorSnapshot

Defined in: packages/editor/src/editor.ts:56

EditorSnapshot


on: {<TType>(type, listener, options): object; <TType>(type, listener, options?): object; }

Defined in: packages/editor/src/editor.ts:83

Register an event listener.

With {batch: true} the listener is called once per burst with Array<Event>, every matching event emitted before control returns to the event loop (one synchronous editor.send worth, normalization included), in delivery order, on the trailing microtask. That is the same boundary at which the editor settles its own state, so each call is one fully-applied, normalized change. Without it (the default), the listener runs synchronously for every event and receives a single event.

<TType>(type, listener, options): object

TType extends "*" | "blurred" | "editable" | "focused" | "invalid value" | "mutation" | "operation" | "patch" | "read only" | "ready" | "selection" | "value changed"

TType

(events) => void

true

object

unsubscribe: () => void

void

<TType>(type, listener, options?): object

TType extends "*" | "blurred" | "editable" | "focused" | "invalid value" | "mutation" | "operation" | "patch" | "read only" | "ready" | "selection" | "value changed"

TType

(event) => void

false

object

unsubscribe: () => void

void


registerBehavior: (config) => () => void

Defined in: packages/editor/src/editor.ts:60

Behavior

(): void

void


registerNode: (config) => () => void

Defined in: packages/editor/src/editor.ts:70

Register a node renderer. The node argument is the result of one of the defineX factories (defineContainer, defineTextBlock, defineSpan, defineBlockObject, defineInlineObject, defineDecorator, defineAnnotation). Returns a function that unregisters the node when called.

RegistrableNode

(): void

void


send: (event) => void

Defined in: packages/editor/src/editor.ts:71

EditorEvent

void

subscribe(observer): object

Defined in: packages/editor/src/editor.ts:119

Subscribe to editor state changes. The observer’s next callback fires with the current EditorSnapshot on relevant transitions (selection updates, content mutations, behavior dispatch, configuration changes).

Notifications are coalesced: a synchronous burst of transitions (e.g. the many operations one action applies, like undoing a large delete) delivers a single next with the settled snapshot on the next microtask, rather than one next per transition. The snapshot is cumulative, so only intermediate per-transition states are skipped. To observe every operation, use editor.on('operation', ...).

The editor has no terminal state and no error path, so error and complete are part of the observable contract but never fire. They are kept for structural compatibility with useSyncExternalStore, @xstate/react’s useSelector, and other observer-shaped consumers.

() => void

(err) => void

(snapshot) => void

object

unsubscribe: () => void

void