Collaboration

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

React
tsx


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

  return (
    <DragbleEditor
      ref={editorRef}
      editorKey="db_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),
        });
      }}
    />
  );
}
Vue
plaintext
<template>
  <DragbleEditor
    ref="editorRef"
    editor-key="db_your_key"
    editor-mode="email"
    :collaboration="collabConfig"
    @comment="onComment"
  />
</template>

<script setup lang="ts">


const editorRef = ref<InstanceType<typeof DragbleEditor>>();

const collabConfig = {
  enabled: true,
  role: "editor" as const,
  user: { id: "user-42", name: "Jane Smith" },
  mentions: [
    { id: "user-1", name: "Alice Johnson" },
    { id: "user-2", name: "Bob Chen" },
  ],
};

async function onComment(comment: any) {
  await fetch("/api/comments", {
    method: "POST",
    headers: { "Content-Type": "application/json" },
    body: JSON.stringify(comment),
  });
}
</script>
Angular
typescript



@Component({
  selector: "app-collab-editor",
  standalone: true,
  imports: [DragbleEditorComponent],
  template: `
    <dragble-editor
      #editor
      editorKey="db_your_key"
      editorMode="email"
      [collaboration]="collabConfig"
      (comment)="onComment($event)"
    ></dragble-editor>
  `,
})
export class CollabEditorComponent {
  @ViewChild("editor") editorComp!: DragbleEditorComponent;

  collabConfig = {
    enabled: true,
    role: "reviewer" as const,
    user: { id: "user-42", name: "Jane Smith" },
    mentions: [{ id: "user-1", name: "Alice Johnson" }],
  };

  async onComment(comment: any) {
    await fetch("/api/comments", {
      method: "POST",
      headers: { "Content-Type": "application/json" },
      body: JSON.stringify(comment),
    });
  }
}
Vanilla JS
typescript
dragble.init({
  containerId: "editor-container",
  editorKey: "db_your_key",
  editorMode: "email",
  options: {
    collaboration: {
      enabled: true,
      role: "editor",
      user: { id: "user-42", name: "Jane Smith" },
      mentions: [
        { id: "user-1", name: "Alice Johnson" },
        { id: "user-2", name: "Bob Chen" },
      ],
    },
  },
  callbacks: {
    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:

typescript
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