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.
 
 
 
 
Go to file
curd f65ab040ee
feat: update changelog
3 years ago
.github/ISSUE_TEMPLATE Update issue templates 4 years ago
packages v0.7.2 3 years ago
.gitignore feat: update to slate 0.58 && fix site build 4 years ago
.prettierrc initial commit 5 years ago
.travis.yml feat: clear depts 5 years ago
CHANGELOG.md feat: update changelog 3 years ago
License.md feat: update to slate 0.5x (#10) 4 years ago
README.md Preserve external history option (#22) 4 years ago
changelog-template.hbs feat: modify changelog template 4 years ago
commitlint.config.js feat: add auto-changelog 4 years ago
lerna.json v0.7.2 3 years ago
package.json build(deps-dev): bump husky from 3.1.0 to 4.3.6 (#46) 3 years ago
tsconfig.base.json feat: update to slate 0.5x (#10) 4 years ago
tslint.json initial commit 5 years ago

README.md

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
  preserveExternalHistory?: boolean // preserve slate-history operations form other clients
}

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