Commit 6de21f6
fix(super-editor): resolve child element in Editor.getElementAtPos
`view.domAtPos(pos)` returns `{node, offset}` where `node` is an
element parent and `offset` is the child index when the position
sits between block children. The previous implementation returned
the parent directly, which for the editor root collapses every
position into "the entire document" — `scrollIntoView()` on that
element always lands at the top of the editor regardless of which
heading or paragraph was requested.
Resolve to `parent.childNodes[offset]` (clamped) when the returned
node is an element parent. The text-node branch is unchanged. This
fixes web/flow-layout `getElementAtPos` for positions on block
boundaries; the presentation-editor branch isn't touched.
Verified with a probe that calls the body-editor `getElementAtPos`
for known heading positions (2725, 3513, 4477, 13264) — before
this fix all four returned the same ProseMirror root DIV; after,
each returns the actual heading's wrapper element.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>1 parent a6a6654 commit 6de21f6
1 file changed
Lines changed: 23 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1718 | 1718 | | |
1719 | 1719 | | |
1720 | 1720 | | |
1721 | | - | |
1722 | | - | |
1723 | | - | |
| 1721 | + | |
| 1722 | + | |
| 1723 | + | |
| 1724 | + | |
| 1725 | + | |
| 1726 | + | |
| 1727 | + | |
| 1728 | + | |
| 1729 | + | |
| 1730 | + | |
| 1731 | + | |
| 1732 | + | |
| 1733 | + | |
| 1734 | + | |
| 1735 | + | |
| 1736 | + | |
| 1737 | + | |
| 1738 | + | |
| 1739 | + | |
| 1740 | + | |
| 1741 | + | |
| 1742 | + | |
1724 | 1743 | | |
1725 | | - | |
| 1744 | + | |
1726 | 1745 | | |
1727 | 1746 | | |
1728 | 1747 | | |
| |||
0 commit comments