add something broken
This commit is contained in:
@@ -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,19 +138,30 @@ 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,
|
view.dispatch(receiveTransaction(
|
||||||
// history.steps,
|
state,
|
||||||
// history.clientIDs,
|
history.steps,
|
||||||
// ))
|
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.dispatch(receiveTransaction(
|
|
||||||
state,
|
|
||||||
history.steps,
|
|
||||||
history.clientIDs,
|
|
||||||
))
|
|
||||||
|
|
||||||
// view.updateState(newstate2)
|
// view.updateState(newstate2)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user