diff --git a/Frontend/src/components/EditorArea.jsx b/Frontend/src/components/EditorArea.jsx
index c24d41c..89b954b 100644
--- a/Frontend/src/components/EditorArea.jsx
+++ b/Frontend/src/components/EditorArea.jsx
@@ -662,6 +662,37 @@ Happy coding!`;
}
};
+ // Add this function above the return statement
+ const handleDownloadFile = () => {
+ if (!activeFile) return;
+
+ // Create a blob with the file content
+ const blob = new Blob([activeFile.content], { type: 'text/plain' });
+
+ // Create a URL for the blob
+ const url = URL.createObjectURL(blob);
+
+ // Create a temporary anchor element
+ const a = document.createElement('a');
+ a.href = url;
+
+ // Get just the filename without path
+ const fileName = activeFile.id.includes('/') ?
+ activeFile.id.split('/').pop() :
+ activeFile.id;
+
+ // Set the download attribute with the filename
+ a.download = fileName;
+
+ // Append to the document, click it, and then remove it
+ document.body.appendChild(a);
+ a.click();
+ document.body.removeChild(a);
+
+ // Release the object URL
+ URL.revokeObjectURL(url);
+ };
+
return (
{sidebarVisible && (
@@ -818,6 +849,7 @@ Happy coding!`;
>
)}
+ {/* Modify the editor-actions div to include the download button */}
+
+ {/* Add download button */}
+
{isNewFileModalOpen && (
@@ -886,6 +942,61 @@ Happy coding!`;
Rename
+
+ {/* Add download option - only show for files */}
+ {contextMenuTarget?.type === 'file' && (
+ {
+ // Find the file in the files array
+ const file = files.find(f => f.id === contextMenuTarget.path);
+ if (file) {
+ // Create a blob with the file content
+ const blob = new Blob([file.content], { type: 'text/plain' });
+
+ // Create a URL for the blob
+ const url = URL.createObjectURL(blob);
+
+ // Create a temporary anchor element
+ const a = document.createElement('a');
+ a.href = url;
+
+ // Get just the filename without path
+ const fileName = file.id.includes('/') ?
+ file.id.split('/').pop() :
+ file.id;
+
+ // Set the download attribute with the filename
+ a.download = fileName;
+
+ // Append to the document, click it, and then remove it
+ document.body.appendChild(a);
+ a.click();
+ document.body.removeChild(a);
+
+ // Release the object URL
+ URL.revokeObjectURL(url);
+ }
+ closeContextMenu();
+ }}>
+
+ Download
+
+ )}
+
{
deleteItem(contextMenuTarget.path, contextMenuTarget.type);
closeContextMenu();
diff --git a/backend/tmp/main.exe b/backend/tmp/main.exe
index fadda57..345d959 100644
Binary files a/backend/tmp/main.exe and b/backend/tmp/main.exe differ