mirror of
https://github.com/lostpaul/obsidian-folder-notes.git
synced 2026-07-22 07:40:24 +00:00
Allow users to open folder notes in a new tab with ctrl
This commit is contained in:
parent
08c1218a40
commit
38a5fdfe89
2 changed files with 6 additions and 7 deletions
|
|
@ -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);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Reference in a new issue