feat: success add & remove marks

This commit is contained in:
cudr
2019-10-06 13:30:35 +03:00
parent 61c3b830dc
commit fbcbef02af
5 changed files with 40 additions and 44 deletions

View File

@@ -35,6 +35,8 @@ class Connection {
this.docSet = new Automerge.DocSet()
window['getDoc'] = () => toJS(this.docSet.getDoc(this.docId))
this.connect()
}
@@ -60,19 +62,17 @@ 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)
// console.log('this.editor', this.editor)
this.editor.remote = true
this.editor.withoutSaving(() => {
slateOps.forEach(o => {
this.editor.applyOperation(o)
if (o.type === 'insert_node') {
o.node.regenerateKey()
}
})
})
@@ -84,7 +84,7 @@ class Connection {
}
receiveSlateOps = (operations: Immutable.List<Operation>) => {
console.log('change slate ops!!!', operations.toJS())
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,7 +95,7 @@ class Connection {
applySlateOps(d, operations)
)
console.log('changed!!!', toJS(changed))
// console.log('changed!!!', toJS(changed))
this.docSet.setDoc(this.docId, changed)
}

View File

@@ -1,10 +1,10 @@
import React, { PureComponent, ReactNode } from 'react'
import React, { Component, ReactNode } from 'react'
import Connection from './Connection'
import { ControllerProps } from './model'
class Controller extends PureComponent<ControllerProps> {
class Controller extends Component<ControllerProps> {
connection?: Connection
state = {