mirror of
https://github.com/lostpaul/obsidian-folder-notes.git
synced 2026-07-22 07:40:24 +00:00
parent
a050c2673c
commit
04e611fb97
1 changed files with 18 additions and 0 deletions
|
|
@ -13,6 +13,7 @@ export async function addObserver(plugin: FolderNotesPlugin) {
|
|||
.forEach(async (element: HTMLElement) => {
|
||||
let folderTitle = element.querySelector('div.nav-folder-title-content') as HTMLElement;
|
||||
const filePath = folderTitle.parentElement?.getAttribute('data-path') || '';
|
||||
applyFMTPStyles(plugin, filePath, folderTitle);
|
||||
|
||||
applyCSSClassesToFolder(filePath, plugin);
|
||||
|
||||
|
|
@ -22,6 +23,10 @@ export async function addObserver(plugin: FolderNotesPlugin) {
|
|||
|
||||
const observer = new MutationObserver(async (mutations, obs) => {
|
||||
folderTitle = element.querySelector('div.nav-folder-title-content') as HTMLElement;
|
||||
|
||||
const filePath = folderTitle.parentElement?.getAttribute('data-path') || '';
|
||||
applyFMTPStyles(plugin, filePath, folderTitle);
|
||||
|
||||
if (folderTitle) {
|
||||
await initializeFolderTitle(folderTitle, plugin);
|
||||
obs.disconnect();
|
||||
|
|
@ -77,6 +82,19 @@ export async function addObserver(plugin: FolderNotesPlugin) {
|
|||
});
|
||||
}
|
||||
|
||||
function applyFMTPStyles(plugin: FolderNotesPlugin, filePath: string, folderTitle: HTMLElement) {
|
||||
if (!plugin.settings.frontMatterTitle.enabled) { return; }
|
||||
|
||||
const folder = plugin.fmtpHandler?.modifiedFolders.get(filePath);
|
||||
if (folder && plugin.settings.frontMatterTitle.path) {
|
||||
folderTitle.setAttribute('old-name', folder.name || '');
|
||||
folderTitle.innerText = folder.newName || '';
|
||||
} else {
|
||||
folderTitle.removeAttribute('old-name');
|
||||
folderTitle.innerText = folderTitle.innerText.trim();
|
||||
}
|
||||
}
|
||||
|
||||
async function initializeFolderTitle(folderTitle: HTMLElement, plugin: any) {
|
||||
if (folderTitle.onclick) return;
|
||||
if (Platform.isMobile && plugin.settings.disableOpenFolderNoteOnClick) return;
|
||||
|
|
|
|||
Loading…
Reference in a new issue