diff --git a/services/web/frontend/js/features/source-editor/components/codemirror-editor.tsx b/services/web/frontend/js/features/source-editor/components/codemirror-editor.tsx index d116bd600c..753079f6be 100644 --- a/services/web/frontend/js/features/source-editor/components/codemirror-editor.tsx +++ b/services/web/frontend/js/features/source-editor/components/codemirror-editor.tsx @@ -40,6 +40,13 @@ function CodeMirrorEditor() { const isMounted = useIsMounted() const editContextEnabled = useFeatureFlag('edit-context') + const { openDocName } = useEditorOpenDocContext() + const { showVisual } = useEditorPropertiesContext() + + const VisualEditor = + showVisual && openDocName != null + ? getVisualEditorComponent(openDocName) + : null // create the view using the initial state and intercept transactions const viewRef = useRef(null) @@ -64,27 +71,26 @@ function CodeMirrorEditor() { return ( - + ) } -function CodeMirrorEditorComponents() { +type CodeMirrorEditorComponentsProps = { + hidden: boolean +} + +function CodeMirrorEditorComponents({ + hidden = false, +}: CodeMirrorEditorComponentsProps) { useToolbarMenuBarEditorCommands() const { features } = useProjectContext() - const { openDocName } = useEditorOpenDocContext() - const { showVisual } = useEditorPropertiesContext() - - const VisualEditor = - showVisual && openDocName != null - ? getVisualEditorComponent(openDocName) - : null - return ( - + ) } diff --git a/services/web/frontend/js/features/source-editor/components/codemirror-view.tsx b/services/web/frontend/js/features/source-editor/components/codemirror-view.tsx index 4968e10367..4361930a14 100644 --- a/services/web/frontend/js/features/source-editor/components/codemirror-view.tsx +++ b/services/web/frontend/js/features/source-editor/components/codemirror-view.tsx @@ -3,7 +3,11 @@ import { useCodeMirrorViewContext } from './codemirror-context' import useCodeMirrorScope from '../hooks/use-codemirror-scope' import { useEditorViewContext } from '@/features/ide-react/context/editor-view-context' -function CodeMirrorView() { +type CodeMirrorViewProps = { + hidden: boolean +} + +function CodeMirrorView({ hidden = false }: CodeMirrorViewProps) { const view = useCodeMirrorViewContext() const { setView } = useEditorViewContext() @@ -33,7 +37,7 @@ function CodeMirrorView() { useCodeMirrorScope(view) - return
+ return