diff --git a/next_app/src/components/drawer/components/file-list.tsx b/next_app/src/components/drawer/components/file-list.tsx
index 8cec1d6..fd5f968 100644
--- a/next_app/src/components/drawer/components/file-list.tsx
+++ b/next_app/src/components/drawer/components/file-list.tsx
@@ -1,6 +1,8 @@
import { useGlobalState, useProjectManager } from "@/hooks";
import { TDrawerItem } from "."
import { Button } from "@/components/ui/button";
+import Dropzone from "react-dropzone";
+import { toast } from "sonner";
function FileList() {
const manager = useProjectManager();
@@ -9,11 +11,13 @@ function FileList() {
if (globalState.activeProject) {
const project = manager.projects[globalState.activeProject];
return
-
FILE EXPLORER {
- document.getElementById("new-file")?.click()
- }}
- >+ New File
+
FILE EXPLORER
+ {
+ document.getElementById("new-file")?.click()
+ }}
+ >+ New File
+
{
Object.keys(project.files).toSorted().map((fname, i) =>
)
}
+
+
{
+ console.log(acceptedFiles)
+ const file = acceptedFiles[0]
+ const reader = new FileReader()
+ reader.onload = () => {
+ console.log(reader.result)
+ // add new file to project
+ const proj = manager.getProject(globalState.activeProject);
+ if (proj.files[file.name]) return toast.error("File already exists")
+ const f = manager.newFile(proj, {
+ name: file.name,
+ type: file.name.endsWith(".luanb") ? "NOTEBOOK" : "NORMAL",
+ initialContent: reader.result as string,
+ });
+ // if notebook replace content
+ if (f.type == "NOTEBOOK") {
+ f.content = JSON.parse(reader.result as string).content;
+ proj.files[f.name] = f;
+ manager.projects[globalState.activeProject] = proj;
+ manager.saveProjects(manager.projects);
+ }
+ globalState.setActiveFile(file.name);
+ }
+ reader.readAsText(file)
+ }}>
+ {({ getRootProps, getInputProps, isDragActive, isDragAccept, isDragReject }) => {
+ return (
+
+
+
+ {/*
Drag 'n' drop some files here, or click to select files
*/}
+ Upload File (.lua, .luanb, .md)
+
+
+ )
+ }}
+
+
} else {
return
diff --git a/next_app/src/components/menubar/components/new-file.tsx b/next_app/src/components/menubar/components/new-file.tsx
index 5bf3b8e..1cb1c52 100644
--- a/next_app/src/components/menubar/components/new-file.tsx
+++ b/next_app/src/components/menubar/components/new-file.tsx
@@ -56,7 +56,7 @@ export default function NewFile() {
Enter the name of the file you want to create (supported extensions: lua, luanb, md)
setNewFileName(e.target.value)} onKeyDown={handleEnter} />
-
+
{/* Upload File (coming soon...) */}
- {({ getRootProps, getInputProps }) => (
-
-
-
- {/*
Drag 'n' drop some files here, or click to select files
*/}
- Upload File (.lua, .luanb, .md)
-
-
- )}
+ {({ getRootProps, getInputProps, isDragActive, isDragAccept, isDragReject }) => {
+ return (
+
+
+
+ {/*
Drag 'n' drop some files here, or click to select files
*/}
+ Upload File (.lua, .luanb, .md)
+
+
+ )
+ }}
newFile()}>Create File