|
|
|
@ -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)
|
|
|
|
|
}
|
|
|
|
|