mirror of
https://github.com/lostpaul/obsidian-folder-notes.git
synced 2026-07-22 07:40:24 +00:00
MacOS cmd + click support
This commit is contained in:
parent
08ece2293c
commit
ece9b16014
3 changed files with 20 additions and 16 deletions
|
|
@ -1,4 +1,4 @@
|
|||
import { Plugin, TFile, TFolder, TAbstractFile, Notice } from 'obsidian';
|
||||
import { Plugin, TFile, TFolder, TAbstractFile, Notice, Keymap } from 'obsidian';
|
||||
import { DEFAULT_SETTINGS, FolderNotesSettings, SettingsTab } from './settings';
|
||||
import FolderNameModal from './modals/folderName';
|
||||
import { applyTemplate } from './template';
|
||||
|
|
@ -175,7 +175,6 @@ export default class FolderNotesPlugin extends Plugin {
|
|||
event.target.click();
|
||||
}
|
||||
const path = folder + '/' + event.target.innerText + '.md';
|
||||
|
||||
if (this.app.vault.getAbstractFileByPath(path)) {
|
||||
event.target.classList.remove('has-not-folder-note');
|
||||
event.target.classList.add('has-folder-note');
|
||||
|
|
@ -189,9 +188,11 @@ export default class FolderNotesPlugin extends Plugin {
|
|||
}
|
||||
});
|
||||
|
||||
} else if (event.altKey || event.ctrlKey) {
|
||||
if ((this.settings.altKey && event.altKey) || (this.settings.ctrlKey && event.ctrlKey)) {
|
||||
} else if (event.altKey || Keymap.isModEvent(event) == 'tab') {
|
||||
if ((this.settings.altKey && event.altKey) || (this.settings.ctrlKey && Keymap.isModEvent(event) == 'tab')) {
|
||||
this.createFolderNote(path, true, true);
|
||||
event.target.classList.remove('has-not-folder-note');
|
||||
event.target.classList.add('has-folder-note');
|
||||
if (!this.settings.hideFolderNote) return;
|
||||
event.target.parentElement?.parentElement?.getElementsByClassName('nav-folder-children').item(0)?.querySelectorAll('div.nav-file')
|
||||
.forEach((element: HTMLElement) => {
|
||||
|
|
|
|||
|
|
@ -120,16 +120,19 @@ export class SettingsTab extends PluginSettingTab {
|
|||
.setName('Key for creating folder note')
|
||||
.setDesc('The key combination to create a folder note')
|
||||
.addDropdown((dropdown) => {
|
||||
dropdown
|
||||
.addOption('ctrl', 'Ctrl + Click')
|
||||
.addOption('alt', 'Alt + Click')
|
||||
.setValue(this.plugin.settings.ctrlKey ? 'ctrl' : 'alt')
|
||||
.onChange(async (value) => {
|
||||
this.plugin.settings.ctrlKey = value === 'ctrl';
|
||||
this.plugin.settings.altKey = value === 'alt';
|
||||
await this.plugin.saveSettings();
|
||||
this.display();
|
||||
});
|
||||
if(!Platform.isMacOS) {
|
||||
dropdown.addOption('ctrl', 'Ctrl + Click')
|
||||
} else {
|
||||
dropdown.addOption('ctrl', 'Cmd + Click')
|
||||
}
|
||||
dropdown.addOption('alt', 'Alt + Click')
|
||||
dropdown.setValue(this.plugin.settings.ctrlKey ? 'ctrl' : 'alt')
|
||||
dropdown.onChange(async (value) => {
|
||||
this.plugin.settings.ctrlKey = value === 'ctrl';
|
||||
this.plugin.settings.altKey = value === 'alt';
|
||||
await this.plugin.saveSettings();
|
||||
this.display();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
.fn-whitespace-collapsing .nav-folder-title-content.has-folder-note {
|
||||
.fn-whitespace-collapsing .nav-folder-title-content {
|
||||
flex-grow: 1;
|
||||
padding-bottom: 4px;
|
||||
padding-top: 4px;
|
||||
|
|
@ -11,7 +11,7 @@
|
|||
text-underline-offset: 1px;
|
||||
}
|
||||
|
||||
.fn-whitespace-collapsing .nav-folder-title:has(.has-folder-note) {
|
||||
.fn-whitespace-collapsing .nav-folder-title {
|
||||
padding-bottom: 0;
|
||||
padding-top: 0;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue