From a412a6ee14cfa6d379a2b00d66b675d18c0a35ee Mon Sep 17 00:00:00 2001 From: Jonas Date: Mon, 4 Nov 2024 13:40:22 +0100 Subject: [PATCH] feat: Expose debug function via OCA.Collectives Should make it easier to debug sync issues. Signed-off-by: Jonas --- src/mixins/editorMixin.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/mixins/editorMixin.js b/src/mixins/editorMixin.js index bbdf45772..1c572e03d 100644 --- a/src/mixins/editorMixin.js +++ b/src/mixins/editorMixin.js @@ -166,6 +166,7 @@ export default { }, }) : null + this.setupEditorDebug() }, updateEditorContent(markdown) { @@ -188,5 +189,19 @@ export default { this.hide('outline') } }, + + setupEditorDebug() { + window.OCA.Collectives.editor = this.editor.vm.$children[0] + window.OCA.Collectives.debugEditor = () => { + console.debug('ydoc clientID:', window.OCA.Collectives.editor.$ydoc.clientID) + console.debug('ydoc pendingStructs:', window.OCA.Collectives.editor.$ydoc.store.pendingStructs) + const clientVectors = [] + for (const client of window.OCA.Collectives.editor.$ydoc.store.clients.values()) { + clientVectors.push(client.at(-1).id) + } + console.debug('ydoc clients vectors:', clientVectors) + console.debug('ydoc document state:', window.OCA.Collectives.editor.$syncService.getDocumentState()) + } + }, }, }