/** * Unit-sequence diff for the editor's incremental structural repaint. * * After a structural op (insert table/row, footnote, delete block, undo/redo) * the editor fetches the session's {@link RenderPlan} (`ListBlocks`) and diffs * each container's unit sequence against the DOM's, so unchanged blocks keep * their DOM nodes and only changed/created units re-render — replacing the * whole-document remount that cost seconds on large documents. * * Pure functions only: DOM walking, rendering, and fallback policy live in * `editor.ts` (`DocxEditor.reconcile`). */ /** One top-level render unit: a body block (`p`/`h`/`li`), one whole table * (`tbl`), or one footnote/endnote definition (`fn`/`en`). Mirrors the wire * shape of `DocxSessionBridge.ListBlocks`. `sig` (container units only) is a * content signature: a table or note keeps its unid when content INSIDE it * changes, so the diff tokens must include it or a changed container would be * kept stale. */ export interface RenderUnit { id: string; kind: string; sig?: string; } /** The diff token for a unit: unid plus the container content signature. The DOM * side composes the same token from a node's `data-anchor` + `data-render-sig` * stamp, so a container whose inside changed diffs as an in-place substitution. */ export declare function tokenOf(unit: RenderUnit): string; /** Per-container render plan — the wire shape of `DocxSessionBridge.ListBlocks`. */ export interface RenderPlan { body: RenderUnit[]; footnotes: RenderUnit[]; endnotes: RenderUnit[]; } export interface UnitDiff { /** newIndex → oldIndex for units that keep their existing DOM node. */ keep: Map; /** Indices into the OLD DOM sequence whose nodes must be removed. */ removed: number[]; /** Indices into the NEW plan that need a fresh render. */ added: number[]; /** * added/removed pairs that are an IN-PLACE change (same number of kept units * on each side) — e.g. a text edit re-hashing a block's content-addressed * unid. A substituted list item keeps its list position, so it renumbers no * siblings and may reconcile where a pure li insert/remove may not. */ substituted: Array<{ oldIndex: number; newIndex: number; }>; /** Exact-token units whose existing DOM node moves to a new document slot. */ moved: Array<{ oldIndex: number; newIndex: number; }>; } /** unid ("a1b2…") from a full anchor id ("p:body:a1b2…"). */ export declare function unidOf(id: string): string; /** * LCS diff of the DOM's unit-token sequence against the new plan's. Old entries * are tokens (see {@link tokenOf} — bare unids for leaf blocks, `unid|sig` for * containers). Equal tokens are interchangeable (content-addressed: equal token * ⇒ equal content ⇒ equal rendering, up to position-dependent chrome the caller * handles). O(n·m) — sequences are document block counts, a few hundred. */ export declare function diffUnits(oldUnids: string[], newUnits: RenderUnit[]): UnitDiff; /** * Whether this diff must fall back to a full remount: * - a PURE li insert or removal (not an in-place substitution) — sibling list * items renumber without their own XML changing, which a unit diff cannot see; * - total churn above `threshold` (a remount is cheaper and simpler than * rendering half the document block-by-block). * * `oldKinds[i]` is the kind of the old sequence's i-th unit (the DOM knows it). * An li substitution deliberately does NOT force a remount — its list position * is unchanged; the CALLER must still verify its list facts (numId/ilvl) * survived, and remount when they changed. */ export declare function needsRemount(diff: UnitDiff, newUnits: RenderUnit[], oldKinds: string[], threshold?: number): boolean; //# sourceMappingURL=editor-reconcile.d.ts.map