Skip to content

Repository files navigation

slate-collaborative. Check demo

slatejs collaborative plugin & microservice

screencast2019-10-2820-06-10

A little experiment for co-editing.

Based on idea of https://github.com/humandx/slate-automerge

API

Client

Use it as a simple slatejs plugin

import{withIOCollaboration}from'@slate-collaborative/client'constcollaborationEditor=withIOCollaboration(editor,options)

Check detailed example

Options:

{docId?: // document idurl?: string // url to open connectionconnectOpts?: SocketIOClient.ConnectOpts// socket.io-client optionscursorData?: any // any data passed to cursoronConnect?: ()=>void// connect callbackonDisconnect?: ()=>void// disconnect callback}

You need to attach the useCursor decorator to provide custom cursor data in renderLeaf function

import{useCursor}from'@slate-collaborative/client'constdecorator=useCursor(editor)

Backend

const{ SocketIOConnection }=require('@slate-collaborative/backend')constconnection=newSocketIOConnection(options)

options:

{
entry: Server// or specify port to start io server
defaultValue: Node[]// default value
saveFrequency: number// frequency of onDocumentSave callback execution in ms
onAuthRequest: (// auth callbackquery: Object,socket?: SocketIO.Socket)=>Promise<boolean>|boolean
onDocumentLoad: (// request slate document callbackpathname: string,query?: Object)=>Node[]
onDocumentSave: (pathname: string,doc: Node[])=>Promise<void>|void// save document callback}

Contribute

You welcome to contribute!

start it ease:

yarn
yarn dev

About

slatejs collaborative plugin & microservice https://slate-collaborative.herokuapp.com/

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages