tiptap/docs/api/extensions/collaboration.md

53 lines
2.6 KiB
Markdown
Raw Normal View History

2020-08-20 21:33:16 +08:00
# Collaboration
2020-12-04 00:23:54 +08:00
[![Version](https://img.shields.io/npm/v/@tiptap/extension-collaboration.svg?label=version)](https://www.npmjs.com/package/@tiptap/extension-collaboration)
[![Downloads](https://img.shields.io/npm/dm/@tiptap/extension-collaboration.svg)](https://npmcharts.com/compare/@tiptap/extension-collaboration?minimal=true)
The Collaboration extension enables you to collaborate with others in a single document. The implementation is based on [Y.js by Kevin Jahns](https://github.com/yjs/yjs), which is the coolest thing to [integrate collaborative editing](/guide/collaborative-editing) in your project.
2020-10-28 23:49:44 +08:00
2020-12-03 23:52:54 +08:00
The history works totally different in a collaborative editing setup. If you undo a change, you dont want to undo changes of other users. To handle that behaviour this extension provides an own `undo` and `redo` command. Dont load the default [`History`](/api/extensions/history) extension together with the Collaboration extension to avoid conflicts.
2020-12-04 00:23:54 +08:00
:::pro Pro Extension
2020-12-01 19:03:50 +08:00
We kindly ask you to [sponsor our work](/sponsor) when using this extension in production.
2020-10-28 23:49:44 +08:00
:::
## Installation
```bash
2020-10-30 21:24:16 +08:00
# with npm
2020-12-01 19:03:50 +08:00
npm install @tiptap/extension-collaboration yjs y-websocket
2020-10-30 21:24:16 +08:00
# with Yarn
2020-12-01 19:03:50 +08:00
yarn add @tiptap/extension-collaboration yjs y-websocket
```
## Settings
| Option | Type | Default | Description |
| -------- | -------- | ----------- | --------------------------------------------------------------------------------------- |
| document | `Object` | `null` | An initialized Y.js document. |
| field | `String` | `'default'` | Name of a Y.js fragment, can be changed to sync multiple fields with one Y.js document. |
| fragment | `Object` | `null` | A raw Y.js fragment, can be used instead of `document` and `field`. |
## Commands
2020-12-04 00:23:54 +08:00
| Command | Parameters | Description |
| ------- | ---------- | --------------------- |
| undo | — | Undo the last change. |
| redo | — | Redo the last change. |
## Keyboard shortcuts
2020-12-04 00:23:54 +08:00
### Undo
* Windows/Linux: `Control` `Z`
* macOS: `Cmd` `Z`
### Redo
* Windows/Linux: `Shift` `Control` `Z` or `Control` `Y`
* macOS: `Shift` `Cmd` `Z` or `Cmd` `Y`
## Source code
2021-04-21 21:31:11 +08:00
[packages/extension-collaboration/](https://github.com/ueberdosis/tiptap/blob/main/packages/extension-collaboration/)
## Usage
2020-09-27 03:04:33 +08:00
:::warning Public
The content of this editor is shared with other users.
:::
2021-09-19 04:58:38 +08:00
<tiptap-demo name="Extensions/Collaboration" hide-source></tiptap-demo>
<tiptap-demo name="Extensions/Collaboration"></tiptap-demo>