Skip to content

Commit

Permalink
[#61762] Override ytext with initialText if ytext is empty
Browse files Browse the repository at this point in the history
  • Loading branch information
MaciejWas committed Jul 2, 2024
1 parent 929fd1f commit 0655766
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/components/CodeMirror.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,11 @@ const CodeMirror = ({ text, id, name, mode, collaboration, spellcheckOpts, highl
if (editorRef.current) return;
if (error) return;

if (ytext?.toString().length === 0 && text.get().length > 0) {
console.warn("[Collaboration] Remote state is empty, overriding with local state");
ytext.insert(0, text.get());
}

if (collaboration.enabled) text.set(ytext.toString());

text.readyToRender();
Expand Down

0 comments on commit 0655766

Please sign in to comment.