Skip to content

Commit

Permalink
Support Hover Editors in editing mode and autofocus
Browse files Browse the repository at this point in the history
* Allow paging up/down through edit-mode hovers
* Don't reset explore target when hovers autofocus
  • Loading branch information
pjeby committed Apr 9, 2022
1 parent 3410661 commit 59c3412
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 9 deletions.
16 changes: 12 additions & 4 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.1.18",
"version": "0.1.19",
"description": "Perform file explorer operations (and see your current file path) from the title bar, using the mouse or keyboard",
"minAppVersion": "0.13.23",
"isDesktopOnly": true
Expand Down
10 changes: 8 additions & 2 deletions src/Explorer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export class Explorer extends Component {
lastPath: string = null;
el: HTMLElement = <div id="quick-explorer" />;
list = list(this.el, Explorable);
isOpen = 0

constructor(public app: App) {
super()
Expand Down Expand Up @@ -76,7 +77,11 @@ export class Explorer extends Component {
const { filePath, parentPath } = opener.dataset
const selected = this.app.vault.getAbstractFileByPath(filePath);
const folder = this.app.vault.getAbstractFileByPath(parentPath) as TFolder;
return new FolderMenu(this.app, folder, selected, opener).cascade(opener, event);
this.isOpen++;
return new FolderMenu(this.app, folder, selected, opener).cascade(opener, event, () => {
this.isOpen--;
if (!this.isOpen) this.update(this.app.workspace.getActiveFile());
});
}

browseVault() {
Expand All @@ -88,7 +93,7 @@ export class Explorer extends Component {
}

browseFile(file: TAbstractFile) {
if (file === this.app.workspace.getActiveFile()) return this.browseCurrent();
if (file === this.lastFile) return this.browseCurrent();
let menu: FolderMenu;
let opener: HTMLElement = this.el.firstElementChild as HTMLElement;
const path = [], parts = file.path.split("/").filter(p=>p);
Expand Down Expand Up @@ -116,6 +121,7 @@ export class Explorer extends Component {
}

update(file?: TAbstractFile) {
if (this.isOpen) return;
file ??= this.app.vault.getAbstractFileByPath("/");
if (file == this.lastFile && file.path == this.lastPath) return;
this.lastFile = file;
Expand Down
2 changes: 1 addition & 1 deletion src/FolderMenu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ export class FolderMenu extends PopupMenu implements HoverParent {
}

doScroll(direction: number, toEnd: boolean, event: KeyboardEvent) {
const preview = this.hoverPopover?.hoverEl.find(".markdown-preview-view");
const preview = this.hoverPopover?.hoverEl.find(".markdown-preview-view, .cm-scroller");
if (preview) {
preview.style.scrollBehavior = toEnd ? "auto": "smooth";
const oldTop = preview.scrollTop;
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.1.18": "0.13.23",
"0.1.19": "0.13.23",
"0.1.9": "0.12.12",
"0.0.5": "0.12.10",
"0.0.1": "0.12.3"
Expand Down

0 comments on commit 59c3412

Please sign in to comment.