Skip to content

Commit a66f456

Browse files
authored
Merge pull request #70 from velt-js/env-docs
Env Docs + TipTap docs Updates
2 parents fa348fa + f5f9627 commit a66f456

File tree

6 files changed

+383
-310
lines changed

6 files changed

+383
-310
lines changed

async-collaboration/comments/customize-behavior.mdx

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -88,20 +88,19 @@ commentElement.addCommentOnSelectedText();
8888

8989
![](/images/addCommentOnElement.png)
9090

91-
9291
Adds a Comment on a specific element by ID.
9392

9493
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:
9594

95+
**Example 1: Add comment with targetElementId only:**
96+
9697
<Tabs>
9798
<Tab title="React / Next.js">
9899

99-
100100
```jsx
101-
102101
const element = {
103102
"targetElement": {
104-
"elementId": "element_id", // optional (pass elementId if you want to add comment on a specific element)
103+
"elementId": "element_id", // optional (pass elementId if you want to add comment on a specific element)
105104
"targetText": "target_text", // optional (pass targetText if you want to add comment on a specific text)
106105
"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.
107106
"selectAllContent": true, // Set to `true` if you want to select all the text content of the target element.
@@ -123,8 +122,8 @@ commentElement.addCommentOnElement(element);
123122
</Tab>
124123

125124
<Tab title="Other Frameworks">
126-
```jsx
127125

126+
```jsx
128127
const element = {
129128
"targetElement": {
130129
"elementId": "element_id", // optional (pass elementId if you want to add comment on a specific element)
@@ -147,8 +146,6 @@ const commentElement = Velt.getCommentElement();
147146
commentElement.addCommentOnElement(element);
148147
```
149148
</Tab>
150-
151-
152149
</Tabs>
153150

154151
#### addManualComment
@@ -2069,22 +2066,41 @@ Extra fields in the comment context don't prevent a match.
20692066
{ product: "cheese", category: "dairy"} ❌ No match (missing field)
20702067
```
20712068
2069+
**Example**
2070+
20722071
<Tabs>
20732072
<Tab title="React / Next.js">
20742073
```jsx
2074+
{/* Comment Bubble with Partial Match */}
20752075
<VeltCommentBubble
20762076
context={{ product: "cheese" }}
20772077
contextOptions={{ partialMatch: true }}
20782078
/>
2079+
2080+
{/* Comment Tool with Partial Match */}
2081+
<VeltCommentTool
2082+
targetElementId="element_id"
2083+
context={{ product: "cheese" }}
2084+
contextOptions={{ partialMatch: true }}
2085+
/>
20792086
```
20802087
</Tab>
20812088
<Tab title="Other Frameworks">
20822089
```html
2090+
<!-- Comment Bubble with Partial Match -->
20832091
<velt-comment-bubble
20842092
context='{ "product": "cheese" }'
20852093
context-options='{ "partialMatch": true }'
20862094
>
20872095
</velt-comment-bubble>
2096+
2097+
<!-- Comment Tool with Partial Match -->
2098+
<velt-comment-tool
2099+
target-element-id="element_id"
2100+
context='{ "product": "cheese" }'
2101+
context-options='{ "partialMatch": true }'
2102+
>
2103+
</velt-comment-tool>
20882104
```
20892105
</Tab>
20902106
</Tabs>

0 commit comments

Comments
 (0)