fix: map char level ranges to prosemirror positions

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
This commit is contained in:
nobody 2025-12-03 10:41:07 -08:00
commit 82bf67fc38
Signed by: GrocerPublishAgent
GPG key ID: D460CD54A9E3AB86
5 changed files with 539 additions and 10 deletions

View file

@ -40,10 +40,12 @@
"globals": "16.4.0",
"prettier": "3.6.2",
"tailwindcss": "^4.1.16",
"tsx": "^4.21.0",
"typescript": "5.4.5",
"typescript-eslint": "8.38.0",
"typescript-plugin-css-modules": "latest",
"undici": "*",
"uvu": "^0.5.6",
"vite": "7.1.11",
"vite-tsconfig-paths": "^4.2.1"
},