mirror of
https://github.com/cudr/slate-collaborative.git
synced 2024-10-27 20:34:06 +00:00
e3068d0b48
Bumps [ts-jest](https://github.com/kulshekhar/ts-jest) from 25.5.1 to 26.4.4. - [Release notes](https://github.com/kulshekhar/ts-jest/releases) - [Changelog](https://github.com/kulshekhar/ts-jest/blob/master/CHANGELOG.md) - [Commits](https://github.com/kulshekhar/ts-jest/compare/v25.5.1...v26.4.4) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> |
||
---|---|---|
.github/ISSUE_TEMPLATE | ||
packages | ||
.gitignore | ||
.prettierrc | ||
.travis.yml | ||
changelog-template.hbs | ||
CHANGELOG.md | ||
commitlint.config.js | ||
lerna.json | ||
License.md | ||
package.json | ||
README.md | ||
tsconfig.base.json | ||
tslint.json |
slate-collaborative. Check demo
slatejs collaborative plugin & microservice
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