import { VeltComments, useVeltClient } from '@veltdev/react';

import { useEffect } from 'react'

export default function YourDocument() {
  const { client } = useVeltClient();  

  useEffect(()=>{
    if(client){
      const commentElement = client.getCommentElement();
      commentElement.enableAutoCategorize(); // 1
      commentElement.disableAutoCategorize(); // 1
      // 2
      commentElement.setCustomCategory([
         {
              "id": "bug",  
              "name": "Bug",
              "color": "red"
          }
      ])
      commentElement.enablePriority(); // 3
      commentElement.disablePriority(); // 3
      // 4
      commentElement.setCustomPriority([
          {
              "id": "low",
              "name": "Low",
              "color": "red",
              "lightColor": "pink"
          }
      ])
      commentElement.enableStatus(); // 5
      commentElement.disableStatus(); // 5
      commentElement.setCustomStatus([
          {
              "id": "open",
              "name": "Open",
              "color": "white",
              "lightColor":"green",
              "type": "default",
              "svg": "<svg></svg>" // Pass in a serialized SVG
          }
      ])
      commentElement.enableResolveButton(); // 7
      commentElement.disableResolveButton(); // 7
      commentElement.enableModeratorMode(); // 8 
      commentElement.disableModeratorMode(); // 8
      commentElement.enableSuggestionMode(); // 9
      commentElement.disableSuggestionMode(); // 9
      commentElement.enableSignInButton(); // 10 
      commentElement.disableSignInButton(); // 10
      commentElement.enablePrivateCommentMode(); // 13
      commentElement.disablePrivateCommentMode(); // 13
      commentElement.enableUserMentions(); // 14
      commentElement.disableUserMentions(); // 14


    }
  })

  return (
    <div>

        <VeltComments          
            autoCategorize={true} {/* 1 */}
            {/* 2 */}
            customCategory={[
                {
                    "id": "bug",
                    "name": "Bug",
                    "color": "red"
                }
            ]}
            priority={true} {/* 3 */}
            {/* 4 */}
            customPriority={[
                {
                    "id": "low",
                    "name": "Low",
                    "color": "red",
                    "lightColor": "pink"
                }
            ]}
            status={true} {/* 5 */}
            {/* 6 */}
            customStatus = {[
                {
                    "id": "open",
                    "name": "Open",
                    "color": "white",
                    "lightColor":"green",
                    "type": "default",
                    "svg": "<svg></svg>" // Pass in a serialized SVG
                }
            ]}
            resolveButton={true} {/* 7 */}
            moderatorMode={true} {/* 8 */}
            suggestionMode={true} {/* 9 */}
            onCommentAccept={(event)=>yourMethod(event)} {/* 10 */}
            onCommentReject={(event)=>yourMethod(event)} {/* 10 */}
            signInButton={true} {/* 11 */}
            onSignIn={() => yourSignInMethod()} {/* 12 */}
            privateCommentMode={true} {/* 13 */}
            userMentions={false} {/* 14 */}


        />
    </div>
1

AI auto categorization of comments

Whether AI auto-categorization of comments is enabled.

Default: false

We use AI to analyze your comment content and auto-categorize it so users can filter comments easily. You can provide a list of custom categories that we should use to categorize the comments (shown below).

<VeltComments autoCategorize={true} />

API Method:

const commentElement = client.getCommentElement();
commentElement.enableAutoCategorize();
commentElement.disableAutoCategorize();
2

Set Custom Categories

Pass custom categories in the customCategory prop.

Default categories: Question, Feedback, Bug, Other.

With custom categories, you can replace the default categories with your own values.

These categories are used in the Comments Sidebar to filter comments by category. The AI autoCategorize feature uses the list of categories to determine the closest category to choose from.

The input format to the customCategory prop should be an array of objects with an id, name, and color.

The color property is used to set the category pill background color.

<VeltComments customCategory={[
  {
    "id": "bug",
    "name": "Bug",
    "color": "red"
  }
]}/>

API Method:

const commentElement = client.getCommentElement();
commentElement.setCustomCategory([
  {
    "id": "bug",
    "name": "Bug",
    "color": "red"
  }
])

Make sure to have at least 2 categories set.

3

Priority

Whether to enable setting priority on comments.

Default: false

When this is on, users can assign a priority to each comment & filter comment by priority in the sidebar. You can customize the list of priority options as shown later on this page in the Set Custom Priorities section.

<VeltComments priority={true} />

API Method:

const commentElement = client.getCommentElement();
commentElement.enablePriority();
commentElement.disablePriority();
4

Set Custom Priorities

Pass custom priorities in the customPriority prop.

Default priorities: P0, P1, P2

With custom priorities, you can replace the default priorities with your own values. These priorities are also used in the comment sidebar to filter comments by priority.

This will work if you have enabled the priority feature.

The color property is used to set the priority pill background color.

The lightColor property sets the background color of the filter.


<VeltComments customPriority={[
  {
    "id": "low",
    "name": "Low",
    "color": "red",
    "lightColor": "pink",
  },
]}/>

API Method:

const commentElement = client.getCommentElement();
commentElement.setCustomPriority([
  {
    "id": "low",
    "name": "Low",
    "color": "red",
    "lightColor": "pink",
  },
])

Make sure to have at least 2 categories set.

5

Status

Whether to enable the default status dropdown & filters.

Default: true

When this is on, users can assign a status to each comment & filter comment by status in the sidebar. You can customize the list of status options as shown below on this page.

<VeltComments status={true} />

API Method:

const commentElement = client.getCommentElement();
commentElement.enableStatus();
commentElement.disableStatus();
6

Set Custom Statuses

Set custom statuses in the customStatus prop.

Default statuses: Open, In Progress, Resolved

With custom statuses, you can replace the default statuses with your own values. These statuses are also used in the comment sidebar to filter comments by status.

Setting the Status type using the type property:

  • default: This will be the default status assigned to each comment.
  • ongoing: This is treated as an intermediary status, you can add as many statuses with type ongoing as you want.
  • terminal: This represents a status that is completed. Comments with this status type are no longer shown in the DOM.

Setting the Status Icon using the svg property:

  • You can pass in a serialized SVG. We automatically parse and colorize SVGs. If instead you pass in an icon URL, you will have to colorize each icon yourself to match the status color.
<VeltComments customStatus={[
  {
    "id": "open",
    "name": "Open",
    "color": "white",
    "lightColor":"green",
    "type": "default",
    "svg": "<svg></svg>" // Pass in a serialized SVG
  }
]}/>

API Method:

const commentElement = client.getCommentElement();
commentElement.setCustomStatus([
  {
    "id": "open",
    "name": "Open",
    "color": "white",
    "lightColor":"green",
    "type": "default",
    "svg": "<svg></svg>" // Pass in a serialized SVG
  }
])

Make sure to have at least 2 categories set.

7

Resolve button

Whether to show resolve button on comments.

Default: true

This adds a tick mark button on the top right corner of the comment dialog. Clicking on this button will mark the comment as resolved.

<VeltComments resolveButton={true} />

API Method:

const commentElement = client.getCommentElement();
commentElement.enableResolveButton();
commentElement.disableResolveButton();
8

Moderator mode

Whether comments require moderator approval.

Default: false

By default, when a user adds a comment it is visible to all authenticated users on the same document. Moderator mode makes visibility of all comments private to only admin users and the comment author. Admin users will see an approve button on the comment dialog. Once approved the comment will be visible to all users who can access the document.

You can set some users as admin by setting the isAdmin property in the User object, during the identify() call.

<VeltComments moderatorMode={true} />

API Method:

const commentElement = client.getCommentElement();
commentElement.enableModeratorMode();
commentElement.disableModeratorMode();
9

Ability to accept or reject comments

Whether to enable suggestion mode to accept or reject comments.

Default: false

To accept comments, set the suggestionMode attribute to true.

<VeltComments suggestionMode={true} />

API Method:

const commentElement = client.getCommentElement();
commentElement.enableSuggestionMode();
commentElement.disableSuggestionMode();
10

Listen to `onCommentAccept` and `onCommentReject` events

To listen to comments that are Accepted or Rejected in Suggestion mode, pass callbacks to the onCommentAccept and onCommentReject` event handlers.

<VeltComments onCommentAccept={(event)=>yourMethod(event)}/>
<VeltComments onCommentReject={(event)=>yourMethod(event)}/>

Response:

{
    "annotationId": "ANNOTATION_ID",
    "actionUser": {
        // user object
    },
    "actionType": "accept", // accept or reject
    "annotation": {
        // raw annotation object
    },
  	"replaceContentHtml": "HTML_FORMATTED_TEXT_TO_REPLACE", // optional
  	"replaceContentText": "PLAIN_TEXT_TO_REPLACE", // optional
}
11

Sign In button

Whether to enable Sign In button on comment dialog when user is anonymous or signed out.

Default: false

This allows anonymous or signed out users to still read the comments but encourages them to sign in if they want to respond to the comments.

<VeltComments signInButton={true} />

API Method:

const commentElement = client.getCommentElement();
commentElement.enableSignInButton();
commentElement.disableSignInButton();
12

onSignIn

When the user clicks on the sign in button, we will emit an onSignIn event that you can handle with your own sign in method.

No data is passed with the event.

<VeltComments onSignIn={() => yourSignInMethod()} />
13

Enable/Disable private comment mode

Whether private comment mode is enabled.

Default: false

Admin users can enable private comment mode. Once private comment mode is enabled, all the newly added comment annotations by the admin user will be private comments by default, meaning only other admins can see it.

To enable private comment mode, set the privateCommentMode attribute to true:

<VeltComments privateCommentMode={true} />

API Methods:

const commentElement = client.getCommentElement();
// To enable private comment mode
commentElement.enablePrivateCommentMode();
// To disable private comment mode
commentElement.disablePrivateCommentMode();
14

Enable user @mentions

Whether user @mentions are enabled.

Default: true

To disable user @mentions, set the userMentions attribute to false:

<VeltComments userMentions={false} />

API Methods:

const commentElement = client.getCommentElement();
commentElement.enableUserMentions(); // to enable user mentions
commentElement.disableUserMentions(); // to disable user mentions