add support for raw Y.js fragments to the collaboration extension
This commit is contained in:
@@ -20,10 +20,11 @@ yarn add @tiptap/extension-collaboration yjs y-websocket
|
||||
```
|
||||
|
||||
## Settings
|
||||
| Option | Type | Default | Description |
|
||||
| -------- | -------- | --------- | ----------------------------------------------------------------------------------------- |
|
||||
| document | `Object` | `null` | An initialized Y.js document. |
|
||||
| fragment | `String` | `default` | Name of the Y.js fragment, can be changed to sync multiple fields with one Y.js document. |
|
||||
| Option | Type | Default | Description |
|
||||
| -------- | -------- | ----------- | --------------------------------------------------------------------------------------- |
|
||||
| document | `Object` | `null` | An initialized Y.js document. |
|
||||
| field | `String` | `'default'` | Name of a Y.js fragment, can be changed to sync multiple fields with one Y.js document. |
|
||||
| fragment | `Object` | `null` | A raw Y.js fragment, can be used instead of `document` and `field`. |
|
||||
|
||||
## Commands
|
||||
| Command | Parameters | Description |
|
||||
|
||||
@@ -236,13 +236,22 @@ And if you’d like to sync multiple fields with one Y.js document, just pass di
|
||||
// a tiptap instance for the field
|
||||
Collaboration.configure({
|
||||
document: ydoc,
|
||||
fragment: 'title',
|
||||
field: 'title',
|
||||
})
|
||||
|
||||
// and another instance for the summary, both in the same Y.js document
|
||||
Collaboration.configure({
|
||||
document: ydoc,
|
||||
fragment: 'summary',
|
||||
field: 'summary',
|
||||
})
|
||||
```
|
||||
|
||||
If your setup is somehow more complex, for example with nested fragments, you can pass a raw Y.js fragment too. `document` and `field` will be ignored then.
|
||||
|
||||
```js
|
||||
// a raw Y.js fragment
|
||||
Collaboration.configure({
|
||||
fragment: ydoc.getXmlFragment('custom'),
|
||||
})
|
||||
```
|
||||
|
||||
|
||||
Reference in New Issue
Block a user