make less assumptions about the Y.js provider, fix #70
This commit is contained in:
@@ -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' {
|
||||
|
||||
Reference in New Issue
Block a user