ProseMirror's document model is a tree structure where positions are
calculated by traversing nodes, accounting for structural elements
(opening/closing tags of nodes like paragraphs, lists, etc.). A position
in ProseMirror is not "character index N". Structual boundaries like
"start of paragraph" also get their own index. A document with two
paragraphs "ab" and "cd" has positions:
0 1 2 3 4 5 6 7 8
<p> a b </p><p> c d </p>
So when I serialize a ProseMirror document to plain text for external
processing:
01 234
"ab\ncd"
I need to save this mapping information so when the external system
says "there's something interesting at characters [3,4]", I can map that
back to ProseMirror positions to do something useful: highlighting,
applying marks, or making selections.
fix: measure site visits