diff --git a/sandpack-react/src/components/CodeEditor/CodeMirror.tsx b/sandpack-react/src/components/CodeEditor/CodeMirror.tsx index 480ef4073..643c05b3e 100644 --- a/sandpack-react/src/components/CodeEditor/CodeMirror.tsx +++ b/sandpack-react/src/components/CodeEditor/CodeMirror.tsx @@ -228,6 +228,12 @@ export const CodeMirror = React.forwardRef( }); const parentDiv = wrapper.current; + const existingPlaceholder = parentDiv.querySelector( + ".sp-pre-placeholder" + ); + if (existingPlaceholder) { + parentDiv.removeChild(existingPlaceholder); + } const view = new EditorView({ state: startState, @@ -350,9 +356,7 @@ export const CodeMirror = React.forwardRef( if (readOnly) { return (
-          {!shouldInitEditor && (
-            {code}
-          )}
+          {code}
 
           {readOnly && showReadOnly && (
             Read-only
@@ -376,16 +380,14 @@ export const CodeMirror = React.forwardRef(
         tabIndex={0}
         translate="no"
       >
-        {!shouldInitEditor && (
-          
-            {code}
-          
- )} +
+          {code}
+        
<>