allow to pass a fragment name to the collaboration extension

This commit is contained in:
Hans Pagel
2021-01-11 14:42:12 +01:00
parent 8e5f331345
commit e4801b0cfa
3 changed files with 28 additions and 7 deletions

View File

@@ -11,6 +11,7 @@ export interface CollaborationOptions {
* An initialized Y.js document.
*/
document: any,
fragment: string,
}
export const Collaboration = Extension.create({
@@ -18,6 +19,7 @@ export const Collaboration = Extension.create({
defaultOptions: <CollaborationOptions>{
document: null,
fragment: 'default',
},
addCommands() {
@@ -52,7 +54,9 @@ export const Collaboration = Extension.create({
addProseMirrorPlugins() {
return [
ySyncPlugin(
this.options.document.getXmlFragment('prosemirror'),
this.options.document.getXmlFragment(
this.options.fragment,
),
),
yUndoPlugin(),
]