tiptap/docs/examples/collaborative-editing.md

43 lines
1.3 KiB
Markdown
Raw Normal View History

---
tableOfContents: true
---
2020-09-27 03:08:49 +08:00
# Collaborative editing
2021-02-04 23:56:17 +08:00
:::pro Commercial use
Using the collaborative editing commercially? [Become a sponsor](/sponsor) to fund its development!
:::
## Introduction
2020-11-30 21:12:19 +08:00
This example shows how you can use tiptap to let multiple users collaborate in the same document in real-time.
2020-10-05 20:56:45 +08:00
2020-11-30 21:12:19 +08:00
It connects all clients to a WebSocket server and merges changes to the document with the power of [Y.js](https://github.com/yjs/yjs). If you want to learn more about collaborative text editing, check out [our guide on collaborative editing](/guide/collaborative-editing).
2020-10-05 20:56:45 +08:00
2021-02-04 23:56:17 +08:00
## Example
2020-11-06 21:49:40 +08:00
:::warning Shared Document
Be nice! The content of this editor is shared with other users from the Internet.
2020-09-27 03:04:33 +08:00
:::
2020-09-26 20:17:51 +08:00
<tiptap-demo name="Examples/CollaborativeEditing"></tiptap-demo>
2020-11-30 21:20:31 +08:00
2021-02-04 23:56:17 +08:00
## Backend
In case youre wondering what kind of sorcery you need on the server to achieve this, here is the whole backend code for the demo:
2020-11-30 21:20:31 +08:00
:::warning Request early access
2021-04-28 00:50:51 +08:00
Our plug & play collaboration backend hocuspocus is still work in progress. If you want to give it a try, [get early access](https://www.hocuspocus.dev).
:::
2020-11-30 21:20:31 +08:00
```js
import { Server } from '@hocuspocus/server'
2021-04-16 03:48:19 +08:00
import { RocksDB } from '@hocuspocus/extension-rocksdb'
2020-11-30 21:20:31 +08:00
const server = Server.configure({
2020-12-03 20:50:01 +08:00
port: 80,
extensions: [
2021-04-16 03:48:19 +08:00
new RocksDB({ path: './database' }),
],
2020-11-30 21:20:31 +08:00
})
server.listen()
```