fn
createTransaction
testedStart a transaction from the current writekit state.
Signature
ts
export function createTransaction(state: WritekitState): Transaction{ ... }Parameters
| Parameter | Type | Description |
|---|---|---|
state | WritekitState | — |
Returns
Transaction| Property | Type | Description |
|---|---|---|
before | WritekitState | — |
steps | Step[] | — |
inverted | Step[] | Inverse of each step, in application order (reversed when undoing). |
meta | Map<string, unknown> | — |
doc | WritekitDocument | 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 splitBlock. |
schema | Schema | — |
step | (step: Step) => Transaction | Apply a raw step (also used by undo/redo to replay stored steps). |
insertText | (pos: Position, text: string, marks?: Marks) => Transaction | — |
insertInline | (pos: Position, content: Inline) => Transaction | — |
deleteText | (blockId: string, from: number, to: number) => Transaction | — |
replaceInline | (blockId: string, from: number, to: number, content: Inline) => Transaction | — |
setBlockContent | (blockId: string, content: Inline) => Transaction | Replace a block's entire inline content (used by the input flush path). |
addMark | (blockId: string, from: number, to: number, mark: Mark) => Transaction | — |
removeMark | (blockId: string, from: number, to: number, mark: Mark) => Transaction | — |
setAttrs | (blockId: string, attrs: Attrs) => Transaction | Merge attrs into the block's existing attrs. |
setBlockType | (blockId: string, type: string, attrs?: Attrs) => Transaction | Convert a block to another type, preserving its inline content. |
splitBlock | (pos: Position, newType?: string, newAttrs?: Attrs, newId?: string) => Transaction | — |
mergeBlock | (blockId: string, intoId: string) => Transaction | — |
insertBlock | (node: Node, index: number) => Transaction | — |
removeBlock | (blockId: string) => Transaction | — |
moveBlock | (blockId: string, toIndex: number) => Transaction | — |
setDoc | (doc: WritekitDocument) => Transaction | Replace the whole document (used to apply a remote CRDT snapshot). |
setSelection | (selection: Selection) => Transaction | — |
setStoredMarks | (marks: Marks | null) => Transaction | — |
setMeta | (key: string, value: unknown) => Transaction | — |
getMeta | (key: string) => unknown | — |