Skip to content

invertOp

function invertOp(op, before):
| TransactionOp
| TransactionOp[]
| null;

Defined in: invert.ts:60

Compute the inverse of a single op given the state immediately before it was applied. Returns the op (or ops) that map applyOp(before, op) back to before, an empty array when the op has no document effect to undo (e.g. setSelection), or null when the op cannot be faithfully inverted because the data it touched is absent from before.

Every embedded block / span carried into an inverse op is deep-cloned so the inverse never aliases live editor state.

ParameterType
opTransactionOp
beforeEditorState

| TransactionOp | TransactionOp[] | null