This commit is contained in:
Philipp Kühn
2021-04-23 08:58:06 +02:00
2 changed files with 13 additions and 4 deletions

View File

@@ -5,7 +5,7 @@
<div class="editor__footer"> <div class="editor__footer">
<div :class="`editor__status editor__status--${status}`"> <div :class="`editor__status editor__status--${status}`">
<template v-if="status === 'connected'"> <template v-if="status === 'connected'">
{{ users.length }} user{{ users.length === 1 ? '' : 's' }} online {{ users.length }} user{{ users.length === 1 ? '' : 's' }} online in {{ room }}
</template> </template>
<template v-else> <template v-else>
offline offline
@@ -37,6 +37,14 @@ const getRandomElement = list => {
return list[Math.floor(Math.random() * list.length)] return list[Math.floor(Math.random() * list.length)]
} }
const getRandomRoom = () => {
return getRandomElement([
'room.one',
'room.two',
'room.three',
])
}
export default { export default {
components: { components: {
EditorContent, EditorContent,
@@ -54,19 +62,20 @@ export default {
editor: null, editor: null,
users: [], users: [],
status: 'connecting', status: 'connecting',
room: getRandomRoom(),
} }
}, },
mounted() { mounted() {
const ydoc = new Y.Doc() const ydoc = new Y.Doc()
this.provider = new WebsocketProvider('wss://websocket.tiptap.dev', 'tiptap-collaboration-example', ydoc) this.provider = new WebsocketProvider('wss://websocket.tiptap.dev', this.room, ydoc)
this.provider.on('status', event => { this.provider.on('status', event => {
this.status = event.status this.status = event.status
}) })
window.ydoc = ydoc window.ydoc = ydoc
this.indexdb = new IndexeddbPersistence('tiptap-collaboration-example', ydoc) this.indexdb = new IndexeddbPersistence(this.room, ydoc)
this.editor = new Editor({ this.editor = new Editor({
extensions: [ extensions: [

View File

@@ -6,7 +6,7 @@
The headless editor framework for web artisans. The headless editor framework for web artisans.
</h1> </h1>
<p class="is-large"> <p class="is-large">
tiptap gives you full control about every single aspect of your text editor experience. Its customizable, comes with a ton of extensions, is open source, has an extensive documentation, and is simply a joy to use. Join our welcoming community and start building cool things! tiptap gives you full control about every single aspect of your text editor experience. Its customizable, comes with a ton of extensions, is open source and has an extensive documentation. Join our welcoming community and start building cool things!
</p> </p>
<btn-wrapper> <btn-wrapper>
<btn type="primary" icon="arrow-right-line" to="/installation"> <btn type="primary" icon="arrow-right-line" to="/installation">