Skip to main content

Collaboration

Add commenting, mentions, and role-based permissions so teams can review and discuss designs within the editor.

import { useRef } from 'react';
import { PexelizeEditor, PexelizeEditorRef } from '@pexelize/react-editor';

function CollaborativeEditor() {
const editorRef = useRef<PexelizeEditorRef>(null);

return (
<PexelizeEditor
ref={editorRef}
editorKey="pk_your_key"
editorMode="email"
options={{
collaboration: {
enabled: true,
role: 'editor', // 'editor' | 'reviewer'
user: {
id: 'user-42',
name: 'Jane Smith',
avatar: 'https://cdn.example.com/avatars/jane.jpg',
},
mentions: [
{ id: 'user-1', name: 'Alice Johnson' },
{ id: 'user-2', name: 'Bob Chen' },
{ id: 'user-3', name: 'Carlos Rivera' },
],
},
}}
onComment={async (comment) => {
await fetch('/api/comments', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(comment),
});
}}
/>
);
}

Roles

RoleCan edit contentCan commentCan resolve comments
editorYesYesYes
reviewerNoYesNo
Reviewer mode

Set role: 'reviewer' for stakeholders who need to give feedback but should not modify the design. They can add comments and mentions but cannot drag, edit, or delete content.

Mentions

Users type @ in a comment to trigger the mentions dropdown. Provide the mentions array with team members:

mentions: [
{ id: 'user-1', name: 'Alice Johnson', avatar: 'https://...' },
{ id: 'user-2', name: 'Bob Chen', avatar: 'https://...' },
]
Comment data structure

The onComment callback receives an object with { id, userId, userName, text, rowId, timestamp, mentions: string[] }. Persist this to your backend and load existing comments via the design JSON.

Method reference

MethodReturnsDescription
setCollaboration(config)voidUpdate collaboration settings at runtime
CallbackParametersDescription
onComment(comment: CommentData)Fired when a user posts a comment

Next steps