mirror of
https://github.com/ueberdosis/tiptap.git
synced 2024-12-15 11:09:01 +08:00
add something broken
This commit is contained in:
parent
5b530d5d0c
commit
5433870183
@ -47,15 +47,19 @@ export default {
|
|||||||
// this.editor.view.updateState(this.state.edit)
|
// this.editor.view.updateState(this.state.edit)
|
||||||
// return false
|
// return false
|
||||||
// },
|
// },
|
||||||
onUpdate: ({ state }) => {
|
onUpdate: ({ state, oldState }) => {
|
||||||
this.getSendableSteps(state)
|
this.getSendableSteps(state, oldState)
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
getSendableSteps: debounce(function (state) {
|
getSendableSteps: debounce(function (state, oldState) {
|
||||||
const sendable = sendableSteps(state)
|
const sendable = sendableSteps(state)
|
||||||
|
|
||||||
|
console.log('update editor', { sendable })
|
||||||
|
|
||||||
|
// console.log({ state, oldState })
|
||||||
|
|
||||||
if (sendable) {
|
if (sendable) {
|
||||||
this.socket.emit('update', sendable)
|
this.socket.emit('update', sendable)
|
||||||
|
|
||||||
@ -63,7 +67,7 @@ export default {
|
|||||||
const clientIDs = this.repeat(sendable.clientID, steps.length)
|
const clientIDs = this.repeat(sendable.clientID, steps.length)
|
||||||
|
|
||||||
this.history.push({
|
this.history.push({
|
||||||
state,
|
state: oldState,
|
||||||
version: getVersion(state),
|
version: getVersion(state),
|
||||||
steps,
|
steps,
|
||||||
clientIDs,
|
clientIDs,
|
||||||
@ -116,7 +120,7 @@ export default {
|
|||||||
console.log('version in sync', version)
|
console.log('version in sync', version)
|
||||||
// TODO remove steps older than version
|
// TODO remove steps older than version
|
||||||
})
|
})
|
||||||
.on('versionMismatch', ({ version, data }) => {
|
.on('versionMismatch', ({ version, data, doc }) => {
|
||||||
console.log('version mismatch', version)
|
console.log('version mismatch', version)
|
||||||
// TODO: go back to `version`, apply `steps`, apply unmerged `steps`
|
// TODO: go back to `version`, apply `steps`, apply unmerged `steps`
|
||||||
|
|
||||||
@ -124,20 +128,47 @@ export default {
|
|||||||
|
|
||||||
const { state, view, schema } = this.editor
|
const { state, view, schema } = this.editor
|
||||||
|
|
||||||
view.updateState(history.state)
|
// view.updateState(history.state)
|
||||||
|
|
||||||
view.dispatch(receiveTransaction(
|
console.log('other steps', { data })
|
||||||
|
// console.log(getVersion(view.state))
|
||||||
|
|
||||||
|
const newstate = history.state.apply(receiveTransaction(
|
||||||
history.state,
|
history.state,
|
||||||
data.map(item => Step.fromJSON(schema, item.step)),
|
data.map(item => Step.fromJSON(schema, item.step)),
|
||||||
data.map(item => item.clientID),
|
data.map(item => item.clientID),
|
||||||
))
|
))
|
||||||
|
|
||||||
|
view.updateState(newstate)
|
||||||
|
|
||||||
|
// const newstate2 = newstate.apply(receiveTransaction(
|
||||||
|
// newstate,
|
||||||
|
// history.steps,
|
||||||
|
// history.clientIDs,
|
||||||
|
// ))
|
||||||
|
|
||||||
view.dispatch(receiveTransaction(
|
view.dispatch(receiveTransaction(
|
||||||
history.state,
|
state,
|
||||||
history.steps,
|
history.steps,
|
||||||
history.clientIDs,
|
history.clientIDs,
|
||||||
))
|
))
|
||||||
|
|
||||||
|
// view.updateState(newstate2)
|
||||||
|
|
||||||
|
// view.dispatch(receiveTransaction(
|
||||||
|
// view.state,
|
||||||
|
// data.map(item => Step.fromJSON(schema, item.step)),
|
||||||
|
// data.map(item => item.clientID),
|
||||||
|
// ))
|
||||||
|
|
||||||
|
// console.log('own', { history })
|
||||||
|
|
||||||
|
// view.dispatch(receiveTransaction(
|
||||||
|
// history.state,
|
||||||
|
// history.steps,
|
||||||
|
// history.clientIDs,
|
||||||
|
// ))
|
||||||
|
|
||||||
// const transaction = receiveTransaction(
|
// const transaction = receiveTransaction(
|
||||||
// state,
|
// state,
|
||||||
// steps,
|
// steps,
|
||||||
|
Loading…
Reference in New Issue
Block a user