Editor
Editor =
object
Defined in: packages/editor/src/editor.ts:54
Properties
Section titled “Properties”dom:
EditorDom
Defined in: packages/editor/src/editor.ts:55
getSnapshot()
Section titled “getSnapshot()”getSnapshot: () =>
EditorSnapshot
Defined in: packages/editor/src/editor.ts:56
Returns
Section titled “Returns”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.
Call Signature
Section titled “Call Signature”<
TType>(type,listener,options):object
Type Parameters
Section titled “Type Parameters”TType extends "*" | "blurred" | "editable" | "focused" | "invalid value" | "mutation" | "operation" | "patch" | "read only" | "ready" | "selection" | "value changed"
Parameters
Section titled “Parameters”TType
listener
Section titled “listener”(events) => void
options
Section titled “options”true
Returns
Section titled “Returns”object
unsubscribe()
Section titled “unsubscribe()”unsubscribe: () =>
void
Returns
Section titled “Returns”void
Call Signature
Section titled “Call Signature”<
TType>(type,listener,options?):object
Type Parameters
Section titled “Type Parameters”TType extends "*" | "blurred" | "editable" | "focused" | "invalid value" | "mutation" | "operation" | "patch" | "read only" | "ready" | "selection" | "value changed"
Parameters
Section titled “Parameters”TType
listener
Section titled “listener”(event) => void
options?
Section titled “options?”batch?
Section titled “batch?”false
Returns
Section titled “Returns”object
unsubscribe()
Section titled “unsubscribe()”unsubscribe: () =>
void
Returns
Section titled “Returns”void
registerBehavior()
Section titled “registerBehavior()”registerBehavior: (
config) => () =>void
Defined in: packages/editor/src/editor.ts:60
Parameters
Section titled “Parameters”config
Section titled “config”behavior
Section titled “behavior”Behavior
Returns
Section titled “Returns”():
void
Returns
Section titled “Returns”void
registerNode()
Section titled “registerNode()”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.
Parameters
Section titled “Parameters”config
Section titled “config”Returns
Section titled “Returns”():
void
Returns
Section titled “Returns”void
send()
Section titled “send()”send: (
event) =>void
Defined in: packages/editor/src/editor.ts:71
Parameters
Section titled “Parameters”Returns
Section titled “Returns”void
Methods
Section titled “Methods”subscribe()
Section titled “subscribe()”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.
Parameters
Section titled “Parameters”observer
Section titled “observer”complete?
Section titled “complete?”() => void
error?
Section titled “error?”(err) => void
(snapshot) => void
Returns
Section titled “Returns”object
unsubscribe()
Section titled “unsubscribe()”unsubscribe: () =>
void
Returns
Section titled “Returns”void