diff --git a/frontend/src/components/features/editor/code-editor-component.tsx b/frontend/src/components/features/editor/code-editor-component.tsx deleted file mode 100644 index 673010b8b1..0000000000 --- a/frontend/src/components/features/editor/code-editor-component.tsx +++ /dev/null @@ -1,115 +0,0 @@ -import { Editor, EditorProps } from "@monaco-editor/react"; -import React from "react"; -import { useTranslation } from "react-i18next"; -import { VscCode } from "react-icons/vsc"; -import { I18nKey } from "#/i18n/declaration"; -import { useFiles } from "#/context/files"; -import { useSaveFile } from "#/hooks/mutation/use-save-file"; - -interface CodeEditorComponentProps { - onMount: EditorProps["onMount"]; - isReadOnly: boolean; -} - -function CodeEditorComponent({ - onMount, - isReadOnly, -}: CodeEditorComponentProps) { - const { t } = useTranslation(); - const { - files, - selectedPath, - modifiedFiles, - modifyFileContent, - saveFileContent: saveNewFileContent, - } = useFiles(); - - const { mutate: saveFile } = useSaveFile(); - - const handleEditorChange = (value: string | undefined) => { - if (selectedPath && value) modifyFileContent(selectedPath, value); - }; - - const isBase64Image = (content: string) => content.startsWith("data:image/"); - const isPDF = (content: string) => content.startsWith("data:application/pdf"); - const isVideo = (content: string) => content.startsWith("data:video/"); - - React.useEffect(() => { - const handleSave = async (event: KeyboardEvent) => { - if (selectedPath && event.metaKey && event.key === "s") { - const content = saveNewFileContent(selectedPath); - - if (content) { - saveFile({ path: selectedPath, content }); - } - } - }; - - document.addEventListener("keydown", handleSave); - return () => { - document.removeEventListener("keydown", handleSave); - }; - }, [saveNewFileContent]); - - if (!selectedPath) { - return ( -
- - {t(I18nKey.CODE_EDITOR$EMPTY_MESSAGE)} -
- ); - } - - const fileContent: string | undefined = - modifiedFiles[selectedPath] || files[selectedPath]; - - if (fileContent) { - if (isBase64Image(fileContent)) { - return ( -
- {selectedPath} -
- ); - } - - if (isPDF(fileContent)) { - return ( -