diff --git a/src/commands.ts b/src/commands.ts index 52d6415..c28c4f4 100644 --- a/src/commands.ts +++ b/src/commands.ts @@ -39,7 +39,7 @@ export class Commands { item.setTitle('Delete folder note') .setIcon('trash') .onClick(() => { - file = this.plugin.app.vault.getAbstractFileByPath(file?.path + '/' + file?.name + '.md') as TFile; + file = this.plugin.app.vault.getAbstractFileByPath(file.path + '/' + file.name + '.md') ?? file; if (!(file instanceof TFile)) return; this.plugin.deleteFolderNote(file); }); @@ -49,7 +49,7 @@ export class Commands { item.setTitle('Create folder note') .setIcon('edit') .onClick(() => { - this.plugin.createFolderNote(file.path + '/' + file.name + '.md' , true); + this.plugin.createFolderNote(file.path + '/' + file.name + '.md', true); }); }); } diff --git a/src/main.ts b/src/main.ts index bca59a7..c86ad79 100644 --- a/src/main.ts +++ b/src/main.ts @@ -138,7 +138,7 @@ export default class FolderNotesPlugin extends Plugin { const path = folder + '/' + event.target.innerText + '.md'; if (this.app.vault.getAbstractFileByPath(path)) { - return this.openFolderNote(path); + return this.openFolderNote(path, event); } else if (event.altKey || Keymap.isModEvent(event) === 'tab') { if ((this.settings.altKey && event.altKey) || (this.settings.ctrlKey && Keymap.isModEvent(event) === 'tab')) { await this.createFolderNote(path, true, true); @@ -155,7 +155,6 @@ export default class FolderNotesPlugin extends Plugin { if (!(event.target instanceof HTMLElement)) return; if (!this.settings.openFolderNoteOnClickInPath) return; const folder = event.target.getAttribute('data-path'); - console.log(folder); if (!folder) { return; } const excludedFolder = this.getExcludedFolderByPath(folder); if (excludedFolder?.disableFolderNote) { @@ -169,7 +168,7 @@ export default class FolderNotesPlugin extends Plugin { const path = folder + '/' + event.target.innerText + '.md'; if (this.app.vault.getAbstractFileByPath(path)) { - return this.openFolderNote(path); + return this.openFolderNote(path, event); } else if (event.altKey || Keymap.isModEvent(event) === 'tab') { if ((this.settings.altKey && event.altKey) || (this.settings.ctrlKey && Keymap.isModEvent(event) === 'tab')) { await this.createFolderNote(path, true, true); @@ -293,8 +292,8 @@ export default class FolderNotesPlugin extends Plugin { this.addCSSClassToTitleEL(path, 'is-folder-note', true); } - async openFolderNote(path: string) { - const leaf = this.app.workspace.getLeaf(false); + async openFolderNote(path: string, evt: MouseEvent) { + const leaf = this.app.workspace.getLeaf(Keymap.isModEvent(evt)); const file = this.app.vault.getAbstractFileByPath(path); if (file instanceof TFile) { await leaf.openFile(file);