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