Skip to content

Commit

Permalink
Go to the folder note when a folder is selected
Browse files Browse the repository at this point in the history
  • Loading branch information
pjeby committed Aug 31, 2021
1 parent 51d8829 commit 3d91522
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 15 deletions.
12 changes: 8 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,15 @@

[Obsidian](https://obsidian.md)'s in-app file explorer is pretty flexible, but it's almost 100% mouse-driven and not at all keyboard-friendly. Worse, if you have a lot of folders with lots of files in them, you can spend a lot of time expanding and collapsing folders, and scrolling around to find what you're looking for. This can be especially annoying when all you want is to do something with the "current" folder, or a parent of it... *without* needing to open a sidebar and close it again afterwards. (And last, but not least, trying to rapidly preview the contents of a lot of notes with the mouse is a giant PITA.)

Enter Quick Explorer. It's menu-based and keyboard-friendly, stays out of your way when you aren't using it, and makes it super-easy to navigate from either the vault root or current folder, without needing to scroll through or collapse a zillion other folders to find what you're looking for. You can even search by name within a folder, just by typing. There's an auto-preview feature that makes previewing lots of notes super easy, with no mousing and no popups overhanging the file list. And you can even see the path of the current file as a "breadcrumbs bar" in the window title bar!
Enter Quick Explorer. It's menu-based and **keyboard-friendly**, stays out of your way when you aren't using it, and makes it super-easy to navigate from either the vault root or current folder, without needing to scroll through or collapse a zillion other folders to find what you're looking for. You can even **search by name within a folder**, just by typing.

Each breadcrumb, when clicked, drops down a list of the the files and folders in the same directory. So if you click on the breadcrumb for the current file, you'll see the items in its folder, and the first breadcrumb will show items in the vault root. No matter where you click, though, you can then do almost anything that can be done with Obsidian's built-in file explorer:
But wait, there's more: a **quick-preview mode** that makes previewing lots of notes super easy, with no mousing and no popups overhanging the file list: you can just keep hitting the PgDn key to page through the contents of all the notes in a folder.

**Folder notes** are supported, too: previewing a folder shows the folder note without you first needing to navigate into the folder and find the note, and when you navigate into the folder its folder note is automatically selected, if present. (A "folder note" is a note whose name is the same as the name of its enclosing folder: other Obsidian plugins such as [Note Folder Autorename](https://github.com/pjeby/note-folder-autorename) can be used to help create or maintain them.)

And last, but far from least, you can even see the path of the current file as a "breadcrumbs bar" in the window title bar. Each breadcrumb, when clicked, drops down a list of the the files and folders in the same directory. So if you click on the breadcrumb for the current file, you'll see the items in its folder, and the first breadcrumb will show items in the vault root.

No matter where you click, though, you can then do almost anything that can be done with Obsidian's built-in file explorer:

* Ctrl/Cmd + Hover to preview files (if the built-in Page Preview plugin is enabled)
* Click to open files (with ctrl or cmd to open in a new pane)
Expand All @@ -22,8 +28,6 @@ And an extensive set of keyboard operations is available as well:
* Tab toggles "quick preview" mode: when active, hovering or arrowing to an item will automatically display a hover preview for it, positioned so that it's always *outside* the menu (unless you're so deep in subfolders you've reached the edge of your screen). This makes it really easy to browse the contents of a folder just by arrowing down through it.
* If a page preview is active for the current file or folder, PageUp and PageDown scroll it up and down, with Ctrl-or-Cmd + Home or End jump to the beginning or end of the note. Scrolling past the end or before the beginning (or using any of these keys without an active preview) advances the selection to the next or previous file/folder in the list.

And speaking of previews, Quick Explorer's previews support **folder notes**! When hover-previewing a folder (or after arrowing to it in quick preview mode), it's checked for a note whose name is the same as the folder, and then that note is shown without you needing to open the folder first. It's a huge time saver if you have a lot of folder notes. (Check out the Note Folder Autorename plugin if you'd like to automatically rename or move folders when the note is renamed, too.)

Like the built-in file explorer, Quick Explorer will either show all files, or only the ones supported by Obsidian, depending upon whether "Detect all file extensions" is enabled in the "Files and Links" options tab.

Quick explorer also includes two hotkeyable commands:
Expand Down
15 changes: 10 additions & 5 deletions main.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "quick-explorer",
"name": "Quick Explorer",
"version": "0.0.9",
"version": "0.0.10",
"description": "Perform file explorer operations (and see your current file path) from the title bar",
"minAppVersion": "0.12.12",
"isDesktopOnly": true
Expand Down
14 changes: 10 additions & 4 deletions src/FolderMenu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -260,14 +260,20 @@ export class FolderMenu extends PopupMenu {
maybeHover(targetEl: HTMLDivElement, cb: (file: TFile) => void) {
if (!this.canShowPopover()) return;
let file = this.fileForDom(targetEl)
if (file instanceof TFolder) {
file = this.app.vault.getAbstractFileByPath(file.path+"/"+file.name+".md");
}
if (file instanceof TFolder) file = this.folderNote(file);
if (file instanceof TFile && previewIcons[this.app.viewRegistry.getTypeByExtension(file.extension)]) {
cb(file)
};
}

folderNote(folder: TFolder) {
return this.app.vault.getAbstractFileByPath(this.folderNotePath(folder));
}

folderNotePath(folder: TFolder) {
return `${folder.path}/${folder.name}.md`;
}


_popover: HoverParent["hoverPopover"];

Expand Down Expand Up @@ -336,7 +342,7 @@ export class FolderMenu extends PopupMenu {
this.openBreadcrumb(this.opener?.nextElementSibling);
} else {
// Otherwise, pop a new menu for the subfolder
const folderMenu = new FolderMenu(this, file as TFolder, this.folder);
const folderMenu = new FolderMenu(this, file as TFolder, this.folderNote(file as TFolder) || this.folder);
folderMenu.cascade(target, event instanceof MouseEvent ? event : undefined);
}
}
Expand Down
2 changes: 1 addition & 1 deletion versions.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"0.0.9": "0.12.12",
"0.0.10": "0.12.12",
"0.0.5": "0.12.10",
"0.0.1": "0.12.3"
}

0 comments on commit 3d91522

Please sign in to comment.