From ee12e0577daa663dce752e80ff427655f087ab29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philipp=20Ku=CC=88hn?= Date: Fri, 3 May 2019 16:05:30 +0200 Subject: [PATCH] add something broken --- .../Routes/Collaboration3/index.vue | 42 ++++++++++++------- 1 file changed, 26 insertions(+), 16 deletions(-) diff --git a/examples/Components/Routes/Collaboration3/index.vue b/examples/Components/Routes/Collaboration3/index.vue index 471909ec..7267a472 100644 --- a/examples/Components/Routes/Collaboration3/index.vue +++ b/examples/Components/Routes/Collaboration3/index.vue @@ -9,7 +9,9 @@ import io from 'socket.io-client' import { debounce } from 'lodash-es' import { Editor, EditorContent } from 'tiptap' import { Step } from 'prosemirror-transform' -import { receiveTransaction, sendableSteps, getVersion } from 'prosemirror-collab' +import { + receiveTransaction, sendableSteps, getVersion, rebaseSteps, +} from 'prosemirror-collab' import Collab from './Collab' export default { @@ -71,6 +73,7 @@ export default { version: getVersion(state), steps, clientIDs, + sendable, }) const transaction = receiveTransaction( @@ -125,13 +128,9 @@ export default { // TODO: go back to `version`, apply `steps`, apply unmerged `steps` const history = this.history.find(item => item.version === version) - const { state, view, schema } = this.editor - // view.updateState(history.state) - - console.log('other steps', { data }) - // console.log(getVersion(view.state)) + // console.log('other steps', { data }) const newstate = history.state.apply(receiveTransaction( history.state, @@ -139,19 +138,30 @@ export default { data.map(item => item.clientID), )) + // this.editor.state = view.updateState(newstate) - // const newstate2 = newstate.apply(receiveTransaction( - // newstate, - // history.steps, - // history.clientIDs, - // )) + if (history.steps.length) { + view.dispatch(receiveTransaction( + state, + 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)