Read the undo stack.
Read the redo stack.
Undo the previous history batch.
Redo the next history batch.
Do not save the current transaction to history.
Merge the current transaction into the previous compatible undo batch.
Start a fresh undo batch for the current transaction.
Run one update without saving it to history.
Run one update that merges into the previous compatible undo batch.
Run one update where the first write starts a fresh history batch, then the rest of the callback merges into that batch.
Configure a direct write by calling editor.update(policy) first.
editor.update({ history: "skip" }).text.insert("draft");editor.update({ history: "skip" }).text.insert("draft");Undo the previous history batch outside a larger transaction.
Redo the next history batch outside a larger transaction.
import type {
DocumentChange,
EditorEffect,
EditorSchemaIdentity,
Selection,
} from "@platejs/plite";
type History = {
readonly redos: readonly Batch[];
readonly revision: number;
readonly schema: EditorSchemaIdentity;
readonly undos: readonly Batch[];
};
type Batch = {
readonly change: DocumentChange;
readonly effects: readonly EditorEffect[];
readonly selectionAfter: Selection;
readonly selectionAfterRoot?: string;
readonly selectionBefore: Selection;
readonly selectionBeforeRoot?: string;
};import type {
DocumentChange,
EditorEffect,
EditorSchemaIdentity,
Selection,
} from "@platejs/plite";
type History = {
readonly redos: readonly Batch[];
readonly revision: number;
readonly schema: EditorSchemaIdentity;
readonly undos: readonly Batch[];
};
type Batch = {
readonly change: DocumentChange;
readonly effects: readonly EditorEffect[];
Persist the installed stacks with History.toJSON(editor). Decode them with
History.fromJSON(editor, json), then install the returned value through
tx.history.restore(...). Custom standalone effects belong to an installed
extension's effects resource so their keyed versioned codecs can decode the
batch. The version 4 envelope requires the current derived or named schema
identity and rejects null or mismatched schema semantics before decoding a
batch.
Compatible typing and same-node property updates coalesce from canonical
DocumentChange classifications and changed ranges. Grouping fingerprints are
runtime-only; loading persisted history starts a fresh automatic group.