mirror of
https://github.com/lostpaul/obsidian-folder-notes.git
synced 2026-07-22 07:40:24 +00:00
Fix # 275
This commit is contained in:
parent
68d9b0b8d5
commit
3e23140bfb
4 changed files with 32 additions and 15 deletions
30
src/main.ts
30
src/main.ts
|
|
@ -84,6 +84,9 @@ export default class FolderNotesPlugin extends Plugin {
|
|||
if (this.settings.hideCollapsingIcon) {
|
||||
document.body.classList.add('fn-hide-collapse-icon');
|
||||
}
|
||||
if (this.settings.ignoreAttachmentFolder) {
|
||||
document.body.classList.add('fn-ignore-attachment-folder');
|
||||
}
|
||||
if (!this.settings.highlightFolder) {
|
||||
document.body.classList.add('disable-folder-highlight');
|
||||
}
|
||||
|
|
@ -433,7 +436,7 @@ export default class FolderNotesPlugin extends Plugin {
|
|||
updateViewDropdown: typeof updateViewDropdown = updateViewDropdown;
|
||||
|
||||
isEmptyFolderNoteFolder(folder: TFolder): boolean {
|
||||
const attachmentFolderPath = this.app.vault.getConfig('attachmentFolderPath') as string;
|
||||
let attachmentFolderPath = this.app.vault.getConfig('attachmentFolderPath') as string;
|
||||
const cleanAttachmentFolderPath = attachmentFolderPath?.replace('./', '') || '';
|
||||
const attachmentsAreInRootFolder = attachmentFolderPath === './'
|
||||
|| attachmentFolderPath === '';
|
||||
|
|
@ -441,22 +444,27 @@ export default class FolderNotesPlugin extends Plugin {
|
|||
if (folder.children.length === 0) {
|
||||
addCSSClassToFileExplorerEl(folder.path, 'fn-empty-folder', false, this);
|
||||
}
|
||||
attachmentFolderPath = `${folder.path}/${cleanAttachmentFolderPath}`;
|
||||
|
||||
if (folder.children.length === threshold) {
|
||||
addCSSClassToFileExplorerEl(folder.path, 'fn-empty-folder', false, this);
|
||||
return true;
|
||||
} else if (folder.children.length > threshold) {
|
||||
if (attachmentsAreInRootFolder) {
|
||||
return false;
|
||||
} else if (this.settings.ignoreAttachmentFolder
|
||||
&& this.app.vault.getAbstractFileByPath(
|
||||
`${folder.path}/${cleanAttachmentFolderPath}`)) {
|
||||
const folderPath = `${folder.path}/${cleanAttachmentFolderPath}`;
|
||||
const attachmentFolder = this.app.vault.getAbstractFileByPath(folderPath);
|
||||
if (attachmentFolder instanceof TFolder
|
||||
&& folder.children.length <= threshold + 1) {
|
||||
if (!folder.collapsed) {
|
||||
getFileExplorerElement(folder.path, this)?.click();
|
||||
}
|
||||
} else if (
|
||||
this.app.vault.getAbstractFileByPath(attachmentFolderPath) instanceof TFolder
|
||||
) {
|
||||
const attachmentFolder = this.app.vault.getAbstractFileByPath(attachmentFolderPath);
|
||||
if (
|
||||
attachmentFolder instanceof TFolder &&
|
||||
folder.children.length <= threshold + 1
|
||||
) {
|
||||
addCSSClassToFileExplorerEl(folder.path, 'fn-empty-folder', false, this);
|
||||
addCSSClassToFileExplorerEl(
|
||||
folder.path, 'fn-has-attachment-folder',
|
||||
false, this,
|
||||
);
|
||||
}
|
||||
return folder.children.length <= threshold + 1;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
Subproject commit 37008ed555811b06e5e9c3547079368e0cce8113
|
||||
Subproject commit 69f6e80b248e6317ca3d9587f27891ce86f55c79
|
||||
|
|
@ -135,12 +135,14 @@ export async function renderFileExplorer(settingsTab: SettingsTab): Promise<void
|
|||
.setValue(settingsTab.plugin.settings.hideCollapsingIcon)
|
||||
.onChange(async (value) => {
|
||||
settingsTab.plugin.settings.hideCollapsingIcon = value;
|
||||
await settingsTab.plugin.saveSettings();
|
||||
if (value) {
|
||||
console.log(document.body.classList.contains('fn-hide-collapse-icon'));
|
||||
document.body.classList.add('fn-hide-collapse-icon');
|
||||
} else {
|
||||
console.log(document.body.classList.contains('fn-hide-collapse-icon'));
|
||||
document.body.classList.remove('fn-hide-collapse-icon');
|
||||
}
|
||||
await settingsTab.plugin.saveSettings();
|
||||
settingsTab.display();
|
||||
}),
|
||||
);
|
||||
|
|
@ -170,6 +172,11 @@ export async function renderFileExplorer(settingsTab: SettingsTab): Promise<void
|
|||
toggle
|
||||
.setValue(settingsTab.plugin.settings.ignoreAttachmentFolder)
|
||||
.onChange(async (value) => {
|
||||
if (value) {
|
||||
document.body.classList.add('fn-ignore-attachment-folder');
|
||||
} else {
|
||||
document.body.classList.remove('fn-ignore-attachment-folder');
|
||||
}
|
||||
settingsTab.plugin.settings.ignoreAttachmentFolder = value;
|
||||
await settingsTab.plugin.saveSettings();
|
||||
}),
|
||||
|
|
|
|||
|
|
@ -223,8 +223,10 @@ li:has(.fv-link-list-item),
|
|||
|
||||
.fn-has-no-files .collapse-icon,
|
||||
.fn-hide-collapse-icon .has-folder-note.only-has-folder-note .tree-item-icon,
|
||||
.fn-hide-empty-collapse-icon .fn-empty-folder .tree-item-icon,
|
||||
.only-has-folder-note:not(.is-collapsed):not(.show-folder-note-in-explorer)>.nav-folder-children {
|
||||
body.fn-ignore-attachment-folder.fn-hide-collapse-icon .only-has-folder-note .fn-empty-folder.fn-has-attachment-folder .tree-item-icon,
|
||||
body.fn-hide-collapse-icon .only-has-folder-note .fn-empty-folder:not(.fn-has-attachment-folder) .tree-item-icon,
|
||||
body.fn-hide-empty-collapse-icon :not(.only-has-folder-note) > .fn-empty-folder:not(.fn-has-attachment-folder) .tree-item-icon,
|
||||
body.fn-hide-collapse-icon.only-has-folder-note:not(.is-collapsed):not(.show-folder-note-in-explorer)>.nav-folder-children {
|
||||
display: none;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue