From d49893b714f7f74e6846a1124d31f11fbb4dd422 Mon Sep 17 00:00:00 2001 From: "Gabriel Mowses (Mouse)" Date: Thu, 2 Apr 2026 10:16:46 -0300 Subject: [PATCH] fix: populate Y.Doc with page content on first sync when editor is empty --- ux/src/components/EditorWysiwyg.vue | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/ux/src/components/EditorWysiwyg.vue b/ux/src/components/EditorWysiwyg.vue index 6461155d..b4c14aed 100644 --- a/ux/src/components/EditorWysiwyg.vue +++ b/ux/src/components/EditorWysiwyg.vue @@ -694,7 +694,17 @@ function init () { state.collabEnabled = false console.warn('[Collab] Disconnected') }, - onSynced() { console.info('[Collab] Synced with server') }, + onSynced({ state: syncState }) { + console.info('[Collab] Synced with server') + // If Y.Doc is empty after sync, populate with page content + if (editor && editor.value && editor.value.isEmpty) { + const html = pageStore.render || pageStore.content || '' + if (html) { + console.info('[Collab] Y.Doc empty, inserting page content:', html.length, 'chars') + editor.value.commands.setContent(html) + } + } + }, onStatus(event) { console.info('[Collab] Status:', event.status) }, onClose(event) { console.warn('[Collab] Closed:', event.event?.code, event.event?.reason) } })