mirror of
https://github.com/cudr/slate-collaborative.git
synced 2026-03-02 03:40:18 +00:00
feat: success add & remove marks
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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 = {
|
||||
|
||||
Reference in New Issue
Block a user