0.7.31 • Published 2 years ago

@hiveteams/collab-backend v0.7.31

Weekly downloads
1,211
License
MIT
Repository
github
Last release
2 years ago

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
0.7.31

2 years ago

0.7.30

3 years ago

0.7.29

3 years ago

0.7.28

3 years ago

0.7.27

3 years ago

0.7.26

3 years ago

0.7.25

3 years ago

0.7.24

3 years ago

0.7.23

3 years ago

0.7.22

3 years ago

0.7.21

3 years ago

0.7.20

3 years ago

0.7.20-alpha.1

3 years ago

0.7.19

3 years ago

0.7.20-alpha.0

3 years ago

0.7.15

4 years ago

0.7.14

4 years ago

0.7.16

4 years ago

0.7.13

4 years ago

0.7.9

4 years ago

0.7.8

4 years ago

0.7.7

4 years ago

0.7.6

4 years ago

0.7.4

4 years ago

0.7.2

4 years ago

0.7.3

4 years ago

0.7.1

4 years ago