Go to file
2020-06-22 01:46:15 +03:00
packages feat: add license 2020-06-22 01:46:15 +03:00
.gitignore feat: update to slate 0.58 && fix site build 2020-05-11 09:28:26 +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
changelog-template.hbs feat: modify changelog template 2020-06-22 01:40:35 +03:00
CHANGELOG.md v0.6.5 2020-06-22 01:31:53 +03:00
commitlint.config.js feat: add auto-changelog 2020-06-22 01:23:34 +03:00
lerna.json feat: add license 2020-06-22 01:46:15 +03:00
License.md feat: update to slate 0.5x (#10) 2020-05-10 16:50:12 +03:00
package.json feat: add auto-changelog 2020-06-22 01:23:34 +03:00
README.md feat: add onError cb (#15) 2020-06-07 23:04:23 +03:00
tsconfig.base.json feat: update to slate 0.5x (#10) 2020-05-10 16:50:12 +03:00
tslint.json initial commit 2019-10-05 11:44:49 +03:00

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'

const collaborationEditor = withIOCollaboration(editor, options)

Check detailed example

Options:

{
  docId?: // document id
  url?: string // url to open connection
  connectOpts?: SocketIOClient.ConnectOpts // socket.io-client options
  cursorData?: any // any data passed to cursor
  onConnect?: () => void // connect callback
  onDisconnect?: () => void // disconnect callback
  onError?: (reason: string) => void // error callback
}

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

import { useCursor } from '@slate-collaborative/client'

const decorator = useCursor(editor)

Backend

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

const connection = new SocketIOConnection(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 callback
    query: Object,
    socket?: SocketIO.Socket
  ) => Promise<boolean> | boolean
  onDocumentLoad: ( // request slate document callback
    pathname: string,
    query?: Object
  ) => Promise<Node[]> | Node[]
  onDocumentSave: (pathname: string, doc: Node[]) => Promise<void> | void // save document callback
}

Contribute

You welcome to contribute!

start it ease:

yarn
yarn dev