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

@@ -19,12 +19,13 @@ export default {
data() {
return {
editor: null,
provider: null,
}
},
mounted() {
const ydoc = new Y.Doc()
const provider = new WebrtcProvider('tiptap-collaboration-extension', ydoc)
this.provider = new WebrtcProvider('tiptap-collaboration-extension', ydoc)
this.editor = new Editor({
extensions: [
@@ -32,7 +33,7 @@ export default {
Paragraph,
Text,
Collaboration.configure({
provider,
document: ydoc,
}),
],
})
@@ -40,6 +41,7 @@ export default {
beforeDestroy() {
this.editor.destroy()
this.provider.destroy()
},
}
</script>

View File

@@ -20,12 +20,13 @@ export default {
data() {
return {
editor: null,
provider: null,
}
},
mounted() {
const ydoc = new Y.Doc()
const provider = new WebrtcProvider('tiptap-collaboration-cursor-extension', ydoc)
this.provider = new WebrtcProvider('tiptap-collaboration-cursor-extension', ydoc)
this.editor = new Editor({
extensions: [
@@ -33,10 +34,10 @@ export default {
Paragraph,
Text,
Collaboration.configure({
provider,
document: ydoc,
}),
CollaborationCursor.configure({
provider,
provider: this.provider,
user: {
name: 'Cyndi Lauper',
color: '#f783ac',
@@ -48,6 +49,7 @@ export default {
beforeDestroy() {
this.editor.destroy()
this.provider.destroy()
},
}
</script>