C
Transaction
testedA mutable builder that accumulates atomic {@link Step}s over a working copy of the document. Each builder method applies its step immediately (so later builders see prior effects) and records the exact inverse for undo. Dispatch turns the finished transaction into a new {@link EditorState}.
Signature
ts
class TransactionProperties
| Property | Type | Description |
|---|---|---|
beforereadonly | EditorState | — |
stepsreadonly | Step[] | — |
invertedreadonly | Step[] | Inverse of each step, in application order (reversed when undoing). |
metareadonly | Map<string, unknown> | — |
doc | EditorDocument | Working document after the steps applied so far. |
selection | Selection | Selection to apply after this transaction. |
storedMarks | Marks | null | undefined | `undefined` = leave stored marks to default handling; otherwise set them. |
lastSplitId | string | undefined | Id of the block created by the most recent {@link splitBlock}. |
Methods
stepApply a raw step (also used by undo/redo to replay stored steps).
ts
step(step: Step): this| Parameter | Type | Description |
|---|---|---|
step | Step | — |
Returns
thisinsertTextts
insertText(pos: Position, text: string, marks: Marks = []): this| Parameter | Type | Description |
|---|---|---|
pos | Position | — |
text | string | — |
marks? | Marks | — |
Returns
thisinsertInlinets
insertInline(pos: Position, content: Inline): this| Parameter | Type | Description |
|---|---|---|
pos | Position | — |
content | Inline | — |
Returns
thisdeleteTextts
deleteText(blockId: string, from: number, to: number): this| Parameter | Type | Description |
|---|---|---|
blockId | string | — |
from | number | — |
to | number | — |
Returns
thisreplaceInlinets
replaceInline(blockId: string, from: number, to: number, content: Inline): this| Parameter | Type | Description |
|---|---|---|
blockId | string | — |
from | number | — |
to | number | — |
content | Inline | — |
Returns
thissetBlockContentReplace a block's entire inline content (used by the input flush path).
ts
setBlockContent(blockId: string, content: Inline): this| Parameter | Type | Description |
|---|---|---|
blockId | string | — |
content | Inline | — |
Returns
thisaddMarkts
addMark(blockId: string, from: number, to: number, mark: Mark): this| Parameter | Type | Description |
|---|---|---|
blockId | string | — |
from | number | — |
to | number | — |
mark | Mark | — |
Returns
thisremoveMarkts
removeMark(blockId: string, from: number, to: number, mark: Mark): this| Parameter | Type | Description |
|---|---|---|
blockId | string | — |
from | number | — |
to | number | — |
mark | Mark | — |
Returns
thissetAttrsMerge `attrs` into the block's existing attrs.
ts
setAttrs(blockId: string, attrs: Attrs): this| Parameter | Type | Description |
|---|---|---|
blockId | string | — |
attrs | Readonly<Record<string, import("..").AttrValue>> | — |
Returns
thissetBlockTypeConvert a block to another type, preserving its inline content.
ts
setBlockType(blockId: string, type: string, attrs?: Attrs): this| Parameter | Type | Description |
|---|---|---|
blockId | string | — |
type | string | — |
attrs? | Readonly<Record<string, import("..").AttrValue>> | undefined | — |
Returns
thissplitBlockts
splitBlock(pos: Position, newType?: string, newAttrs?: Attrs, newId: string = createId()): this| Parameter | Type | Description |
|---|---|---|
pos | Position | — |
newType? | string | undefined | — |
newAttrs? | Readonly<Record<string, import("..").AttrValue>> | undefined | — |
newId? | string | — |
Returns
thismergeBlockts
mergeBlock(blockId: string, intoId: string): this| Parameter | Type | Description |
|---|---|---|
blockId | string | — |
intoId | string | — |
Returns
thisinsertBlockts
insertBlock(node: Node, index: number): this| Parameter | Type | Description |
|---|---|---|
node | Node | — |
index | number | — |
Returns
thisremoveBlockts
removeBlock(blockId: string): this| Parameter | Type | Description |
|---|---|---|
blockId | string | — |
Returns
thismoveBlockts
moveBlock(blockId: string, toIndex: number): this| Parameter | Type | Description |
|---|---|---|
blockId | string | — |
toIndex | number | — |
Returns
thissetDocReplace the whole document (used to apply a remote CRDT snapshot).
ts
setDoc(doc: EditorDocument): this| Parameter | Type | Description |
|---|---|---|
doc | EditorDocument | — |
Returns
thissetSelectionts
setSelection(selection: Selection): this| Parameter | Type | Description |
|---|---|---|
selection | Selection | — |
Returns
thissetStoredMarksts
setStoredMarks(marks: Marks | null): this| Parameter | Type | Description |
|---|---|---|
marks | Marks | null | — |
Returns
thissetMetats
setMeta(key: string, value: unknown): this| Parameter | Type | Description |
|---|---|---|
key | string | — |
value | unknown | — |
Returns
thisgetMetats
getMeta(key: string): unknown| Parameter | Type | Description |
|---|---|---|
key | string | — |
Returns
unknown