docs/solutions/logic-errors/2026-04-04-decorated-multi-leaf-text-needs-cumulative-offset-mapping.md
The first decorated-text browser proof finally hit the next real seam:
slate-browserEverything still assumed one DOM text node per Slate text node.
That was garbage.
Selections inside later decorated leaves snapped back to the first leaf or reported the wrong Slate offset.
Both directions needed cumulative offset mapping across sibling leaf segments:
slate-dom-v2 bridge:
toDOMPoint(...) and toSlatePoint(...)slate-browser semantic selection snapshots:
page-level and root-level helpersThe rule is:
[data-slate-node="text"][data-slate-string] / [data-slate-zero-width] segmentWithout that, decorated text selection is fake.
Leaf splitting changes the DOM, not the Slate path.
So the mapping cannot use raw native offsets anymore. It has to translate between:
That is the real decorated-text contract.
For any browser or DOM bridge code around decorated text:
If a selection helper or bridge reports offset 1 when you asked for offset
10, it is probably counting inside the current DOM segment instead of inside
the whole text node.