Skip to main content

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 text mode prop to false to hide the default text comment tool.

Step 2: Install the Velt Ace extension

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

Step 4: Add a comment button to your Ace editor

  • Add a button that users can click to add comments after selecting text.

Step 5: Call addComment to add a comment

  • Call this method to add a comment to selected text in the Ace editor. You can use this when the user clicks on the comment button or presses a keyboard shortcut.
  • Params: AddCommentRequest. It has the following properties:
    • editor: instance of the Ace Editor.
    • editorId: Id of the Ace editor. Use this if you have multiple Ace editors on the same page in your app. (optional)
    • context: Add any custom metadata to the Comment Annotation. Learn more. (optional)

Step 6: Render comments in Ace editor

  • Get the comment data from Velt SDK and render it in the Ace Editor.
  • Params: RenderCommentsRequest. It has the following properties:
    • editor: Instance of the Ace Editor.
    • editorId: Id of the Ace editor. Use this if you have multiple Ace editors on the same page in your app. (optional)
    • commentAnnotations: Array of Comment Annotation objects.

Step 7: Persist Velt Comment Marks (optional)

  • By default, Velt comment marks (<velt-comment-text>) are persisted in the Ace editor by Velt SDK. When the editor loads and the Velt SDK initializes, the marks will be automatically added to the editor.
  • If you plan to store the contents of the Ace editor on your end with the comment marks already included, you can disable this feature.
  • Default: true

Step 8: Style the commented text

  • You can style the commented text by adding CSS for the velt-comment-text element.

APIs

AceVeltComments()

Initializes the Velt Comments extension for an Ace Editor instance.
  • Params: editor: Ace.Editor, config?: AceVeltCommentsConfig
    • editorId?: string - Unique identifier for this editor instance (for multi-editor scenarios)
    • persistVeltMarks?: boolean - Whether to persist Velt marks. Default: true
  • Returns: () => void - Cleanup function to remove event listeners

addComment()

Creates a comment annotation for the currently selected text in the editor.
  • Params:
  • Returns: Promise<void>

renderComments()

Renders and highlights comment annotations in the editor.