Skip to main content
The controller exposes navigation helpers for the everyday cases (scroll a comment or a tracked change into view, step through review). For raw element-id navigation and cross-session tracking, the host SuperDoc and the editor expose scrollToElement and PositionTracker.

Comments and tracked changes

ui.comments.scrollTo(id) and ui.trackChanges.scrollTo(id) land on a specific entity. ui.trackChanges.next() and previous() advance activeId and return the new id, but they don’t move the viewport on their own. Pair them with scrollTo to navigate.
ui.trackChanges.scrollTo is story-aware: a tracked change in a header, footer, or footnote activates the right surface before alignment. ui.comments.scrollTo is body-scoped today; non-body comment scroll lands in a follow-up.

Generic viewport scroll

ui.viewport.scrollIntoView accepts the same target shapes the doc-API uses (entity address, text address, text target). Pair it with block and behavior:
See Selection and viewport for the full target list and the not-mounted / not-ready reasons. scrollToElement takes any element ID: paragraph, comment, or tracked change: and scrolls to it. Use doc.extract() to get all IDs at once, or query.match for targeted lookups.
This is the approach to use for:
  • RAG citations: store nodeId alongside embeddings, navigate on click
  • Cross-references: link to specific paragraphs from external UI
  • Search results: scroll to the matching paragraph
  • Cross-session addressing: IDs from DOCX-imported content survive reloads
For the full extraction pattern, see content extraction for RAG. For the cross-session pattern, see cross-session block addressing.

Track nodes during edits

When users edit a document, stored positions can drift. Use PositionTracker so navigation targets stay stable within the current session.

Best practices

  • Use ui.comments.scrollTo / ui.trackChanges.scrollTo for the everyday cases. They’re the shortest path and they activate non-body surfaces correctly.
  • Use superdoc.scrollToElement when you have a stable element id from doc.extract() or the Document API (RAG citations, cross-references, search hits).
  • Use editor.positionTracker when you need to follow a node that moves during edits within the current session.
  • For cross-session use, store nodeId values (not sdBlockId: those regenerate on each open).
  • Handle missing targets gracefully: every API above returns false if the element no longer exists.