-
Notifications
You must be signed in to change notification settings - Fork 2
Editor State Reference
Jayden Smith edited this page Apr 12, 2026
·
2 revisions
type Selection =
| { type: 'text'; anchor?: number; head?: number }
| { type: 'node'; pos?: number }
| { type: 'all' };| Variant | Fields | Meaning |
|---|---|---|
text |
anchor?: number, head?: number
|
Text range or caret selection. |
node |
pos?: number |
Selected node position. |
all |
none | Entire document selected. |
interface ActiveState {
marks: Record<string, boolean>;
markAttrs: Record<string, Record<string, unknown>>;
nodes: Record<string, boolean>;
commands: Record<string, boolean>;
allowedMarks: string[];
insertableNodes: string[];
}| Field | Type | Meaning |
|---|---|---|
marks |
Record<string, boolean> |
Currently active marks at the selection. |
markAttrs |
Record<string, Record<string, unknown>> |
Attributes of the currently active marks. For example, when the selection is inside a link, markAttrs.link.href contains the URL. |
nodes |
Record<string, boolean> |
Currently active node context. |
commands |
Record<string, boolean> |
Currently available commands such as list wrapping or indent/outdent. |
allowedMarks |
string[] |
Marks allowed by the schema at the current selection. |
insertableNodes |
string[] |
Nodes that may be inserted at the current selection. |
interface HistoryState {
canUndo: boolean;
canRedo: boolean;
}| Field | Type | Meaning |
|---|---|---|
canUndo |
boolean |
Whether undo is currently available. |
canRedo |
boolean |
Whether redo is currently available. |
interface EditorUpdate {
renderElements: RenderElement[];
selection: Selection;
activeState: ActiveState;
historyState: HistoryState;
}| Field | Type | Meaning |
|---|---|---|
renderElements |
RenderElement[] |
Native render tree description generated by the Rust core. |
selection |
Selection |
Current selection state. |
activeState |
ActiveState |
Current active marks, nodes, commands, and schema availability. |
historyState |
HistoryState |
Current undo and redo availability. |
type RenderMark = string | { type: string; [key: string]: unknown };
interface RenderElement {
type:
| 'textRun'
| 'blockStart'
| 'blockEnd'
| 'voidInline'
| 'voidBlock'
| 'opaqueInlineAtom'
| 'opaqueBlockAtom';
text?: string;
marks?: RenderMark[];
nodeType?: string;
depth?: number;
docPos?: number;
label?: string;
attrs?: Record<string, unknown>;
listContext?: ListContext;
}| Field | Type | Meaning |
|---|---|---|
type |
union | Render element kind. |
text |
string | undefined |
Text content for text runs. |
marks |
RenderMark[] | undefined |
Active marks on a text run. Each entry is either a string (mark name without attributes) or an object { type: string; [key: string]: unknown } (mark name with attributes, e.g. a link mark carrying href). |
nodeType |
string | undefined |
Node type associated with the element. |
depth |
number | undefined |
Nesting depth in the render tree. |
docPos |
number | undefined |
Associated document position when available. |
label |
string | undefined |
Optional display label for opaque atoms. |
attrs |
Record<string, unknown> | undefined |
Schema attributes for opaque atom nodes (e.g. src, alt on images, or id on mentions). |
listContext |
ListContext | undefined |
List metadata for native marker rendering. |
interface ListContext {
ordered: boolean;
index: number;
total: number;
start: number;
isFirst: boolean;
isLast: boolean;
}| Field | Type | Meaning |
|---|---|---|
ordered |
boolean |
Whether the list is ordered. |
index |
number |
Zero-based item index within the list. |
total |
number |
Total items in the current list. |
start |
number |
Ordered-list start number. |
isFirst |
boolean |
Whether this is the first list item. |
isLast |
boolean |
Whether this is the last list item. |
interface DocumentJSON {
[key: string]: unknown;
}DocumentJSON is intentionally loose because the exact document shape depends on the active schema.
Copyright © 2026 Apollo Health Group Pty. Ltd.