mirror of
https://github.com/lostpaul/obsidian-folder-notes.git
synced 2026-07-22 07:40:24 +00:00
Fix #112
This commit is contained in:
parent
86d1abab49
commit
e7653658fc
3 changed files with 44 additions and 2 deletions
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
19
src/main.ts
19
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;
|
||||
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
Subproject commit 2f09e3443140050e4f8653b43dddfcebeaea8309
|
||||
Subproject commit 331d3aea842fea661f8979a923b466ebed161379
|
||||
Loading…
Reference in a new issue