Appearance
Add inline comments on specific blocks for review workflows. Team members can discuss changes, resolve threads, and track feedback without leaving the editor.
const editor = await initCloud({ container: '#editor', auth: { url: '/api/templatical/token' }, commenting: true, onComment: (event) => { // Notified when comments are created, updated, or deleted console.log(event); }, });
import { useComments } from '@templatical/core/cloud'; const { // State comments, // Ref<CommentThread[]> isLoading, // Ref<boolean> isSubmitting, // Ref<boolean> isEnabled, // ComputedRef<boolean> commentCountByBlock, // ComputedRef<Map<string, number>> totalCount, // ComputedRef<number> unresolvedCount, // ComputedRef<number> // Operations loadComments, // () => Promise<void> addComment, // (body, blockId?, parentId?) => Promise<Comment | null> editComment, // (commentId, body) => Promise<Comment | null> removeComment, // (commentId) => Promise<boolean> toggleResolve, // (commentId) => Promise<Comment | null> } = useComments({ authManager, getTemplateId: () => templateId, onComment: (event) => { /* comment event */ }, onError: (error) => { /* handle error */ }, });
When WebSocket is connected, comments sync automatically across all collaborators. The composable provides methods for applying remote updates:
const { applyRemoteCreate, applyRemoteUpdate, applyRemoteDelete } = useComments({ // ...options });
These are called automatically by the useCommentListener composable when WebSocket events arrive.
useCommentListener
Comments
Add inline comments on specific blocks for review workflows. Team members can discuss changes, resolve threads, and track feedback without leaving the editor.
Enable Comments
How It Works
Composable
Real-Time Sync
When WebSocket is connected, comments sync automatically across all collaborators. The composable provides methods for applying remote updates:
These are called automatically by the
useCommentListenercomposable when WebSocket events arrive.