From 2cc0fdc99909cf3ac988e17445e6850b018dda55 Mon Sep 17 00:00:00 2001 From: Evan Simkowitz Date: Wed, 4 Sep 2024 11:45:26 -0700 Subject: [PATCH] remove unnecessary height and width from codeeditor --- frontend/app/view/codeeditor/codeeditor.tsx | 9 +-------- frontend/app/view/preview/preview.tsx | 5 +---- 2 files changed, 2 insertions(+), 12 deletions(-) diff --git a/frontend/app/view/codeeditor/codeeditor.tsx b/frontend/app/view/codeeditor/codeeditor.tsx index b6a7e7380..acfaf06f9 100644 --- a/frontend/app/view/codeeditor/codeeditor.tsx +++ b/frontend/app/view/codeeditor/codeeditor.tsx @@ -1,8 +1,6 @@ // Copyright 2024, Command Line Inc. // SPDX-License-Identifier: Apache-2.0 -import { useHeight } from "@/app/hook/useHeight"; -import { useWidth } from "@/app/hook/useWidth"; import loader from "@monaco-editor/loader"; import { Editor, Monaco } from "@monaco-editor/react"; import type * as MonacoTypes from "monaco-editor/esm/vs/editor/editor.api"; @@ -66,7 +64,6 @@ function defaultEditorOptions(): MonacoTypes.editor.IEditorOptions { } interface CodeEditorProps { - parentRef: React.MutableRefObject; text: string; filename: string; language?: string; @@ -74,11 +71,9 @@ interface CodeEditorProps { onMount?: (monacoPtr: MonacoTypes.editor.IStandaloneCodeEditor, monaco: Monaco) => () => void; } -export function CodeEditor({ parentRef, text, language, filename, onChange, onMount }: CodeEditorProps) { +export function CodeEditor({ text, language, filename, onChange, onMount }: CodeEditorProps) { const divRef = useRef(null); const unmountRef = useRef<() => void>(null); - const parentHeight = useHeight(parentRef); - const parentWidth = useWidth(parentRef); const theme = "wave-theme-dark"; React.useEffect(() => { @@ -111,8 +106,6 @@ export function CodeEditor({ parentRef, text, language, filename, onChange, onMo theme={theme} value={text} options={editorOpts} - height={parentHeight} - width={parentWidth} onChange={handleEditorChange} onMount={handleEditorOnMount} path={filename} diff --git a/frontend/app/view/preview/preview.tsx b/frontend/app/view/preview/preview.tsx index 7e78298c9..a62eaff75 100644 --- a/frontend/app/view/preview/preview.tsx +++ b/frontend/app/view/preview/preview.tsx @@ -691,7 +691,7 @@ function StreamingPreview({ model }: SpecializedViewProps) { return Preview Not Supported; } -function CodeEditPreview({ parentRef, model }: SpecializedViewProps) { +function CodeEditPreview({ model }: SpecializedViewProps) { const fileContent = jotai.useAtomValue(model.fileContent); const setNewFileContent = jotai.useSetAtom(model.newFileContent); const fileName = jotai.useAtomValue(model.statFilePath); @@ -723,8 +723,6 @@ function CodeEditPreview({ parentRef, model }: SpecializedViewProps) { function onMount(editor: MonacoTypes.editor.IStandaloneCodeEditor, monaco: Monaco): () => void { model.monacoRef.current = editor; - const simpleMod = keyutil.getKeyUtilPlatform() == "darwin" ? monaco.KeyMod.CtrlCmd : monaco.KeyMod.Alt; - editor.onKeyDown((e: MonacoTypes.IKeyboardEvent) => { const waveEvent = keyutil.adaptFromReactOrNativeKeyEvent(e.browserEvent); const handled = tryReinjectKey(waveEvent); @@ -744,7 +742,6 @@ function CodeEditPreview({ parentRef, model }: SpecializedViewProps) { return ( setNewFileContent(text)}