From c9293feb66ed3959c12adccdefdce87bff59396a Mon Sep 17 00:00:00 2001
From: Thomas Gauvin <35609369+thomasgauvin@users.noreply.github.com>
Date: Sat, 9 Mar 2024 15:52:36 -0500
Subject: [PATCH] backup
---
... a new note.md => This is a new note 2.md} | 0
.../Maybe I need to debounce more.md | 0
.../Untitled Folder (1)/This is a test.md | 18 ---
.../Untitled Folder/Happy thanksgiving!.md | 1 -
.../Untitled Folder/Untitled Folder/Tes.md | 0
.../Untitled Folder/Untitled Folder/Test.md | 1 -
.../We'll see you at Christmas!.md | 1 -
.../Untitled this is a test.md | 0
.../folder/subfolder/test55.md | 3 -
...est TESt \342\234\205 \360\237\247\220.md" | 3 -
.../Interesting1234568915.md} | 0
.../wait renaming works cool.md | 0
.../test11/new-folder10/new file.md | 0
.../test11/test this is a test.md | 1 -
.../\342\234\205 Todo list.md" | 31 ++---
.../{Folder.tsx => FileSystemItem.tsx} | 25 +++-
.../FileSystem/LocalFileSystem.tsx | 45 ++++---
.../FileSystem/RightClickMenu.tsx | 40 +++++-
.../FileSystem/WorkspaceSelector.tsx | 118 +++++++++++++-----
src/components/MarkdownEditor/FileEditor.tsx | 14 ++-
src/components/MarkdownEditor/OnClickLink.tsx | 37 ++++++
src/components/MarkdownEditor/OnFocus.tsx | 21 ++++
.../MarkdownEditor/RemirrorComponent.tsx | 8 +-
.../MarkdownEditor/RemirrorMarkdownEditor.tsx | 45 ++-----
src/models/DirectoryNode.ts | 43 +++++++
src/pages/Editor.tsx | 10 +-
26 files changed, 323 insertions(+), 142 deletions(-)
rename sample-markdown-folder/{This is a new note.md => This is a new note 2.md} (100%)
delete mode 100644 sample-markdown-folder/folder/Untitled Folder (1)/Maybe I need to debounce more.md
delete mode 100644 sample-markdown-folder/folder/Untitled Folder (1)/This is a test.md
delete mode 100644 sample-markdown-folder/folder/Untitled Folder (1)/Untitled Folder/Happy thanksgiving!.md
delete mode 100644 sample-markdown-folder/folder/Untitled Folder (1)/Untitled Folder/Untitled Folder/Tes.md
delete mode 100644 sample-markdown-folder/folder/Untitled Folder (1)/Untitled Folder/Untitled Folder/Test.md
delete mode 100644 sample-markdown-folder/folder/Untitled Folder (1)/Untitled Folder/Untitled Folder/We'll see you at Christmas!.md
delete mode 100644 sample-markdown-folder/folder/Untitled Folder (1)/Untitled Folder/Untitled this is a test.md
delete mode 100644 sample-markdown-folder/folder/subfolder/test55.md
delete mode 100644 "sample-markdown-folder/folder/subfolder/thi si a test TESt \342\234\205 \360\237\247\220.md"
rename sample-markdown-folder/{folder/Interesting.md => sample folder for notes 2/Interesting1234568915.md} (100%)
rename sample-markdown-folder/{folder => sample folder for notes 2}/wait renaming works cool.md (100%)
delete mode 100644 sample-markdown-folder/test11/new-folder10/new file.md
delete mode 100644 sample-markdown-folder/test11/test this is a test.md
rename src/components/FileSystemAdapters/FileSystem/{Folder.tsx => FileSystemItem.tsx} (86%)
create mode 100644 src/components/MarkdownEditor/OnClickLink.tsx
create mode 100644 src/components/MarkdownEditor/OnFocus.tsx
diff --git a/sample-markdown-folder/This is a new note.md b/sample-markdown-folder/This is a new note 2.md
similarity index 100%
rename from sample-markdown-folder/This is a new note.md
rename to sample-markdown-folder/This is a new note 2.md
diff --git a/sample-markdown-folder/folder/Untitled Folder (1)/Maybe I need to debounce more.md b/sample-markdown-folder/folder/Untitled Folder (1)/Maybe I need to debounce more.md
deleted file mode 100644
index e69de29..0000000
diff --git a/sample-markdown-folder/folder/Untitled Folder (1)/This is a test.md b/sample-markdown-folder/folder/Untitled Folder (1)/This is a test.md
deleted file mode 100644
index c8cd475..0000000
--- a/sample-markdown-folder/folder/Untitled Folder (1)/This is a test.md
+++ /dev/null
@@ -1,18 +0,0 @@
-Interesting, it's not that bad
-
-## He's a prick
-
-### How long since you spoke
-
-**Ok pretty cool**
-
-* Where **~are~** my
-
-
-1. Where are my numbers
-
-2. Test
-
-
-Tes
-test
\ No newline at end of file
diff --git a/sample-markdown-folder/folder/Untitled Folder (1)/Untitled Folder/Happy thanksgiving!.md b/sample-markdown-folder/folder/Untitled Folder (1)/Untitled Folder/Happy thanksgiving!.md
deleted file mode 100644
index 3596890..0000000
--- a/sample-markdown-folder/folder/Untitled Folder (1)/Untitled Folder/Happy thanksgiving!.md
+++ /dev/null
@@ -1 +0,0 @@
-**Hey** _there_! Happy thanksgiving! :D
\ No newline at end of file
diff --git a/sample-markdown-folder/folder/Untitled Folder (1)/Untitled Folder/Untitled Folder/Tes.md b/sample-markdown-folder/folder/Untitled Folder (1)/Untitled Folder/Untitled Folder/Tes.md
deleted file mode 100644
index e69de29..0000000
diff --git a/sample-markdown-folder/folder/Untitled Folder (1)/Untitled Folder/Untitled Folder/Test.md b/sample-markdown-folder/folder/Untitled Folder (1)/Untitled Folder/Untitled Folder/Test.md
deleted file mode 100644
index 4b7f922..0000000
--- a/sample-markdown-folder/folder/Untitled Folder (1)/Untitled Folder/Untitled Folder/Test.md
+++ /dev/null
@@ -1 +0,0 @@
-This is a test, who can guess how it works
\ No newline at end of file
diff --git a/sample-markdown-folder/folder/Untitled Folder (1)/Untitled Folder/Untitled Folder/We'll see you at Christmas!.md b/sample-markdown-folder/folder/Untitled Folder (1)/Untitled Folder/Untitled Folder/We'll see you at Christmas!.md
deleted file mode 100644
index 4cbaf6f..0000000
--- a/sample-markdown-folder/folder/Untitled Folder (1)/Untitled Folder/Untitled Folder/We'll see you at Christmas!.md
+++ /dev/null
@@ -1 +0,0 @@
-❤️
diff --git a/sample-markdown-folder/folder/Untitled Folder (1)/Untitled Folder/Untitled this is a test.md b/sample-markdown-folder/folder/Untitled Folder (1)/Untitled Folder/Untitled this is a test.md
deleted file mode 100644
index e69de29..0000000
diff --git a/sample-markdown-folder/folder/subfolder/test55.md b/sample-markdown-folder/folder/subfolder/test55.md
deleted file mode 100644
index 9489fdd..0000000
--- a/sample-markdown-folder/folder/subfolder/test55.md
+++ /dev/null
@@ -1,3 +0,0 @@
-hello this is a test
-
-# test 4
\ No newline at end of file
diff --git "a/sample-markdown-folder/folder/subfolder/thi si a test TESt \342\234\205 \360\237\247\220.md" "b/sample-markdown-folder/folder/subfolder/thi si a test TESt \342\234\205 \360\237\247\220.md"
deleted file mode 100644
index 721d7ab..0000000
--- "a/sample-markdown-folder/folder/subfolder/thi si a test TESt \342\234\205 \360\237\247\220.md"
+++ /dev/null
@@ -1,3 +0,0 @@
-this is a link
-
-[test55.md](./test55.md)
\ No newline at end of file
diff --git a/sample-markdown-folder/folder/Interesting.md b/sample-markdown-folder/sample folder for notes 2/Interesting1234568915.md
similarity index 100%
rename from sample-markdown-folder/folder/Interesting.md
rename to sample-markdown-folder/sample folder for notes 2/Interesting1234568915.md
diff --git a/sample-markdown-folder/folder/wait renaming works cool.md b/sample-markdown-folder/sample folder for notes 2/wait renaming works cool.md
similarity index 100%
rename from sample-markdown-folder/folder/wait renaming works cool.md
rename to sample-markdown-folder/sample folder for notes 2/wait renaming works cool.md
diff --git a/sample-markdown-folder/test11/new-folder10/new file.md b/sample-markdown-folder/test11/new-folder10/new file.md
deleted file mode 100644
index e69de29..0000000
diff --git a/sample-markdown-folder/test11/test this is a test.md b/sample-markdown-folder/test11/test this is a test.md
deleted file mode 100644
index 9944a9f..0000000
--- a/sample-markdown-folder/test11/test this is a test.md
+++ /dev/null
@@ -1 +0,0 @@
-This is a test file
\ No newline at end of file
diff --git "a/sample-markdown-folder/\342\234\205 Todo list.md" "b/sample-markdown-folder/\342\234\205 Todo list.md"
index c4ce226..b4c047d 100644
--- "a/sample-markdown-folder/\342\234\205 Todo list.md"
+++ "b/sample-markdown-folder/\342\234\205 Todo list.md"
@@ -66,23 +66,27 @@
* Rename files issue causing duplicate selected files ✅
-* Renaming a folder does not update the folder directory when in a note within the folder
-
* Folder view should not have a Editor view, or the Editor view should be functional to rename a folder ✅
-* Easier way to go from title to text. Maybe enter should go to text, or tab.
+* Easier way to go from title to text. Maybe enter should go to text, or tab. ✅
+
+* Deleting files should automatically update the folder view ✅
+
+* Renaming files in tree view should update the folder view ✅
-* Deleting files should automatically update the folder view
+* Renaming a folder does not update the folder directory when in a note within the folder ✅
-* Renaming files should not be supported in the file tree viewer, or should but currently isn't working
+* Deleting an empty top level folder caused an error ✅
-* **Add new folder/new file to tree viewer**
+* Renaming files should not be supported in the file tree viewer, or should but currently isn't working ✅
+
+* Add new folder/new file to tree viewer ✅
* Make it so that you can start editing and save later (maybe make it a zip on unsupported devices)
* Make it mobile UI responsive
-* Make the UI have resizable side bar
+* Have the UI have top level folders as sections
### P1
@@ -93,20 +97,17 @@
* Autocomplete with Bring your own OpenAI key (or Ollama integration)
+* Export to website (static site generation)
+
* add support to add links within the project ⏸️
* hide folder create/delete until hover of item ⏸️
* add lots of CSS transitions ⏸️
+* Make the UI have resizable side bar
+
### P2
-* Add electron app for desktop, no notifications, and support for browsers that don't work
-
-* ❌ styling for mobile
-
- * local file system doesn't even work on mobile...
-
-
-### P3+
\ No newline at end of file
+* Add electron app for desktop, no notifications, and support for browsers that don't work
\ No newline at end of file
diff --git a/src/components/FileSystemAdapters/FileSystem/Folder.tsx b/src/components/FileSystemAdapters/FileSystem/FileSystemItem.tsx
similarity index 86%
rename from src/components/FileSystemAdapters/FileSystem/Folder.tsx
rename to src/components/FileSystemAdapters/FileSystem/FileSystemItem.tsx
index cfe193c..0c62811 100644
--- a/src/components/FileSystemAdapters/FileSystem/Folder.tsx
+++ b/src/components/FileSystemAdapters/FileSystem/FileSystemItem.tsx
@@ -4,7 +4,7 @@ import { ChevronDown, ChevronRight, FilePlus, FolderPlus } from "lucide-react";
import RightClickMenu from "./RightClickMenu";
import * as ContextMenu from "@radix-ui/react-context-menu";
-export function Folder({
+export function FileSystemItem({
node,
depth,
handleFileSelect,
@@ -12,7 +12,8 @@ export function Folder({
handleDeleteFile,
handleCreateFile,
handleCreateFolder,
- handleRenameFolder
+ handleRenameFolder,
+ handleRenameFile,
}: {
node: DirectoryNode;
depth: number;
@@ -22,6 +23,7 @@ export function Folder({
handleCreateFile: (node: DirectoryNode) => void;
handleCreateFolder: (node: DirectoryNode) => void;
handleRenameFolder: (node: DirectoryNode) => void;
+ handleRenameFile: (node: DirectoryNode) => void;
}) {
const [expanded, setExpanded] = useState(depth === 0);
@@ -106,7 +108,7 @@ export function Folder({
)}
>
) : (
- // Recursively render directory
)}
handleCreateFile(child)
+ : undefined
+ }
+ onCreateFolder={
+ child.isDirectory()
+ ? () => handleCreateFolder(child)
+ : undefined
+ }
onDelete={() => handleDeleteFile(child)}
- onRename={() => handleRenameFolder(child)}
+ onRename={
+ child.isDirectory() ?
+ () => handleRenameFolder(child) :
+ () => handleRenameFile(child)
+ }
/>
diff --git a/src/components/FileSystemAdapters/FileSystem/LocalFileSystem.tsx b/src/components/FileSystemAdapters/FileSystem/LocalFileSystem.tsx
index 57625b8..925f1c0 100644
--- a/src/components/FileSystemAdapters/FileSystem/LocalFileSystem.tsx
+++ b/src/components/FileSystemAdapters/FileSystem/LocalFileSystem.tsx
@@ -6,12 +6,12 @@ import { useEffect } from "react";
import DirectoryNode, {
createDirectoryNode,
} from "../../../models/DirectoryNode";
-import { Folder } from "./Folder";
+import { FileSystemItem } from "./FileSystemItem";
import { FilePlus, FolderPlus } from "lucide-react";
//sample react function
export const LocalFileSystem = ({
- selectedDirectory,
+ selectedDirectory, //rootDirectory
setSelectedDirectory,
selectedFile,
setSelectedFile,
@@ -37,17 +37,6 @@ export const LocalFileSystem = ({
fetchEntries();
}, [selectedDirectory]);
- // const handleDirectorySelect = async () => {
- // try {
- // const directoryHandle = await (window as any).showDirectoryPicker();
- // setSelectedDirectory(
- // await createDirectoryNode(directoryHandle, undefined)
- // );
- // } catch (error) {
- // console.error("Error selecting directory:", error);
- // }
- // };
-
const getDirectoryRecursive = async (
directoryHandle: FileSystemDirectoryHandle
) => {
@@ -65,8 +54,21 @@ export const LocalFileSystem = ({
const handleDeleteFile = async (node: DirectoryNode) => {
console.log("deleting file");
- const parent = await node.delete();
- setSelectedFile(getClosestParentsFirstFile(parent)); // TODO: set to root directory
+ await node.delete();
+
+ //determine if the selected file still exists, if it does, set the selected file to it (leave as is), otherwise set it to null
+ if(selectedFile){
+ const selectedFileAsFoundInCurrentDirectory =
+ selectedDirectory?.findChildByPath(selectedFile?.getFullPath());
+ if(selectedFileAsFoundInCurrentDirectory){
+ setSelectedFile(selectedFileAsFoundInCurrentDirectory.getCopy() || null);
+ } else {
+ setSelectedFile(null);
+ }
+ }
+ else{
+ setSelectedFile(null);
+ }
};
const createFileHandlingDuplicates = async (parent: DirectoryNode) => {
@@ -134,7 +136,15 @@ export const LocalFileSystem = ({
const newName = prompt("Enter new name for folder", node.name);
if (newName) {
await node.renameFolder(newName);
- setSelectedFile(getClosestParentsFirstFile(node));
+ setSelectedFile(selectedFile?.getCopy() || null);
+ }
+ }
+
+ const handleRenameFile = async (node: DirectoryNode) => {
+ const newName = prompt("Enter new name for file", node.getName() || node.name);
+ if (newName) {
+ await node.renameFile(newName);
+ setSelectedFile(selectedFile?.getCopy() || null);
}
}
@@ -193,7 +203,7 @@ export const LocalFileSystem = ({