mirror of
https://github.com/lostpaul/obsidian-folder-notes.git
synced 2026-07-22 07:40:24 +00:00
Command to create a folder note for every supported file types
This commit is contained in:
parent
666fb97133
commit
ebbc2e56dc
1 changed files with 31 additions and 4 deletions
|
|
@ -53,15 +53,31 @@ export class Commands {
|
|||
})
|
||||
this.plugin.addCommand({
|
||||
id: 'create-folder-note-for-current-folder',
|
||||
name: 'Create folder note for current folder of active note',
|
||||
name: 'Create markdown folder note for current folder of active note',
|
||||
callback: () => {
|
||||
const file = this.app.workspace.getActiveFile();
|
||||
if (!(file instanceof TFile)) return;
|
||||
const folder = file.parent;
|
||||
if (!(folder instanceof TFolder)) return;
|
||||
createFolderNote(this.plugin, folder.path, true, undefined, false);
|
||||
createFolderNote(this.plugin, folder.path, true, '.md', false);
|
||||
}
|
||||
});
|
||||
|
||||
this.plugin.settings.supportedFileTypes.forEach((fileType) => {
|
||||
if (fileType === 'md') return;
|
||||
this.plugin.addCommand({
|
||||
id: `create-${fileType}-folder-note-for-current-folder`,
|
||||
name: `Create ${fileType} folder note for current folder of active note`,
|
||||
callback: () => {
|
||||
const file = this.app.workspace.getActiveFile();
|
||||
if (!(file instanceof TFile)) return;
|
||||
const folder = file.parent;
|
||||
if (!(folder instanceof TFolder)) return;
|
||||
createFolderNote(this.plugin, folder.path, true, '.' + fileType, false);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
this.plugin.addCommand({
|
||||
id: 'delete-folder-note-for-current-folder',
|
||||
name: 'Delete folder note of current folder of active note',
|
||||
|
|
@ -291,12 +307,23 @@ export class Commands {
|
|||
});
|
||||
} else {
|
||||
subMenu.addItem((item) => {
|
||||
item.setTitle('Create folder note')
|
||||
item.setTitle('Create markdown folder note')
|
||||
.setIcon('edit')
|
||||
.onClick(() => {
|
||||
createFolderNote(this.plugin, file.path, true);
|
||||
createFolderNote(this.plugin, file.path, true, '.md');
|
||||
});
|
||||
});
|
||||
|
||||
this.plugin.settings.supportedFileTypes.forEach((fileType) => {
|
||||
if (fileType === 'md') return;
|
||||
subMenu.addItem((item) => {
|
||||
item.setTitle(`Create ${fileType} folder note`)
|
||||
.setIcon('edit')
|
||||
.onClick(() => {
|
||||
createFolderNote(this.plugin, file.path, true, '.' + fileType);
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
}));
|
||||
|
|
|
|||
Loading…
Reference in a new issue