Get Started
- Overview
- Quickstart
- Setup
Key Concepts
- Overview
- Organizations
- Documents
- Locations
- Users
- Access Control
Async Collaboration
- Comments
- Overview
- Setup
- Customize Behavior
- Comments Sidebar
- Comments Notifications
- Build Yourself - Standalone Components
- Comment Composer
- Comment Thread
- Comment Pin
- In-app Notifications
- Inline Reactions
- Recorder
- View Analytics
- Arrows
Realtime Collaboration
- Presence
- Cursors
- Follow Me Mode
- Huddle
- Live Selection
- Live State Sync
- Single Editor Mode
- Video Player Sync
Email Notifications
Miscellaneous
- Migrate From Cord
- Common Integration Questions
Comment Thread
Setup
import { VeltCommentThread, useCommentAnnotations } from '@veltdev/react';
export default function YourDocument() {
let commentAnnotations = useCommentAnnotations()
return (
<div>
{commentAnnotations.map((x,i) => <VeltCommentThread key={i} annotationId={x.annotationId}/>)}
</div>
)
}
1
Retrieve Comment Annotations
- Retrieve all comment annotations data.
- Learn more.
Using Hooks:
let commentAnnotations = useCommentAnnotations()
Using API:
const commentElement = client.getCommentElement();
let subscription = commentElement.getAllCommentAnnotations().subscribe((commentAnnotations) => {
// console.log(commentAnnotations);
});
To unsubscribe from the subscription:
subscription?.unsubscribe()
Using Hooks:
let commentAnnotations = useCommentAnnotations()
Using API:
const commentElement = client.getCommentElement();
let subscription = commentElement.getAllCommentAnnotations().subscribe((commentAnnotations) => {
// console.log(commentAnnotations);
});
To unsubscribe from the subscription:
subscription?.unsubscribe()
const commentElement = Velt.getCommentElement();
let subscription = commentElement.getAllCommentAnnotations().subscribe((commentAnnotations) => {
// console.log(commentAnnotations);
});
To unsubscribe from the subscription:
subscription?.unsubscribe()
2
Add the Velt Comment Thread component
- Iterate over the
Comment Annotations
array and add theVelt Comment Thread
component. - Pass the
annotation Id
prop to set the specific Comment Thread data.
Here’s an improved example:
let commentAnnotations = useCommentAnnotations()
return (
<div>
{commentAnnotations.map((x,i) => <VeltCommentThread key={i} annotationId={x.annotationId}/>)}
</div>
)
let commentAnnotations = useCommentAnnotations()
return (
<div>
{commentAnnotations.map((x,i) => <VeltCommentThread key={i} annotationId={x.annotationId}/>)}
</div>
)
<!--
If you are using pure html, inject <velt-comment-thread annotation-id="ANNOTATION_ID"></velt-comment-thread>
In other frameworks, you can loop over the comments inside the template itself
-->
<velt-comment-thread annotation-id="ANNOTATION_ID"></velt-comment-thread>
import { VeltCommentThread, useCommentAnnotations } from '@veltdev/react';
export default function YourDocument() {
let commentAnnotations = useCommentAnnotations()
return (
<div>
{commentAnnotations.map((x,i) => <VeltCommentThread key={i} annotationId={x.annotationId}/>)}
</div>
)
}
Was this page helpful?
import { VeltCommentThread, useCommentAnnotations } from '@veltdev/react';
export default function YourDocument() {
let commentAnnotations = useCommentAnnotations()
return (
<div>
{commentAnnotations.map((x,i) => <VeltCommentThread key={i} annotationId={x.annotationId}/>)}
</div>
)
}