Overview
See also Editor → History management for product-neutral patterns. Here we stress who owns
undo when part of the stack is WASM and part is contenteditable.
Browser undo stack
The browser maintains its own undo history for editable regions.
Programmatic DOM updates, execCommand, and some
frameworks can clear or split that
stack—behavior varies by browser.
Model-level history
Robust editors usually implement inverse operations or
snapshots on the document model in Rust, then
re-render the DOM. Browser undo may be disabled or synchronized via beforeinput interception where supported.
Two independent undo stacks (browser + app) confuse users—pick one authoritative history for text edits.
WASM transactions
Batch model changes into transactions in Rust; expose “undo” as applying inverse ops or rolling back to a checkpoint. Crossing into JS only for DOM patches reduces mismatches.
IME & composition
Undo during IME composition is especially fragile. Often you defer history commits until composition ends—aligns with IME & composition.
Wasm guides
Editing approaches
contenteditable + WASM: source of truth, event order, DOM↔model loop, normalization, and when to call Rust.
IME & composition
composition events, syncing a Rust document model, and why the browser still owns the IME.
JS ↔ WASM boundary
Strings, copies, batched ops, async vs input events, and keeping the hot path cheap.
Clipboard & input routing
beforeinput, paste, routing decisions in JS vs sanitization in WASM.
Tooling, bundle & workers
wasm-pack, wasm-opt, code splitting, Web Workers, COOP/COEP and threads.
Collaboration & CRDT (WASM)
Yrs/y-crdt, bridging to Yjs, snapshots vs update streams with an editor host.
Selection, Range & offsets
UTF-16 vs UTF-8 indices, Selection/Range in JS, mapping to a Rust model and getTargetRanges.
Accessibility (WASM host)
Roles, focus, screen readers when the editable surface is still the browser.
Testing & debugging
E2E, profiling the JS↔WASM boundary, reproducing IME and paste in CI.
Security & deployment
CSP, SRI, module integrity, and hosting WASM next to contenteditable.