fn

createTransaction

tested

Start a transaction from the current writekit state.

Signature

ts
export function createTransaction(state: WritekitState): Transaction{ ... }

Parameters

ParameterTypeDescription
stateWritekitState

Returns

Transaction
PropertyTypeDescription
beforeWritekitState
stepsStep[]
invertedStep[]Inverse of each step, in application order (reversed when undoing).
metaMap<string, unknown>
docWritekitDocumentWorking document after the steps applied so far.
selectionSelectionSelection to apply after this transaction.
storedMarksMarks | null | undefinedundefined = leave stored marks to default handling; otherwise set them.
lastSplitIdstring | undefinedId of the block created by the most recent splitBlock.
schemaSchema
step(step: Step) => TransactionApply 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) => TransactionReplace 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) => TransactionMerge attrs into the block's existing attrs.
setBlockType(blockId: string, type: string, attrs?: Attrs) => TransactionConvert 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) => TransactionReplace 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