add something broken

This commit is contained in:
Philipp Kühn
2019-05-03 16:05:30 +02:00
parent 5433870183
commit ee12e0577d

View File

@@ -9,7 +9,9 @@ import io from 'socket.io-client'
import { debounce } from 'lodash-es' import { debounce } from 'lodash-es'
import { Editor, EditorContent } from 'tiptap' import { Editor, EditorContent } from 'tiptap'
import { Step } from 'prosemirror-transform' import { Step } from 'prosemirror-transform'
import { receiveTransaction, sendableSteps, getVersion } from 'prosemirror-collab' import {
receiveTransaction, sendableSteps, getVersion, rebaseSteps,
} from 'prosemirror-collab'
import Collab from './Collab' import Collab from './Collab'
export default { export default {
@@ -71,6 +73,7 @@ export default {
version: getVersion(state), version: getVersion(state),
steps, steps,
clientIDs, clientIDs,
sendable,
}) })
const transaction = receiveTransaction( const transaction = receiveTransaction(
@@ -125,13 +128,9 @@ export default {
// TODO: go back to `version`, apply `steps`, apply unmerged `steps` // TODO: go back to `version`, apply `steps`, apply unmerged `steps`
const history = this.history.find(item => item.version === version) const history = this.history.find(item => item.version === version)
const { state, view, schema } = this.editor const { state, view, schema } = this.editor
// view.updateState(history.state) // console.log('other steps', { data })
console.log('other steps', { data })
// console.log(getVersion(view.state))
const newstate = history.state.apply(receiveTransaction( const newstate = history.state.apply(receiveTransaction(
history.state, history.state,
@@ -139,20 +138,31 @@ export default {
data.map(item => item.clientID), data.map(item => item.clientID),
)) ))
// this.editor.state =
view.updateState(newstate) view.updateState(newstate)
// const newstate2 = newstate.apply(receiveTransaction( if (history.steps.length) {
// newstate,
// history.steps,
// history.clientIDs,
// ))
view.dispatch(receiveTransaction( view.dispatch(receiveTransaction(
state, state,
history.steps, history.steps,
history.clientIDs, history.clientIDs,
)) ))
// const sendable = sendableSteps(state)
// console.log({ sendable })
// this.socket.emit('update', {
// version: getVersion(state),
// steps: history.steps,
// })
}
// const currentVersion = getVersion(view.state)
// const historySteps = history.steps
// console.log({ currentVersion, historySteps })
// view.updateState(newstate2) // view.updateState(newstate2)
// view.dispatch(receiveTransaction( // view.dispatch(receiveTransaction(