super-productivity/packages/plugin-dev/document-mode
Johannes Millan 17c6eae37c fix(document-mode): correct slash-menu anchor + guard posAtDOM -1
Two issues hit when the gutter "+" inserts a paragraph and then opens
the slash menu, and when clicks land on a hovered block that has
already been re-rendered:

- Slash menu landed in the top-left corner because the anchor used
  getRangeAt(0).getBoundingClientRect(), which returns a zero rect at
  (0, 0) for empty blocks (which is what we just inserted). Switch
  the slash-menu anchor to editor.view.coordsAtPos(selection.from)
  via a new caretRect() helper — ProseMirror always returns real
  coords there. The same helper is now used by the slash-menu
  keyboard handlers (arrow keys, backspace, typing filter) so the
  menu stays anchored consistently.

- Uncaught "Position -1 out of range" came from
  editor.view.posAtDOM(hoveredBlock, 0) returning -1 when the hovered
  block was unmapped between hover and click (e.g. doc re-rendered,
  block replaced). The gutter "+" and openBlockMenu both blindly
  passed that value to doc.resolve, which threw. Bail when pos < 0,
  and also when the resolved position has depth 0 (no enclosing
  block, no nodePos to compute).
2026-05-21 18:47:14 +02:00
..
scripts feat(document-mode): add TipTap-based document-mode plugin (POC) 2026-05-21 17:22:31 +02:00
src fix(document-mode): correct slash-menu anchor + guard posAtDOM -1 2026-05-21 18:47:14 +02:00
.gitignore feat(document-mode): add TipTap-based document-mode plugin (POC) 2026-05-21 17:22:31 +02:00
package-lock.json feat(document-mode): Notion-style UX (gutter, bubble menu, block menu) 2026-05-21 17:34:13 +02:00
package.json feat(document-mode): Notion-style UX (gutter, bubble menu, block menu) 2026-05-21 17:34:13 +02:00
tsconfig.json feat(document-mode): add TipTap-based document-mode plugin (POC) 2026-05-21 17:22:31 +02:00