You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/content/docs/features/collaboration/comments.mdx
+24-22Lines changed: 24 additions & 22 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -16,24 +16,28 @@ To enable comments in your editor, you need to:
16
16
- Optionally provide a schema for comments and comment editors to use. If left undefined, they will use the [default comment editor schema](https://github.com/TypeCellOS/BlockNote/blob/main/packages/react/src/components/Comments/defaultCommentEditorSchema.ts). See [here](/docs/features/custom-schemas) to find out more about custom schemas.
17
17
18
18
```tsx
19
-
const editor =useCreateBlockNote({
20
-
extensions: [
21
-
CommentsExtension({
22
-
// See below.
23
-
threadStore: ...,
24
-
// Return user information for the given userIds (see below).
@@ -50,7 +54,7 @@ BlockNote comes with several built-in ThreadStore implementations:
50
54
The `YjsThreadStore` provides direct Yjs-based storage for comments, storing thread data directly in the Yjs document. This implementation is ideal for simple collaborative setups where all users have write access to the document.
@@ -68,10 +72,8 @@ The `RESTYjsThreadStore` combines Yjs storage with a REST API backend, providing
68
72
In this implementation, data is written to the Yjs document via a REST API which can handle access control. Data is still retrieved from the Yjs document directly (after it's been updated by the REST API), this way all comment information automatically syncs between clients using the existing collaboration provider.
// The Yjs Provider responsible for transporting updates:
37
-
provider,
38
-
// Where to store BlockNote data in the Y.Doc:
39
-
fragment: doc.getXmlFragment("document-store"),
40
-
// Information (name and color) for this user:
41
-
user: {
42
-
name: "My Username",
43
-
color: "#ff0000",
34
+
const editor =useCreateBlockNote(
35
+
withCollaboration({
36
+
// ...
37
+
collaboration: {
38
+
// The Yjs Provider responsible for transporting updates:
39
+
provider,
40
+
// Where to store BlockNote data in the Y.Doc:
41
+
fragment: doc.getXmlFragment("document-store"),
42
+
// Information (name and color) for this user:
43
+
user: {
44
+
name: "My Username",
45
+
color: "#ff0000",
46
+
},
47
+
// When to show user labels on the collaboration cursor. Set by default to
48
+
// "activity" (show when the cursor moves), but can also be set to "always".
49
+
showCursorLabels: "activity",
44
50
},
45
-
// When to show user labels on the collaboration cursor. Set by default to
46
-
// "activity" (show when the cursor moves), but can also be set to "always".
47
-
showCursorLabels: "activity",
48
-
},
49
-
// ...
50
-
});
51
+
// ...
52
+
}),
53
+
);
51
54
```
52
55
56
+
The `withCollaboration` function accepts all the regular editor options along with a `collaboration` property, and configures your editor for real-time collaboration.
57
+
53
58
## Yjs Providers
54
59
55
60
When a user edits the document, an incremental change (or "update") is captured and can be shared between users of your app. You can share these updates by setting up a _Yjs Provider_. In the snipped above, we use [y-webrtc](https://github.com/yjs/y-webrtc) which shares updates over WebRTC (and BroadcastChannel), but you might be interested in different providers for production-ready use cases.
0 commit comments