Skip to content

Commit

Permalink
fix: allow block and heading in popover openmode
Browse files Browse the repository at this point in the history
close #137
  • Loading branch information
Vinzent03 committed Jul 30, 2023
1 parent 44fbff4 commit 40227a3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
2 changes: 0 additions & 2 deletions src/handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,6 @@ export default class Handlers {
file: parameters.filepath + "#" + parameters.heading,
setting: this.plugin.settings.openFileWithoutWriteInNewPane,
parameters: parameters,
supportPopover: false,
});
const view = app.workspace.getActiveViewOfType(MarkdownView);
if (!view) return;
Expand All @@ -354,7 +353,6 @@ export default class Handlers {
file: parameters.filepath + "#^" + parameters.block,
setting: this.plugin.settings.openFileWithoutWriteInNewPane,
parameters: parameters,
supportPopover: false,
});
const view = app.workspace.getActiveViewOfType(MarkdownView);
if (!view) return;
Expand Down
17 changes: 12 additions & 5 deletions src/main.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {
base64ToArrayBuffer,
getLinkpath,
MarkdownView,
normalizePath,
Notice,
Expand Down Expand Up @@ -500,11 +501,17 @@ export default class AdvancedURI extends Plugin {
const leaf = hoverEditor.spawnPopover(undefined, () => {
this.app.workspace.setActiveLeaf(leaf, { focus: true });
});
const tfile =
file instanceof TFile
? file
: (this.app.vault.getAbstractFileByPath(file) as TFile);
leaf.openFile(tfile);

let tFile: TFile;
if (file instanceof TFile) {
tFile = file;
} else {
tFile = this.app.vault.getAbstractFileByPath(
getLinkpath(file)
) as TFile;
}

await leaf.openFile(tFile);
} else {
let openMode: OpenMode | boolean = setting;
if (parameters.newpane !== undefined) {
Expand Down

0 comments on commit 40227a3

Please sign in to comment.