By default, when you highlight over any text in textMode a Comment Tool button will appear. Clicking the button will add a comment on the highlighted text.If you want to trigger the comment using an API method call instead of clicking the button, you can do the following:
Copy
Ask AI
const commentElement = client.getCommentElement();// to add comment on selected textcommentElement.addCommentOnSelectedText();
Adds a Comment on a specific element by ID.To add a comment on a specific element through an API method, use the addCommentOnElement() method and pass in an object with the schema shows in the example:
Copy
Ask AI
const element = { "targetElement": { "elementId": "element_id", // optional (pass elementId if you want to add comment on a specific element) "targetText": "target_text", // optional (pass targetText if you want to add comment on a specific text) "occurrence": 1, // optional (default: 1) This is relevant for text comment. By default, we will attach comment to the first occurence of the target text in your document. You can change this to attach your comment on a more specific text. "selectAllContent": true, // Set to `true` if you want to select all the text content of the target element. }, "commentData": [ { "commentText": "This is awesome! Well done.", // To set plain text content "commentHtml": "This <span style=\"color: green; background-color: aliceblue; display: inline-block; padding: 4px; border-radius: 4px;\">is test</span> comment.", // To set HTML formatted content "replaceContentText": "This is new comment", // provide this replaceContentText to replace current text with "replaceContentHtml": "<span>This is <b>new</b> comment.</span>", // If replacement text contains html formatted text, then provide it here } ], "status": "open", // optional (default: open)}const commentElement = client.getCommentElement();commentElement.addCommentOnElement(element);
Get the total and unread comment annotations count of all the comment annotations across specified Organization, Folder, Document and Multiple Documents levels.
If you don’t specify any query, it will return data from the folder/documents specified in the setDocuments method.
const { data } = useGetCommentAnnotations(query);useEffect(() => { if (data) { // initial data value will be null while the request is in progress console.log("Comment Annotations:", data); }}, [data]);
Using API:
Copy
Ask AI
const commentElement = client.getCommentElement();commentElement.getCommentAnnotations(query).subscribe((response) => { // initial data value will be null while the request is in progress console.log("Comment Annotations:", response.data);});
Handle autocomplete search for @mentions. You should use this if you have a large contact list that you want to plug into the autocomplete dropdown, and search directly your own data source.
// Enable via props<VeltComments customAutocompleteSearch={true} />// Or, enable via Comment Element APIconst commentElement = client.getCommentElement();commentElement.enableCustomAutocompleteSearch();commentElement.disableCustomAutocompleteSearch();
const contactList = useContactList();console.log(contactList); // initial value will be null
Using API:
Copy
Ask AI
const contactElement = useContactUtils();contactElement.getContactList().subscribe((response) => { console.log(response); // initial value will be null});
This event is triggered when a contact is selected from the contact dropdown in the Comment Dialog.
Use the event object to determine if the selected contact has access to the document using fields like isOrganizationContact, isDocumentContact and documentAccessType.
If the selected contact doesn’t have access to the document, you can show an invite dialog to the user to invite the contact to the document.
The returned data will be in the following schema:
Copy
Ask AI
export class UserContactSelectedPayload { contact!: UserContact; // Selected Contact. isOrganizationContact!: boolean; // Is user part of organization contact. isDocumentContact!: boolean; // Is user part of document contact. documentAccessType!: string; // Document access type.}
Customize the description that appears for the @here mention.
Using Props:
Copy
Ask AI
<VeltComments atHereDescription="Notify all users in this document" />
Using Hooks:
Copy
Ask AI
const contactElement = useContactUtils();useEffect(() => { contactElement.setAtHereDescription('Notify all users in this document');}, [contactElement]);
Using API Method:
Copy
Ask AI
const contactElement = client.getContactElement();contactElement.setAtHereDescription('Notify all users in this document');
By default, the contact list is generated using the users in the organization and the document.
However, if you do not want to use that feature or want to provide a custom list of contacts, you can use this method.
By default, it will overwrite the current contact list. You can merge the provided contacts with the existing list by passing the merge flag as {merge:true}.
This method will only update the contact list in the current user session. It doens’t update the user contacts in the database or change the access control.
Update the custom metadata associated with a comment annotation using the updateContext method.
Utilize this method to update the context of a comment annotation at any time. For example, you might use this when the name of the dashboard containing the comment annotation changes.
The commentElement.updateContext() method accepts three parameters:
The Comment Annotation ID
The new metadata object
An optional updateContextConfig object. Specify how the new metadata should be applied:
{ merge: true }: Merges the new metadata with the existing metadata
{ merge: false } or omitted: Replaces the existing metadata entirely (default behavior)
You can have custom dropdown lists appear when certain hotkeys are pressed.When you press a hotkey inside the Comment Dialog composer, it will open a dropdown list of items that you can select.Selecting an item frop the dropdown list will add a chip that inside the comment text.
Grouped lists: Useful for workflows like issue trackers (e.g., group by “Priority” or “Status”), allowing users to quickly refer and insert custom entities from your app. With this feature, you can combine multiple entity types into one drop down just like Linear.
Make sure the hotkey is a single character such as # or /.
The items in the list must be in the following schema:
Use AutocompleteGroup only for grouped lists. For flat lists, do not include groups on the config object or groupId on items.
Copy
Ask AI
export class AutocompleteGroup { id!: string; name!: string;}export class AutocompleteItem { id!: string; // Unique identifier name!: string; // Item name. This appears as the main item text in the UI. description?: string; // Item description. This appears as the secondary item text in the UI. icon?: { url?: string; svg?: string }; // Item icon. Either URL or inline SVG. link?: string; // Item link. You can use this to open a link when the item is clicked. Check the event listener below for more details. groupId?: string; // Optional: assigns item to a group (by AutocompleteGroup.id)}
// Using Props<VeltComments customListDataOnComment={customListWithGroups} />// Hookconst commentElement = useCommentUtils();commentElement.createCustomListDataOnComment(customListWithGroups);
Listen to click events on chips
After the comment is saved, the item will be rendered as a chip on the comment content. When the user clicks on it, you will get an event callback with the data of the clicked chip (AutocompleteItem).
This event will also be triggered when the user clicks on the contact chips added via the @mentions feature.
Copy
Ask AI
let autocompleteChipData = useAutocompleteChipClick();
Handle autocomplete search for custom list. You should use this if you have a large list that you want to plug into the autocomplete dropdown, and search directly your own data source.
// Enable via props<VeltComments customAutocompleteSearch={true} />// Or, enable via Comment Element APIconst commentElement = client.getCommentElement();commentElement.enableCustomAutocompleteSearch();commentElement.disableCustomAutocompleteSearch();
2
Set initial list
Copy
Ask AI
// For @mentions featurecontactElement.updateContactList(users);// For custom list featurecommentElement.createCustomListDataOnComment({ hotkey: "#", type: "custom", data: customListData,});
Enable a callback when users click on links rendered in comment content. When enabled, links won’t automatically open; instead an event is emitted.How to use:
By default linkCallback is false.
When false, clicking a link opens it directly and no callback is triggered.
When true, clicking a link does not open it; instead a linkClicked event is emitted so you can handle navigation.
Copy
Ask AI
// Using Props<VeltComments linkCallback={true} />// Using Hooksconst linkEvent = useCommentEventCallback('linkClicked')useEffect(() => { if (linkEvent) { console.log('linkClicked', linkEvent); }}, [linkEvent]);// Using APIconst commentElement = client.getCommentElement();commentElement.on('linkClicked').subscribe((linkData) => { console.log('linkClicked', linkData);});
Whether file attachments are enabled.Default: trueWhen this is on, users can attach image files to their comments. Users can download or delete an attachment. Users can attach multiple files at once.Currently we support .png, .jpg, .gif (static & animated), .svg file types up to 15MB per file.
You can set custom reactions by passing a map that contains information about the reactions you want to add.
The map keys should be the reaction ID, and the map value should contain an object with either an url or emoji field to represent the reaction icon you want to use.
Copy
Ask AI
const commentElement = client.getCommentElement();const customReactions = { "reactionId1": { "emoji": "🤣" // This will default to system emoji }, "reactionId2": { "emoji": "🎉" // This will default to system emoji }, "reactionId3": { "emoji": "🚀" // This will default to system emoji }}commentElement.setCustomReactions(customReactions);
Whether to enable the default status dropdown & filters.Default: trueWhen 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.
Whether to show resolve button on comments.Default: trueThis adds a tick mark button on the top right corner of the comment dialog. Clicking on this button will mark the comment as resolved.
Whether to enable setting priority on comments.Default: falseWhen 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.
Pass custom priorities in the customPriority prop.Default priorities: P0, P1, P2With 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.
Set the Recorder media options within Comments: (audio, screen, video, all).
audio: enables audio recording
screen: enables screen recording
video: enables video recording
all: enables all recording options
none: disables all recording options
Default: "audio"
Copy
Ask AI
<VeltComments recordings="video,screen" />
Using API:
Copy
Ask AI
const commentElement = client.getCommentElement();commentElement.setAllowedRecordings("video"); // set video mode onlycommentElement.setAllowedRecordings("audio,screen"); // set audio and screen mode onlycommentElement.setAllowedRecordings("all"); // set all modescommentElement.setAllowedRecordings("none"); // disable all modes
Controls whether to enable AI transcription for recordings.Default: enabled
Using Props:
Copy
Ask AI
<VeltComments recordingTranscription={false} />
Using API Methods:
Copy
Ask AI
// Using comment elementconst commentElement = client.getCommentElement();commentElement.enableRecordingTranscription();commentElement.disableRecordingTranscription();// Or using recorder element const recorderElement = client.getRecorderElement();recorderElement.enableRecordingTranscription();recorderElement.disableRecordingTranscription();
Whether, users will be scrolled to the location of a Comment when it is clicked.Default: trueBy default, users will be redirected to a Comment if the comment id is provided in the url. But sometimes this experience is annoying, so we have provided a way to disable the option to automatically scroll users to the location of the Comment.
To disable the feature, set scrollToComment to false.
Copy
Ask AI
<VeltComments scrollToComment={false}/>
API methods:
Copy
Ask AI
const commentElement = client.getCommentElement();// To enable scroll to componentcommentElement.enablescrollToComment();// To disable scroll to componentcommentElement.disablescrollToComment();
Provide a list of element DOM IDs, class names, or query selectors where commenting should be allowed.Comments will be disabled for all other elements. Note, this does not impact Popover mode.
When you have multiple elements with the same DOM ID, you can use the sourceId attribute to control which element displays the comment dialog when adding a new comment.
By default, comments appear on all matching elements.
This is useful in cases where you have multiple instances of the same data component on a page and want the comment to appear on each instance, such as Popover comments on a table.
You can randomly generate the sourceId. It just needs to be unique for each element in the current session.
Whether AI auto-categorization of comments is enabled.Default: falseWe 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).
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.
By default, the Composer in the Comments Dialog only shows the text input box and does not show the actions bar until the Composer is clicked on or the user starts typing.You can modify this behavior by setting the Composer Mode prop to "expanded". This will make the actions bar always visible.To keep the default behavior you can set the property to "default".Default: "default"
You can control whether comments should be shown in fully expanded state by default.
Available on all comment-related components and can be controlled via props or API methods.
Default: false
Using Props:
Copy
Ask AI
// Apply this change globally to all types of comments<VeltComments fullExpanded={true} />// Apply this change only in comments sidebar<VeltCommentsSidebar fullExpanded={true} />// Apply this change only in inline comments section<VeltInlineCommentsSection fullExpanded={true} />// Apply this change only in the standalone comment thread<VeltCommentThread fullExpanded={true} />
Using API:
Copy
Ask AI
// API Methodconst commentElement = client.getCommentElement();commentElement.enableFullExpanded();commentElement.disableFullExpanded();
You can control whether long user names should be shortened. For long names, this will first create an initial of the second name and if the name is still long, it will truncate it with ellipses.Default: true
Whether to enable Sign In button on comment dialog when user is anonymous or signed out.Default: falseThis 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.
Whether the Sidebar Button on Comment Dialogs show up.Default: trueBy Default, each Comment Dialog has a button at the bottom that will open the Comments Sidebar when clicked.To disable it, you can set it to false:
You can enable a confirmation dialog before deleting a reply in comment threads. This feature helps prevent accidental deletions and improves user experience.
Whether mobile mode is enabled.When mobile mode is enabled and the screen width is small enough, comment windows will appear fixed to the bottom of the screen and full width instead of the usual popup window.Default: false
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.
const commentsElement = client.getCommentsElement();commentsElement.enableReplyAvatars(); // Enables the reply avatar component.commentsElement.disableReplyAvatars(); // Disables the reply avatar component.commentsElement.setMaxReplyAvatars(2); // Sets the maximum number of reply avatars to show.
Whether comments are shown on the DOM.Default: trueBy default, all the comments will be visible on DOM whenever we are able to detect to elements for that. But users can hide it from DOM if required.There are 2 ways to show/hide comments on DOM:Configuring attributes on the React Component:
Copy
Ask AI
{/* `true` to show comments, `false` to hide comments */}<VeltComments commentsOnDom={false} />
Using API methods:
Copy
Ask AI
const commentElement = client.getCommentElement();// to show comments on DOMcommentElement.showCommentsOnDom();// to hide comments on DOMcommentElement.hideCommentsOnDom();
Whether to show resolved comments on the DOM.Default: false
Copy
Ask AI
<VeltComments resolvedCommentsOnDom={true} />
API Methods:
Copy
Ask AI
const commentElement = client.getCommentElement();// To show resolved comments on domcommentElement.showResolvedCommentsOnDom();// To hide resolved comments on domcommentElement.hideResolvedCommentsOnDom();
Sometimes when you manually set the position of the Comment Pin, the Comment Dialog might not position itself near the pin in certain scenarios like scrolling, zooming the page when the comment dialog is open.
Use this to manually trigger an update. The dialog will reposition itself near the pin.
Whether comment index is enabled.Default: falseThis appears in the comment sidebar and on the comment pins. When this is on, we show a small icon indicating the comment index in the order of creation date. This enables users to find and navigate to the desired comment quickly.
Whether device type indicator is enabled.Default: falseWhen this is on, we show additional information in the Comment Thread indicating which device the comment was created on. This is useful especially for design tools, where additional context is needed for debugging issues.
Whether the device type indicator on Comment Pins is enabled.Default: falseWhen this is on, we show a small device type icon on the Comment Pin indicating which device the comment was created on. This is useful especially for design tools, where additional context is needed for debugging issues.
Whether to show ghost comments on the DOM.Default: falseGhost comments are comments that were once linked to certain content on the DOM but that content is no longer available. If this is on, we display ghost comments in gray, close to where they were originally positioned on the DOM.
Whether to show ghost comment labels in the comment sidebar.Default: trueGhost comments are always shown in the comments sidebar so that users can see the history of all comments. If this is on, we show a label on the comment in the sidebar indicating that the original content on which this comment was added is no longer available. This sets better expectations with the users.
To support comments on top of a pdf viewer, add the data-velt-pdf-viewer="true" attribute in the container element of the pdf viewer.
Copy
Ask AI
<!-- Add this attribute to the container of your pdf viewer --><div id="viewerContainer" data-velt-pdf-viewer="true"> <!-- Your pdf viewer here --> <div id="viewer" class="pdfViewer"></div></div>
Whether comments require moderator approval.Default: falseBy 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.
const commentElement = client.getCommentElement();// To enable resolve status access admin onlycommentElement.enableResolveStatusAccessAdminOnly();// To disable resolve status access admin onlycommentElement.disableResolveStatusAccessAdminOnly();
Control whether comments are in read-only mode. When enabled, any features requiring user interaction (e.g., Composer, Reactions, Status) will be removed.Default: false
Whether verbose mode is enabled for unread Comments.Default: 'minimal'Unread Comments can be in minimal mode or verbose mode.In minimal mode, a small red dot indicator appears for unread Comments.In verbose mode, a larger badge with the text “UNREAD” will appear for unread Comments.
Copy
Ask AI
<VeltComments unreadIndicatorMode={"verbose"} />
API Method:
Copy
Ask AI
const commentElement = client.getCommentElement();commentElement.setUnreadIndicatorMode("verbose"); // use badge with text UNREADcommentElement.setUnreadIndicatorMode("minimal"); // use small red dot indicator
Whether In-line comment mode is enabled.When In-line comment mode is enabled, comments will appear under the text they are associated with in the DOM, instead of as a pop up window.Default: false
Add context to the Velt Comment Tool component to associate custom metadata with comments created using that tool.
Predefine context directly within the component itself.
Currently, this feature is specific to popover comments. This allows you to, for example, assign unique context to each cell in a table if you place a Velt Comment Tool in each cell.
The context prop accepts an object with key-value pairs.
Copy
Ask AI
// For popover comments<VeltCommentTool targetElementId="elementId" context={{ key1: 'value1' }} />
Turns Comment mode on or off.When you click on the comment tool, it turns on comment mode and user can attach comment to any element on the DOM. Using this method you can programatically turn on the commenting mode.
The comment mode is toggled on and off when you click on the Comment Tool.
The useCommentModeState() hook can be used to get the Comment mode without having to subscribe to changes. When the Comment mode changes, the hook return value will update.The subscription is automatically unsubscribed when the component dismounts.
Copy
Ask AI
import { useCommentModeState } from '@veltdev/react';export default function YourDocument() { let commentModeState = useCommentModeState() return ( <div> Comment Mode is turned on: {commentModeState} </div> )}
Whether the Comment Tool button is Enabled.Default: trueWhen the Comment Tool is disabled, it can not be used to leave comments. Other ways to leave comments, such as highlighting text, will also be disabled.
Whether to group multiple comment annotations in Comment Bubble component when multiple annotations match the provided context or targetElementId.Default: false
Show a Comment Bubble when user hovers or clicks on the Comment Pin vs showing the Comment Dialog.
The comment dialog will open only on clicking the comment bubble.Default: 'false'
const commentElement = useCommentUtils();// To enable/disable showing bubble on pincommentElement.enableBubbleOnPin();commentElement.disableBubbleOnPin();// To enable/disable showing bubble on hovercommentElement.enableBubbleOnPinHover();commentElement.disableBubbleOnPinHover();