feat: better definitions

This commit is contained in:
cudr
2019-10-06 23:56:27 +03:00
parent fbcbef02af
commit 86e9e77410
10 changed files with 49 additions and 31 deletions

View File

@@ -35,8 +35,6 @@ class Connection {
this.docSet = new Automerge.DocSet()
window['getDoc'] = () => toJS(this.docSet.getDoc(this.docId))
this.connect()
}
@@ -62,12 +60,6 @@ class Connection {
if (operations.length !== 0) {
const slateOps = toSlateOp(operations, currentDoc)
// console.log('start key', KeyUtils.create())
console.log('operations', operations, slateOps)
// console.log('this.editor', this.editor)
this.editor.remote = true
this.editor.withoutSaving(() => {
@@ -84,8 +76,6 @@ class Connection {
}
receiveSlateOps = (operations: Immutable.List<Operation>) => {
console.log('change slate ops!!!', operations.map(op => op.toJSON()).toJS())
const doc = this.docSet.getDoc(this.docId)
const message = `change from ${this.socket.id}`
@@ -95,8 +85,6 @@ class Connection {
applySlateOps(d, operations)
)
// console.log('changed!!!', toJS(changed))
this.docSet.setDoc(this.docId, changed)
}

View File

@@ -1,4 +1,7 @@
import React, { Component, ReactNode } from 'react'
import React, { Component } from 'react'
import { KeyUtils } from 'slate'
import { hexGen } from '@slate-collaborative/bridge'
import Connection from './Connection'
@@ -14,6 +17,8 @@ class Controller extends Component<ControllerProps> {
componentDidMount() {
const { editor, url, connectOpts } = this.props
KeyUtils.setGenerator(() => hexGen())
editor.connection = new Connection({
editor,
url,