Return whether the undo branch has a surviving mapped batch.
Return whether the redo branch has a surviving mapped batch.
Return the replay direction currently waiting for a live-session owner. Pending state belongs to this editor runtime and is not included in History JSON, snapshots, or collaboration.
Use editor.read.history().undos and editor.read.history().redos when you need
the full immutable arrays. The same group is available as state.history inside
editor.read((state) => ...).
Claim and replay the current undo batch.
Claim and replay the current redo batch.
type HistorySettlement =
| Readonly<{ status: "applied" }>
| Readonly<{ reason: string; status: "blocked" }>
| Readonly<{ status: "failed" }>;
type HistoryResult =
| HistorySettlement
| Readonly<{ status: "busy" | "empty" }>
| Readonly<{ conflicts: readonly string[]; status: "blocked" }>
| Readonly<{ settled: Promise<HistorySettlement>; status: "pending" }>;type HistorySettlement =
| Readonly<{ status: "applied" }>
| Readonly<{ reason: string; status: "blocked" }>
| Readonly<{ status: "failed" }>;
type HistoryResult =
| HistorySettlement
| Readonly<{ status: "busy" | "empty" }>
| Readonly<{ conflicts: readonly string[]; status: "blocked" }>
| Readonly<{ settled: Promise<HistorySettlementBoth methods claim the current branch head and return synchronously. A document
batch has applied when the call returns. A live-session batch whose owner is
still working returns pending and publishes its pending direction until
settled resolves; settled never rejects. Document edits, selection updates,
and collaborative imports continue during that wait; another replay returns
busy without claiming a batch.
blocked reports a refusal from the live-session owner. failed means the owner or the settlement threw; the error
goes to the editor's lifecycleErrorSink. With no sink, it goes to
reportError, or to console.error where reportError does not exist.
blocked and failed both keep that batch at the branch head. Invalid runtime
use, such as a replay inside an active read or update, throws. Replay always applies the
complete document-wide batch, including changes in other roots.
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");import type {
DocumentChange,
EditorEffect,
EditorSchemaIdentity,
Selection,
} from "plitejs";
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 "plitejs";
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
plugin'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.