Option to disable the sidebar on desktop

Added a setting to also disable the sidebar from automatically opening when you click on a folder name in the path on desktop
This commit is contained in:
Lost Paul 2024-06-01 16:18:45 +02:00
parent 65503affd0
commit c72697b81b
3 changed files with 24 additions and 6 deletions

View file

@ -28,9 +28,9 @@ export async function handleViewHeaderClick(event: MouseEvent, plugin: FolderNot
await openFolderNote(plugin, folderNote, event).then(async () => {
// @ts-ignore
const fileExplorerPlugin = plugin.app.internalPlugins.getEnabledPluginById('file-explorer');
if (fileExplorerPlugin && Platform.isMobile && plugin.settings.openSidebarWhenClickingOnPath) {
if (fileExplorerPlugin && Platform.isMobile && plugin.settings.openSidebar.mobile) {
setTimeout(() => { fileExplorerPlugin.revealInFolder(folderNote); }, 200);
} else if (fileExplorerPlugin) {
} else if (fileExplorerPlugin && Platform.isDesktop && plugin.settings.openSidebar.desktop) {
fileExplorerPlugin.revealInFolder(folderNote);
}
});

View file

@ -20,9 +20,21 @@ export async function renderPath(settingsTab: SettingsTab) {
.setDesc('Open the sidebar when opening a folder note through the path on mobile')
.addToggle((toggle) =>
toggle
.setValue(settingsTab.plugin.settings.openSidebarWhenClickingOnPath)
.setValue(settingsTab.plugin.settings.openSidebar.mobile)
.onChange(async (value) => {
settingsTab.plugin.settings.openSidebarWhenClickingOnPath = value;
settingsTab.plugin.settings.openSidebar.mobile = value;
await settingsTab.plugin.saveSettings();
})
);
new Setting(containerEl)
.setName('Open sidebar when opening a folder note through path (Desktop only)')
.setDesc('Open the sidebar when opening a folder note through the path on desktop')
.addToggle((toggle) =>
toggle
.setValue(settingsTab.plugin.settings.openSidebar.desktop)
.onChange(async (value) => {
settingsTab.plugin.settings.openSidebar.desktop = value;
await settingsTab.plugin.saveSettings();
})
);

View file

@ -59,7 +59,10 @@ export interface FolderNotesSettings {
hideCollapsingIcon: boolean;
ignoreAttachmentFolder: boolean;
tabManagerEnabled: boolean;
openSidebarWhenClickingOnPath: boolean;
openSidebar: {
mobile: boolean;
desktop: boolean;
}
}
export const DEFAULT_SETTINGS: FolderNotesSettings = {
@ -150,7 +153,10 @@ export const DEFAULT_SETTINGS: FolderNotesSettings = {
hideCollapsingIcon: false,
tabManagerEnabled: true,
ignoreAttachmentFolder: true,
openSidebarWhenClickingOnPath: false,
openSidebar: {
mobile: false,
desktop: true,
}
};
export class SettingsTab extends PluginSettingTab {