Skip to content
Branch: master
Find file Copy path
Find file Copy path
1 contributor

Users who have contributed to this file

128 lines (115 sloc) 3.15 KB
<div class="editor">
Collaborative Editing
<div class="message">
With the Collaboration Extension it's possible for several users to work on a document at the same time. To make this possible, client-side and server-side code is required. This example shows this using a <a href="!/tiptap-sockets" target="_blank">socket server on</a>. To keep the demo code clean, only a few nodes and marks are activated. There is also set a 250ms debounce for all changes. Try it out below:
<template v-if="editor && !loading">
<div class="count">
{{ count }} {{ count === 1 ? 'user' : 'users' }} connected
<editor-content class="editor__content" :editor="editor" />
<em v-else>
Connecting to socket server …
import io from ''
import { Editor, EditorContent } from 'tiptap'
import {
} from 'tiptap-extensions'
export default {
components: {
data() {
return {
loading: true,
editor: null,
socket: null,
count: 0,
methods: {
onInit({ doc, version }) {
this.loading = false
if (this.editor) {
this.editor = new Editor({
content: doc,
extensions: [
new HardBreak(),
new Heading({ levels: [1, 2, 3] }),
new Bold(),
new Code(),
new Italic(),
new History(),
new Collaboration({
// the initial version we start with
// version is an integer which is incremented with every change
// debounce changes so we can save some bandwidth
debounce: 250,
// onSendable is called whenever there are changed we have to send to our server
onSendable: ({ sendable }) => {
this.socket.emit('update', sendable)
setCount(count) {
this.count = count
mounted() {
// server implementation:!/tiptap-sockets
this.socket = io('wss://')
// get the current document and its version
.on('init', data => this.onInit(data))
// send all updates to the collaboration extension
.on('update', data => this.editor.extensions.options.collaboration.update(data))
// get count of connected users
.on('getCount', count => this.setCount(count))
beforeDestroy() {
<style lang="scss">
@import "~variables";
.count {
display: flex;
align-items: center;
font-weight: bold;
color: rgba($color-black, 0.5);
color: #27b127;
margin-bottom: 1rem;
text-transform: uppercase;
font-size: 0.7rem;
line-height: 1;
&:before {
content: '';
display: inline-flex;
background-color: #27b127;
width: 0.4rem;
height: 0.4rem;
border-radius: 50%;
margin-right: 0.3rem;
You can’t perform that action at this time.