diff --git a/README.md b/README.md index d2cfd64..367f03e 100644 --- a/README.md +++ b/README.md @@ -63,7 +63,7 @@ const connection = new SocketIOConnection(options) onDocumentLoad: ( // request slate document callback pathname: string, query?: Object - ) => Node[] + ) => Promise | Node[] onDocumentSave: (pathname: string, doc: Node[]) => Promise | void // save document callback } ``` diff --git a/packages/backend/src/AutomergeBackend.ts b/packages/backend/src/AutomergeBackend.ts index 5a30075..5302c29 100644 --- a/packages/backend/src/AutomergeBackend.ts +++ b/packages/backend/src/AutomergeBackend.ts @@ -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}`) diff --git a/packages/backend/src/SocketIOConnection.ts b/packages/backend/src/SocketIOConnection.ts index 3856406..c7171a3 100644 --- a/packages/backend/src/SocketIOConnection.ts +++ b/packages/backend/src/SocketIOConnection.ts @@ -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 - onDocumentLoad?: (pathname: string, query?: Object) => Element[] - onDocumentSave?: (pathname: string, doc: Element[]) => Promise | void + onDocumentLoad?: ( + pathname: string, + query?: Object + ) => Promise | Node[] + onDocumentSave?: (pathname: string, doc: Node[]) => Promise | void } export default class SocketIOCollaboration {