diff --git a/src/components/CodeMirror.jsx b/src/components/CodeMirror.jsx index 9fed878..abe5720 100644 --- a/src/components/CodeMirror.jsx +++ b/src/components/CodeMirror.jsx @@ -217,6 +217,11 @@ const CodeMirror = ({ text, root, mode, spellcheckOpts, highlights, collaboratio if (editorView.value) return; if (collaboration.error) return; + if (collaboration.ytext?.toString().length === 0 && text.get().length > 0) { + console.warn("[Collaboration] Remote state is empty, overriding with local state"); + collaboration.ytext.insert(0, text.get()); + } + if (collaboration.opts.enabled) { text.set(collaboration.ytext.toString()); collaboration.ytext.observe((ev, tr) => {