Skip to main content
The SuperDoc integration renders Velt comment highlights as view-only overlay elements positioned over the commented text. It does not write Velt comment marks into your DOCX content. Comment anchors are stored as a durable text and occurrence pair, then resolved against the live SuperDoc document whenever comments render.

Setup

Step 1: Add Comment components

  • Add the Velt Comments component to the root of your app.
  • This component is required to render comments in your app.
  • Set the textMode prop to false to hide the default text comment tool.

Step 2: Install the Velt SuperDoc extension

SuperDoc is browser-only because it touches window and the DOM. Import its stylesheet globally, then dynamically import the SuperDoc SDK and Velt extension inside a client-side effect.

Step 3: Configure the SuperDoc editor with the Velt Comments extension

Create the SuperDoc editor, disable SuperDoc’s built-in comments, then attach SuperDocVeltComments from the editor’s onReady callback.

Step 4: Add a comment button to your SuperDoc editor

Add a button users can click after selecting text in the SuperDoc editor. Use onMouseDown with preventDefault() so clicking the button does not clear the current editor selection before addComment reads it. Keep the actual addComment call in onClick.

Step 5: Call addComment to add a comment

  • Call this method to add a comment to selected text in the SuperDoc editor.
  • Params: AddCommentArgs. It has the following properties:
    • instance: SuperDoc editor instance returned by new SuperDoc(...).
  • Returns: Promise<AddCommentResult | null>. It returns null if no text is selected or Velt is not loaded.
To scope comments to a specific editor on pages with multiple SuperDoc instances, pass an editor id when attaching the extension:

Step 6: Render comments in the SuperDoc editor

  • Get the comment data from Velt SDK and render it in the SuperDoc editor.
  • Params: RenderCommentsArgs. It has the following properties:
    • instance: SuperDoc editor instance.
    • commentAnnotations: Array of Comment Annotation objects.
Highlights are view-only. The library re-derives each highlight from its TextEditorConfig anchor and remaps live ranges as the document changes. You do not need to call renderComments on every edit, scroll, zoom, or resize. Re-run it when Velt’s annotation list changes.

Step 7: Clean up the SuperDoc extension

SuperDocVeltComments.configure(...).attach(instance) returns an AttachedExtension. Call detach() in your effect cleanup to remove listeners, clear per-instance state, and remove overlay elements before destroying the editor.

Step 8: Style the commented text

  • You can style commented text by adding CSS for the velt-comment-text element.
  • SuperDoc highlights are light-DOM overlay elements inside div.velt-superdoc-overlay-root, so a global stylesheet can reach them.
  • The default highlight rules use inline !important styles, so overrides should use !important.

Complete Example

APIs

SuperDocVeltComments

Creates the Velt Comments extension for a SuperDoc editor. Use SuperDocVeltComments.configure(...).attach(instance) to attach it to an editor instance.

addComment()

Creates a comment annotation for the currently selected text in the SuperDoc editor.
  • Signature: async (args: AddCommentArgs) => Promise<AddCommentResult | null>
  • Params: args: AddCommentArgs
  • Returns: Promise<AddCommentResult | null>; see AddCommentResult.

renderComments()

Renders and updates Velt comment highlights in the SuperDoc editor.