Skip to content

Commit 245d5c8

Browse files
committed
feat(debug): Expose yjs debug function in editor API
Should make it easier to debug sync issues. Signed-off-by: Jonas <[email protected]>
1 parent ad08894 commit 245d5c8

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

src/components/Editor.vue

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -761,6 +761,22 @@ export default {
761761
console.debug(editor.getHTML())
762762
},
763763
764+
/**
765+
* Helper method to debug yjs issues
766+
*/
767+
debugYjs() {
768+
const yjsData = {
769+
clientId: this.$ydoc.clientID,
770+
pendingStructs: this.$ydoc.store.pendingStructs,
771+
clientVectors: [],
772+
documentState: this.$syncService.getDocumentState(),
773+
}
774+
for (const client of this.$ydoc.store.clients.values()) {
775+
yjsData.clientVectors.push(client.at(-1).id)
776+
}
777+
console.debug('Yjs data', JSON.stringify(yjsData))
778+
},
779+
764780
outlineToggled(visible) {
765781
this.emit('outline-toggled', visible)
766782
},

src/editor.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,10 @@ class TextEditorEmbed {
132132
this.#getEditorComponent().$editor.commands.focus()
133133
}
134134

135+
debugYjs() {
136+
this.#getEditorComponent().debugYjs()
137+
}
138+
135139
#registerDebug() {
136140
if (window?._oc_debug) {
137141
this.vm = this.#vm

0 commit comments

Comments
 (0)