make less assumptions about the Y.js provider, fix #70

This commit is contained in:
Hans Pagel
2021-01-08 18:02:06 +01:00
parent 6c20e92f7e
commit 3496718654
8 changed files with 50 additions and 30 deletions

View File

@@ -7,14 +7,17 @@ import {
} from 'y-prosemirror'
export interface CollaborationOptions {
provider: any,
/**
* An initialized Y.js document.
*/
document: any,
}
export const Collaboration = Extension.create({
name: 'collaboration',
defaultOptions: <CollaborationOptions>{
provider: null,
document: null,
},
addCommands() {
@@ -49,15 +52,11 @@ export const Collaboration = Extension.create({
addProseMirrorPlugins() {
return [
ySyncPlugin(
this.options.provider.doc.getXmlFragment('prosemirror'),
this.options.document.getXmlFragment('prosemirror'),
),
yUndoPlugin(),
]
},
onDestroy() {
this.options.provider?.destroy()
},
})
declare module '@tiptap/core' {