feature: create folder/file in root context menu
mellbacon committed
Aug 2, 2023 at 11:30 UTC
c2a91bf842face8958ccb9421acf949af0b9d8b4
1 file changed
+13
-2
src/lib/FileTree.svelte
+13
-2
@@ -2,8 +2,9 @@
2
import FileTreeView from "./FileTree/FileTreeView.svelte";
3
import ContextMenu from "./utility/ContextMenu.svelte";
4
import { addEditorTab } from "./EditorTabList.svelte";
5
- import { openFolder, openInExplorer } from "./File";
6
- import { clipboard } from "@tauri-apps/api";
5
+ import { openFolder, openInExplorer, createFile, createFolder } from "./File";
6
+ import { clipboard, path as p } from "@tauri-apps/api";
7
+ import { openInputModal } from "../App.svelte";
8
9
let treeDom;
10
let contextmenu = false;
@@ -26,6 +27,16 @@
27
28
let contextmenuitems = [
29
{name: "Open in File Explorer", shortcut: "", action: async () => {await openInExplorer(path)}},
30
+ {name: "New Folder...", shortcut: "", action: () => {openInputModal("Create New Folder",
31
+ `Create a new folder in ${path}`, [
32
+ {name: "Create Folder", action: async (name) => { await createFolder(`${path}${p.sep}${name}`)}},
33
+ {name: "Cancel", action: () => {}}
34
+ ], {label: "Folder Name"})}},
35
+ {name: "New File...", shortcut: "", action: () => {openInputModal("Create New File",
36
+ `Create a new file in ${path}`, [
37
+ {name: "Create File", action: (name) => {createFile(`${path}${p.sep}${name}`)}},
38
+ {name: "Cancel", action: () => {}}
39
+ ], {label: "File Name"})}},
40
{name: "Copy", shortcut: "Ctrl + C", action: () => {console.warn("Feature not implemented yet.")}},
41
{name: "Cut", disabled: true, shortcut: "Ctrl + X", action: () => {console.warn("Feature not implemented yet.")}},
42
{name: "Paste", shortcut: "Ctrl + X", disabled: true, action: () => {console.warn("Feature not implemented yet.")}},