You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Three related fixes to the public scroll-to-X API surface, motivated
by an external integration where comment-panel click → editor scroll
was silently broken in flow layout and unreliable in paginated
layout.
fix(superdoc): scrollToComment delegates to scrollToElement
The previous implementation hand-rolled a DOM-only lookup
(`root.querySelector('[data-comment-ids*="..."]')` →
`scrollIntoView`). This had two failure modes:
1. Paginated/presentation layout virtualises pages — comment
highlights on offscreen pages aren't in the DOM, so the
selector misses and the call returns false even though the
comment exists in the document.
2. When two `commentMark`s share a position, SuperDoc emits a
single `.sd-editor-comment-highlight` element. Lookups for the
suppressed thread silently fail in either layout.
Route through the existing `scrollToElement` instead. It already
does the right thing for both layouts (with the flow-layout
fallback added below). The side-panel activation is preserved.
fix(superdoc): scrollToElement falls back to body-editor in flow
In flow / web layouts there is no `presentationEditor`, so
`presentationEditor.scrollToElement` returned false unconditionally
and the whole API was a no-op outside paginated mode.
When the presentation path isn't available (or returns false), walk
the ProseMirror doc directly: use `editor.commands.setCursorById`
to resolve comment and tracked-change marks (it already does the
right `findRangeById`-based lookup), then fall back to a one-pass
attr-match for block IDs (`nodeId` / `sdBlockId` / `id` /
`paraId`). Use `editor.getElementAtPos(pos)` for the DOM target so
callers benefit from the companion `Editor.getElementAtPos` fix
in the same branch.
feat(superdoc): scrollToHeading(level, ordinal, options)
New public API. Walks the ProseMirror doc counting headings of the
requested level — recognises both the `heading` node type (level
attr) and the OOXML import shape where headings are paragraphs
with `paragraphProperties.styleId = 'HeadingN'` — and scrolls to
the 1-based `ordinal`-th match.
The walk targets a position INSIDE the heading paragraph's text
content (the first text descendant), not the doc-level boundary
before the paragraph. The presentation editor's layout fragment
index only spans positions inside text content, so a boundary
position misses every fragment and `scrollToPositionAsync` returns
false. Walking one level in unblocks the print-mode path.
Verified against a Playwright probe on a 4-comment, 41-heading test
docx: flow comment-scroll went from 0/4 to 4/4 (`scrollToComment`);
heading scroll works 9/9 in both layouts at levels 1–3, ordinals
1–3. Print-mode comment scroll is unchanged at 3/4 (one residual
case where `scrollToPositionAsync` returns true but the painter
doesn't actually scroll; tracked separately as it's not in this
patch's scope).
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
0 commit comments