mirror of
https://github.com/cudr/slate-collaborative.git
synced 2024-10-27 20:34:06 +00:00
Changed the backend socket config types fom Element[] to Node[] and m… (#14)
* Changed the backend socket config types fom Element[] to Node[] and made the onDocumentLoad async * Updated onDocumentLoad in readme
This commit is contained in:
parent
2a6d99c171
commit
aaa6d1fa54
@ -63,7 +63,7 @@ const connection = new SocketIOConnection(options)
|
||||
onDocumentLoad: ( // request slate document callback
|
||||
pathname: string,
|
||||
query?: Object
|
||||
) => Node[]
|
||||
) => Promise<Node[]> | Node[]
|
||||
onDocumentSave: (pathname: string, doc: Node[]) => Promise<void> | void // save document callback
|
||||
}
|
||||
```
|
||||
|
@ -1,6 +1,6 @@
|
||||
import * as Automerge from 'automerge'
|
||||
|
||||
import { Element } from 'slate'
|
||||
import { Node } from 'slate'
|
||||
|
||||
import {
|
||||
toCollabAction,
|
||||
@ -79,7 +79,7 @@ class AutomergeBackend {
|
||||
* Append document to Automerge DocSet
|
||||
*/
|
||||
|
||||
appendDocument = (docId: string, data: Element[]) => {
|
||||
appendDocument = (docId: string, data: Node[]) => {
|
||||
try {
|
||||
if (this.getDocument(docId)) {
|
||||
throw new Error(`Already has document with id: ${docId}`)
|
||||
|
@ -1,6 +1,6 @@
|
||||
import io from 'socket.io'
|
||||
import * as Automerge from 'automerge'
|
||||
import { Element } from 'slate'
|
||||
import { Node } from 'slate'
|
||||
import { Server } from 'http'
|
||||
|
||||
import throttle from 'lodash/throttle'
|
||||
@ -14,14 +14,17 @@ import AutomergeBackend from './AutomergeBackend'
|
||||
export interface SocketIOCollaborationOptions {
|
||||
entry: number | Server
|
||||
connectOpts?: SocketIO.ServerOptions
|
||||
defaultValue?: Element[]
|
||||
defaultValue?: Node[]
|
||||
saveFrequency?: number
|
||||
onAuthRequest?: (
|
||||
query: Object,
|
||||
socket?: SocketIO.Socket
|
||||
) => Promise<boolean> | boolean
|
||||
onDocumentLoad?: (pathname: string, query?: Object) => Element[]
|
||||
onDocumentSave?: (pathname: string, doc: Element[]) => Promise<void> | void
|
||||
onDocumentLoad?: (
|
||||
pathname: string,
|
||||
query?: Object
|
||||
) => Promise<Node[]> | Node[]
|
||||
onDocumentSave?: (pathname: string, doc: Node[]) => Promise<void> | void
|
||||
}
|
||||
|
||||
export default class SocketIOCollaboration {
|
||||
|
Loading…
Reference in New Issue
Block a user