diff --git a/src/functions/styleFunctions.ts b/src/functions/styleFunctions.ts index 9602b03..7211e55 100644 --- a/src/functions/styleFunctions.ts +++ b/src/functions/styleFunctions.ts @@ -1,8 +1,9 @@ import { TFile, TFolder } from 'obsidian'; import FolderNotesPlugin from '../main'; -import { getDetachedFolder, getExcludedFolder } from 'src/ExcludeFolders/functions/folderFunctions'; +import { getDetachedFolder, getExcludedFolder, addExcludedFolder } from 'src/ExcludeFolders/functions/folderFunctions'; import { getFolder, getFolderNote } from 'src/functions/folderNoteFunctions'; import { getFileExplorer } from './utils'; +import { ExcludedFolder } from 'src/ExcludeFolders/ExcludeFolder'; import FolderOverviewPlugin from 'src/obsidian-folder-overview/src/main'; export function updateAllFileStyles(forceReload = false, plugin: FolderNotesPlugin) { @@ -158,3 +159,25 @@ export function getEl(path: string, plugin: FolderNotesPlugin | FolderOverviewPl if (fileExplorerItem.selfEl) return fileExplorerItem.selfEl; return fileExplorerItem.titleEl; } + + +export function showFolderNoteInFileExplorer(path: string, plugin: FolderNotesPlugin) { + const excludedFolder = new ExcludedFolder(path, plugin.settings.excludeFolders.length, undefined, plugin); + excludedFolder.subFolders = false; + excludedFolder.disableSync = false; + excludedFolder.disableAutoCreate = false; + excludedFolder.disableFolderNote = false; + excludedFolder.enableCollapsing = false; + excludedFolder.excludeFromFolderOverview = false; + excludedFolder.hideInSettings = true; + excludedFolder.showFolderNote = true; + addExcludedFolder(plugin, excludedFolder, false); + applyCSSClassesToFolder(path, plugin); +} + +export function hideFolderNoteInFileExplorer(path: string, plugin: FolderNotesPlugin) { + plugin.settings.excludeFolders = plugin.settings.excludeFolders.filter( + (folder) => (folder.path !== path) && folder.showFolderNote); + plugin.saveSettings(false); + applyCSSClassesToFolder(path, plugin); +} diff --git a/src/main.ts b/src/main.ts index 363706b..0e0c851 100644 --- a/src/main.ts +++ b/src/main.ts @@ -152,6 +152,25 @@ export default class FolderNotesPlugin extends Plugin { this.tabManager = new TabManager(this); this.tabManager.updateTabs(); + const fileExplorerPlugin = this.app.internalPlugins.getEnabledPluginById('file-explorer'); + if (fileExplorerPlugin) { + const originalRevealInFolder = fileExplorerPlugin.revealInFolder.bind(fileExplorerPlugin); + fileExplorerPlugin.revealInFolder = (file: TAbstractFile) => { + if (file instanceof TFile) { + const folder = getFolder(this, file); + if (folder instanceof TFolder) { + document.body.classList.remove('hide-folder-note'); + originalRevealInFolder.call(fileExplorerPlugin, folder); + setTimeout(() => { + document.body.classList.add('hide-folder-note'); + }, 100); + return; + } + } + return originalRevealInFolder.call(fileExplorerPlugin, file); + }; + } + const leaf = this.app.workspace.getLeavesOfType('markdown').first(); const view = leaf?.view; diff --git a/src/obsidian-folder-overview b/src/obsidian-folder-overview index 2f09e34..331d3ae 160000 --- a/src/obsidian-folder-overview +++ b/src/obsidian-folder-overview @@ -1 +1 @@ -Subproject commit 2f09e3443140050e4f8653b43dddfcebeaea8309 +Subproject commit 331d3aea842fea661f8979a923b466ebed161379