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 <jonas@freesources.org>
  • Loading branch information
mejo- committed Nov 4, 2024
1 parent 01f1e3a commit 363b14e
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 @@ -166,6 +166,7 @@ export default {
},
})
: null
this.setupEditorDebug()
},

updateEditorContent(markdown) {
Expand All @@ -188,5 +189,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 363b14e

Please sign in to comment.