You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
cudr_slate-collaborative/README.md

75 lines
2.1 KiB

5 years ago
# slate-collaborative. Check [Demo](https://slate-collaborative.herokuapp.com/)
5 years ago
slatejs collaborative plugin & microservice
5 years ago
![screencast2019-10-2820-06-10](https://user-images.githubusercontent.com/23132107/67700384-ebff7280-f9be-11e9-9005-6ddadcafec47.gif)
5 years ago
A little experiment for co-editing.
5 years ago
Based on idea of https://github.com/humandx/slate-automerge
5 years ago
# API
## Client
Use it as a simple slatejs plugin
5 years ago
check [example](https://github.com/cudr/slate-collaborative/blob/221d8929915c49cbe30a2f92550c9a604b9a527e/packages/example/src/Client.tsx#L43)
5 years ago
5 years ago
```
import ColaborativeClient from '@slate-collaborative/client'
const plugins = [ColaborativeClient(options)]
```
### options:
```
{
url?: string // url to open connection
connectOpts?: SocketIOClient.ConnectOpts // socket.io-client options
cursorAnnotationType?: string // type string for cursor annotations
annotationDataMixin?: Data // any data passed to cursor annotation
renderPreloader?: () => ReactNode // optional preloader render
5 years ago
renderCursor?: (data: Data) => ReactNode | any // custom cursor render
5 years ago
onConnect?: (connection: Connection) => void // connect callback
onDisconnect?: (connection: Connection) => void // disconnect callback
}
```
## Backend
```
const CollaborativeBackend = require('@slate-collaborative/backend')
const connection = new CollaborativeBackend(options)
```
### options:
```
{
5 years ago
entry: number | Server // port or Server for listen io connection
5 years ago
connectOpts?: SocketIO.ServerOptions
5 years ago
defaultValue?: ValueJSON // default value
saveTreshold?: number // theshold of onDocumentSave callback execution
cursorAnnotationType?: string // type string for cursor annotations
onAuthRequest?: ( // auth callback
5 years ago
query: Object,
socket?: SocketIO.Socket
) => Promise<boolean> | boolean
5 years ago
onDocumentLoad?: ( // request slatejs document callback
5 years ago
pathname: string,
query?: Object
) => ValueJSON | null | false | undefined
5 years ago
onDocumentSave?: (pathname: string, json: ValueJSON) => Promise<void> | void // save document callback
5 years ago
}
```
5 years ago
# Contribute
You welcome to contribute!
start it ease:
```
yarn
yarn dev
```