Skip to content

Commit e1d4e54

Browse files
committed
Add file import and export functionality (Closes #119)
1 parent 2de730d commit e1d4e54

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

src/pages/EditorComponent.js

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,7 @@ function EditorComponent() {
242242
);
243243
if (!selectedLanguage) {
244244
console.error("Unsupported file type");
245+
enqueueSnackbar("Unsupported file type", { variant: "error" });
245246
isImportingRef.current = false;
246247
setIsImporting(false);
247248
return;
@@ -269,9 +270,11 @@ function EditorComponent() {
269270
};
270271

271272
// download file
273+
const [isDownloading, setDownloading] = React.useState(false);
272274
const exportFile = () => {
273-
if (!code) return;
275+
if (!code) return;
274276

277+
setDownloading(true);
275278
const fileContent = code;
276279

277280
const extensionMap = {
@@ -294,6 +297,7 @@ function EditorComponent() {
294297

295298
document.body.removeChild(link);
296299
URL.revokeObjectURL(url);
300+
setDownloading(false);
297301
};
298302

299303
const handleEditorDidMount = useCallback(
@@ -463,8 +467,17 @@ function EditorComponent() {
463467
},
464468
})}
465469
>
466-
<FaFileDownload fontSize="small" />
467-
Export
470+
{isDownloading ? (
471+
<>
472+
<CircularProgress size={16} color="inherit" />
473+
Exporting...
474+
</>
475+
) : (
476+
<>
477+
<FaFileDownload fontSize="small" />
478+
Export
479+
</>
480+
)}
468481
</StyledButton>
469482
</div>
470483

0 commit comments

Comments
 (0)