Skip to content

Commit

Permalink
feat: Expose yjs debug function via OCA.Collectives
Browse files Browse the repository at this point in the history
Should make it easier to debug sync issues.

Signed-off-by: Jonas <[email protected]>
  • Loading branch information
mejo- committed Nov 5, 2024
1 parent 9729f64 commit 1bec7a7
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/mixins/editorMixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ export default {
},
})
: null
this.setupEditorDebug()
},

updateEditorContent(markdown) {
Expand All @@ -192,5 +193,29 @@ export default {
this.hide('outline')
}
},

setupEditorDebug() {
window.OCA.Collectives.editorApi = this.editor
window.OCA.Collectives.editorComponent = this.editor.vm.$children[0]
if (this.editor.debugYjs) {
window.OCA.Collectives.debugYjs = () => {
console.debug('Running debugYjs through editor API')
window.OCA.Collectives.editorApi.debugYjs()
}
} else {
window.OCA.Collectives.debugYjs = () => {
const yjsData = {
clientId: window.OCA.Collectives.editorComponent.$ydoc.clientID,
pendingStructs: window.OCA.Collectives.editorComponent.$ydoc.store.pendingStructs,
clientVectors: [],
documentState: window.OCA.Collectives.editorComponent.$syncService.getDocumentState(),
}
for (const client of window.OCA.Collectives.editorComponent.$ydoc.store.clients.values()) {
yjsData.clientVectors.push(client.at(-1).id)
}
console.debug('Yjs data', JSON.stringify(yjsData))
}
}
},
},
}

0 comments on commit 1bec7a7

Please sign in to comment.