|
|
@ -1,6 +1,6 @@
|
|
|
|
import io from 'socket.io'
|
|
|
|
import io from 'socket.io'
|
|
|
|
import * as Automerge from 'automerge'
|
|
|
|
import * as Automerge from 'automerge'
|
|
|
|
import { Element } from 'slate'
|
|
|
|
import { Node } from 'slate'
|
|
|
|
import { Server } from 'http'
|
|
|
|
import { Server } from 'http'
|
|
|
|
|
|
|
|
|
|
|
|
import throttle from 'lodash/throttle'
|
|
|
|
import throttle from 'lodash/throttle'
|
|
|
@ -14,14 +14,17 @@ import AutomergeBackend from './AutomergeBackend'
|
|
|
|
export interface SocketIOCollaborationOptions {
|
|
|
|
export interface SocketIOCollaborationOptions {
|
|
|
|
entry: number | Server
|
|
|
|
entry: number | Server
|
|
|
|
connectOpts?: SocketIO.ServerOptions
|
|
|
|
connectOpts?: SocketIO.ServerOptions
|
|
|
|
defaultValue?: Element[]
|
|
|
|
defaultValue?: Node[]
|
|
|
|
saveFrequency?: number
|
|
|
|
saveFrequency?: number
|
|
|
|
onAuthRequest?: (
|
|
|
|
onAuthRequest?: (
|
|
|
|
query: Object,
|
|
|
|
query: Object,
|
|
|
|
socket?: SocketIO.Socket
|
|
|
|
socket?: SocketIO.Socket
|
|
|
|
) => Promise<boolean> | boolean
|
|
|
|
) => Promise<boolean> | boolean
|
|
|
|
onDocumentLoad?: (pathname: string, query?: Object) => Element[]
|
|
|
|
onDocumentLoad?: (
|
|
|
|
onDocumentSave?: (pathname: string, doc: Element[]) => Promise<void> | void
|
|
|
|
pathname: string,
|
|
|
|
|
|
|
|
query?: Object
|
|
|
|
|
|
|
|
) => Promise<Node[]> | Node[]
|
|
|
|
|
|
|
|
onDocumentSave?: (pathname: string, doc: Node[]) => Promise<void> | void
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
export default class SocketIOCollaboration {
|
|
|
|
export default class SocketIOCollaboration {
|
|
|
|