Documentation Index
Fetch the complete documentation index at: https://superdoc-caio-sd-2929-configurable-toolbar.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
useSuperDocComments() gives you the live comments feed. ui.selection.capture() freezes the selection so a composer textarea can take focus without losing the anchor. ui.comments.createFromCapture(capture, { text }) posts the comment.
A minimal comments list
items is the array sourced from editor.doc.comments.list(). Each item is a DiscoveryItem<CommentDomain> with id, text, creatorName, creatorEmail, createdTime, parentCommentId, status, target, anchoredText.
Disable the built-in comments UI
When you’re rendering your own panel, turn off SuperDoc’s so the two don’t overlap.Add a comment from a selection
Two paths. Pick based on whether your composer takes focus from the editor.When the user clicks “Comment” with the selection still active
createFromSelection reads the live editor selection. If your button doesn’t steal focus, the selection is still there when the click handler runs.
When you open a composer with a textarea
A textarea takes focus. The editor selection clears. By the time the user presses “Post”, the live selection is gone. Capture it first.captured.target is the same shape editor.doc.comments.create({ target }) accepts. quotedText gives you the anchored text for previewing in the composer.
See the selection capture example for a runnable vanilla version: open a composer, move focus to a textarea, and post against the original selection.
Resolve and reopen
useSuperDocComments() reflects the change.
Scroll to a comment
story field, so a comment anchored in a header, footer, or note doesn’t navigate through this call. For now, scroll those manually via ui.viewport.scrollIntoView({ target: ... }) once you’ve resolved the right address yourself.
Threads and replies
Comments form threads viaparentCommentId. Each item from useSuperDocComments() carries one if it’s a reply; group your sidebar by parentCommentId to render thread roots with their replies stacked underneath.
ui.comments.reply(parentCommentId, { text }). The reply inherits the parent’s anchor, so you don’t pass a target. Empty or whitespace-only text returns a NO_OP receipt instead of hitting the API.
useSuperDocComments() includes the reply, threaded under the parent via parentCommentId. The reference demo’s ActivitySidebar ships this pattern with focus management and Ctrl/Cmd+Enter to post.
Trade-offs
useSuperDocCommentsreturns a memoized snapshot. Re-renders happen only when items, total, or activeIds change.createFromSelectionreturns{ success: false, failure: { code: 'NO_OP' } }when there’s no selection target. Guard withselection.emptyorselection.target == null.createFromCapturestays valid as long as the captured snapshot’s blocks still exist. If the user deleted the anchored text between capture and post, the post fails withINVALID_TARGET.- Multi-paragraph anchors export as one
commentRangeStart/commentRangeEndpair per comment id, conformant with ECMA-376 §17.13.4.

