fix collab examples

This commit is contained in:
Hans Pagel
2020-11-30 14:30:24 +01:00
parent 66c88e7669
commit aa9420688b
2 changed files with 11 additions and 29 deletions

View File

@@ -18,30 +18,21 @@ export default {
data() {
return {
documentName: 'tiptap-collaboration-extension',
ydoc: null,
provider: null,
type: null,
editor: null,
}
},
mounted() {
this.ydoc = new Y.Doc()
this.provider = new WebrtcProvider(this.documentName, this.ydoc)
this.type = this.ydoc.getXmlFragment('prosemirror')
const ydoc = new Y.Doc()
const provider = new WebrtcProvider('tiptap-collaboration-extension', ydoc)
this.editor = new Editor({
// TODO: This is added by every new user.
// content: `
// <p>Example Text</p>
// `,
extensions: [
Document,
Paragraph,
Text,
Collaboration.configure({
type: this.type,
provider,
}),
],
})
@@ -49,7 +40,6 @@ export default {
beforeDestroy() {
this.editor.destroy()
this.provider.destroy()
},
}
</script>

View File

@@ -19,35 +19,28 @@ export default {
data() {
return {
documentName: 'tiptap-collaboration-cursor-extension',
ydoc: null,
provider: null,
type: null,
editor: null,
}
},
mounted() {
this.ydoc = new Y.Doc()
this.provider = new WebrtcProvider(this.documentName, this.ydoc)
this.type = this.ydoc.getXmlFragment('prosemirror')
const ydoc = new Y.Doc()
const provider = new WebrtcProvider('tiptap-collaboration-cursor-extension', ydoc)
this.editor = new Editor({
// TODO: This is added by every new user.
// content: `
// <p>Example Text</p>
// `,
extensions: [
Document,
Paragraph,
Text,
Collaboration.configure({
type: this.type,
provider,
}),
CollaborationCursor.configure({
provider: this.provider,
name: 'Cyndi Lauper',
color: '#f783ac',
provider,
user: {
name: 'Cyndi Lauper',
color: '#f783ac',
},
}),
],
})
@@ -55,7 +48,6 @@ export default {
beforeDestroy() {
this.editor.destroy()
this.provider.destroy()
},
}
</script>