Go to file
2019-10-27 23:50:01 +03:00
packages feat: fix server 2019-10-27 23:50:01 +03:00
.gitignore initial commit 2019-10-05 11:44:49 +03:00
.prettierrc initial commit 2019-10-05 11:44:49 +03:00
.travis.yml feat: clear depts 2019-10-27 11:35:30 +03:00
lerna.json initial commit 2019-10-05 11:44:49 +03:00
package.json feat: clear depts 2019-10-27 11:35:30 +03:00
README.md Update README.md 2019-10-19 22:54:24 +03:00
tsconfig.base.json feat: clear depts 2019-10-27 11:35:30 +03:00
tslint.json initial commit 2019-10-05 11:44:49 +03:00

slate-collaborative

slatejs collaborative plugin & microservice

A little experiment for co-editing.

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

Watch the demo

API

Client

Use it as a simple slatejs plugin

check example

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
  renderCursor?: (data: Data) => ReactNode | any // custom cursor render
  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:

{
  port: number // port to start io connection
  connectOpts?: SocketIO.ServerOptions
  defaultValue?: ValueJSON // default value
  saveTreshold?: number // theshold of onDocumentSave callback execution
  cursorAnnotationType?: string // type string for cursor annotations
  onAuthRequest?: ( // auth callback
    query: Object,
    socket?: SocketIO.Socket
  ) => Promise<boolean> | boolean
  onDocumentLoad?: ( // request slatejs document callback
    pathname: string,
    query?: Object
  ) => ValueJSON | null | false | undefined
  onDocumentSave?: (pathname: string, json: ValueJSON) => Promise<void> | void // save document callback 
}