mirror of
https://github.com/wavetermdev/waveterm.git
synced 2025-01-02 18:39:05 +01:00
remove unnecessary height and width from codeeditor
This commit is contained in:
parent
0413b240dd
commit
2cc0fdc999
@ -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<HTMLDivElement>;
|
||||
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<HTMLDivElement>(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}
|
||||
|
@ -691,7 +691,7 @@ function StreamingPreview({ model }: SpecializedViewProps) {
|
||||
return <CenteredDiv>Preview Not Supported</CenteredDiv>;
|
||||
}
|
||||
|
||||
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 (
|
||||
<CodeEditor
|
||||
parentRef={parentRef}
|
||||
text={fileContent}
|
||||
filename={fileName}
|
||||
onChange={(text) => setNewFileContent(text)}
|
||||
|
Loading…
Reference in New Issue
Block a user