add new collaboration cursor plugin
This commit is contained in:
@@ -8,6 +8,9 @@ import Document from '@tiptap/extension-document'
|
||||
import Paragraph from '@tiptap/extension-paragraph'
|
||||
import Text from '@tiptap/extension-text'
|
||||
import Collaboration from '@tiptap/extension-collaboration'
|
||||
import CollaborationCursor from '@tiptap/extension-collaboration-cursor'
|
||||
import * as Y from 'yjs'
|
||||
import { WebrtcProvider } from 'y-webrtc'
|
||||
|
||||
export default {
|
||||
components: {
|
||||
@@ -16,11 +19,18 @@ export default {
|
||||
|
||||
data() {
|
||||
return {
|
||||
ydoc: null,
|
||||
provider: null,
|
||||
type: null,
|
||||
editor: null,
|
||||
}
|
||||
},
|
||||
|
||||
mounted() {
|
||||
this.ydoc = new Y.Doc()
|
||||
this.provider = new WebrtcProvider('example', this.ydoc)
|
||||
this.type = this.ydoc.getXmlFragment('prosemirror')
|
||||
|
||||
this.editor = new Editor({
|
||||
// TODO: This is added by every new user.
|
||||
// content: `
|
||||
@@ -31,6 +41,11 @@ export default {
|
||||
Paragraph(),
|
||||
Text(),
|
||||
Collaboration({
|
||||
provider: this.provider,
|
||||
type: this.type,
|
||||
}),
|
||||
CollaborationCursor({
|
||||
provider: this.provider,
|
||||
name: 'Other User',
|
||||
color: '#d6336c',
|
||||
}),
|
||||
@@ -40,6 +55,7 @@ export default {
|
||||
|
||||
beforeDestroy() {
|
||||
this.editor.destroy()
|
||||
this.provider.destroy()
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user