[FIX] Don't display non text files in previewer
This commit is contained in:
parent
9b7539664e
commit
39369fe41a
1 changed files with 13 additions and 2 deletions
|
@ -10,7 +10,17 @@ import Toolbar from "@mui/material/Toolbar";
|
|||
import TextEditor from "./TextEditor.jsx";
|
||||
import { cairoAuthHeader } from "@mcl/util/auth.js";
|
||||
|
||||
const textFileTypes = ["properties", "txt", "yaml", "yml", "json", "env", "toml", "tml", "text"];
|
||||
const textFileTypes = [
|
||||
"properties",
|
||||
"txt",
|
||||
"yaml",
|
||||
"yml",
|
||||
"json",
|
||||
"env",
|
||||
"toml",
|
||||
"tml",
|
||||
"text",
|
||||
];
|
||||
const imageFileTypes = ["png", "jpeg", "jpg"];
|
||||
|
||||
export const supportedFileTypes = [...textFileTypes, ...imageFileTypes];
|
||||
|
@ -44,6 +54,7 @@ export default function FilePreview(props) {
|
|||
}
|
||||
|
||||
async function onSave() {
|
||||
if (!isTextFile) return;
|
||||
const formData = new FormData();
|
||||
const blob = new Blob([modifiedText], { type: "plain/text" });
|
||||
formData.append("file", blob, name);
|
||||
|
@ -77,7 +88,7 @@ export default function FilePreview(props) {
|
|||
<Toolbar sx={{ display: { sm: "none" } }} />
|
||||
<DialogTitle>{name}</DialogTitle>
|
||||
<DialogContent>
|
||||
<TextEditor text={fileText} onChange={editorChange} />
|
||||
{isTextFile && <TextEditor text={fileText} onChange={editorChange} />}
|
||||
</DialogContent>
|
||||
<DialogActions>
|
||||
<Button autoFocus onClick={dialogToggle}>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue