You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
To add a comment on a specific element through an API method, use the `addCommentOnElement()` method and pass in an object with the schema shown in the examples:
93
+
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:
94
94
95
95
**Example 1: Add comment with targetElementId only:**
96
96
@@ -100,17 +100,17 @@ To add a comment on a specific element through an API method, use the `addCommen
100
100
```jsx
101
101
constelement= {
102
102
"targetElement": {
103
-
"elementId":"element_id",
103
+
"elementId":"element_id",// optional (pass elementId if you want to add comment on a specific element)
104
104
"targetText":"target_text", // optional (pass targetText if you want to add comment on a specific text)
105
105
"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.
106
106
"selectAllContent":true, // Set to `true` if you want to select all the text content of the target element.
"elementId":"element_id",// optional (pass elementId if you want to add comment on a specific element)
130
130
"targetText":"target_text", // optional (pass targetText if you want to add comment on a specific text)
131
131
"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.
132
132
"selectAllContent":true, // Set to `true` if you want to select all the text content of the target element.
Copy file name to clipboardExpand all lines: async-collaboration/comments/setup/popover.mdx
+44-43Lines changed: 44 additions & 43 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -44,7 +44,7 @@ This component is required to render comments in your app. Popover mode means co
44
44
```
45
45
46
46
</Tab>
47
-
<Tabtitle="HTML">
47
+
<Tabtitle="Other Frameworks">
48
48
49
49
Add the comment component to your template close to the root level of your `<body>`.
50
50
@@ -70,6 +70,7 @@ Add a Comment Tool near each cell or element you want to comment on. For example
70
70
- Add unique DOM ID to each element
71
71
- Set the `targetElementId` to match the element's ID
72
72
- When users click on the Comment Tool, it attaches a Comment to that element
73
+
- If your app is more complex and cannot have unique IDs for each element (e.g., table cell), you could also use `context` to bind the element and comment with custom metadata, which can then be used to filter, group, and render comments that match specific criteria. [Learn more](/async-collaboration/comments/customize-behavior#aggregation)
73
74
74
75

75
76
@@ -116,7 +117,8 @@ Add a Comment Tool in a single location such as the navigation bar.
116
117
117
118
- Add unique DOM ID and `data-velt-target-comment-element-id` attribute to each element (both with the same value)
118
119
- When users click on the Comment Tool and then click on the target element, it attaches a Comment to it
119
-
- You can only add one Comment per element with this approach
120
+
- You can only add one Comment Annotation (thread) per element with this approach
121
+
- If your app is more complex and cannot have unique IDs for each element (e.g., table cell), you could also use `context` to bind the element and comment with custom metadata, which can then be used to filter, group, and render comments that match specific criteria. [Learn more](/async-collaboration/comments/customize-behavior#aggregation)
120
122
121
123
<Warning>
122
124
If you don't add the `data-velt-target-comment-element-id` attribute, you will be adding multiple Comment Annotations on the same element.
@@ -157,11 +159,10 @@ If you don't add the `data-velt-target-comment-element-id` attribute, you will b
157
159
158
160
## Step 4: Add Metadata to the Comment
159
161
160
-
You can add metadata to comments to:
161
-
- Render additional data on comments
162
-
- Position comment pins manually
162
+
- Render additional data on comments UI
163
163
- Create custom UI components
164
164
- Enable comment filtering on custom data
165
+
- Use the metadata later when processing notifications
165
166
166
167
### a. Using Comment Tool
167
168
@@ -196,7 +197,7 @@ Either use this or the default triangle component. Using both could cause visual
196
197
197
198
The Comment Bubble component:
198
199
- Displays a count of replies for a comment thread
199
-
- Must have the same `targetElementId` as its associated element
200
+
- Must have the same `targetElementId`or `context`as its associated element and comment tool
200
201
- Can show either total replies or only unread replies
@@ -155,7 +172,7 @@ Refer to the [Tiptap BubbleMenu documentation](https://tiptap.dev/docs/editor/ex
155
172
#### Step 5: Call `addComment` to add a comment
156
173
157
174
- Call this method to add a comment to selected text in the Tiptap editor. You can use this when the user clicks on the comment button in context menu or presses a keyboard shortcut.
158
-
- Params: `AddCommentRequest`. It has the following properties:
175
+
- Params: [`AddCommentRequest`](/api-reference/sdk/models/data-models#addcommentrequest). It has the following properties:
159
176
-`editor`: instance of the Tiptap editor.
160
177
-`editorId`: Id of the tiptap editor. Use this if you have multiple tiptap editors on the same page in your app. (optional)
161
178
-`context`: Add any custom metadata to the Comment Annotation. [Learn more](/async-collaboration/comments/customize-behavior#metadata). (optional)
@@ -198,7 +215,7 @@ Refer to the [Tiptap BubbleMenu documentation](https://tiptap.dev/docs/editor/ex
198
215
#### Step 6: Render Comments in Tiptap Editor
199
216
200
217
- Get the comment data from Velt SDK and render it in the Tiptap Editor.
201
-
- Params: `RenderCommentsRequest`. It has the following properties:
218
+
- Params: [`RenderCommentsRequest`](/api-reference/sdk/models/data-models#rendercommentsrequest). It has the following properties:
202
219
-`editor`: Instance of the Tiptap editor.
203
220
-`editorId`: Id of the tiptap editor. Use this if you have multiple tiptap editors on the same page in your app. (optional)
204
221
-`commentAnnotations`: Array of Comment Annotation objects.
0 commit comments