diff --git a/src/mixins/editorMixin.js b/src/mixins/editorMixin.js index d7bdcaebb..c14370501 100644 --- a/src/mixins/editorMixin.js +++ b/src/mixins/editorMixin.js @@ -170,6 +170,7 @@ export default { }, }) : null + this.setupEditorDebug() }, updateEditorContent(markdown) { @@ -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)) + } + } + }, }, }