50 lines
988 B
Vue
50 lines
988 B
Vue
<template>
|
|
<div v-if="editor">
|
|
<editor-content :editor="editor" />
|
|
</div>
|
|
</template>
|
|
|
|
<script>
|
|
import Collaboration from '@tiptap/extension-collaboration'
|
|
import { Editor, EditorContent } from '@tiptap/vue-starter-kit'
|
|
import Document from '@tiptap/extension-document'
|
|
import Text from '@tiptap/extension-text'
|
|
import * as Y from 'yjs'
|
|
import { WebsocketProvider } from 'y-websocket'
|
|
import Paper from './Paper.js'
|
|
|
|
export default {
|
|
components: {
|
|
EditorContent,
|
|
},
|
|
|
|
data() {
|
|
return {
|
|
editor: null,
|
|
}
|
|
},
|
|
|
|
mounted() {
|
|
const ydoc = new Y.Doc()
|
|
const provider = new WebsocketProvider('wss://websocket.tiptap.dev', 'tiptap-draw-example', ydoc)
|
|
|
|
this.editor = new Editor({
|
|
extensions: [
|
|
Document.extend({
|
|
content: 'paper',
|
|
}),
|
|
Collaboration.configure({
|
|
document: ydoc,
|
|
}),
|
|
Text,
|
|
Paper,
|
|
],
|
|
})
|
|
},
|
|
|
|
beforeDestroy() {
|
|
this.editor.destroy()
|
|
},
|
|
}
|
|
</script>
|