mirror of
https://github.com/lostpaul/obsidian-folder-notes.git
synced 2026-07-22 07:40:24 +00:00
Fixed hide collapse icon bug & more
Fixed that the file explorer always updates when changing a tab in the plugin settings Changed the setting name for the css class that stops white space collapsing for less confusing with the name
This commit is contained in:
parent
35e53aa5f5
commit
4371aa56d3
5 changed files with 37 additions and 30 deletions
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"id": "folder-notes",
|
||||
"name": "Folder notes",
|
||||
"version": "1.7.5",
|
||||
"version": "1.7.6",
|
||||
"minAppVersion": "0.15.0",
|
||||
"description": "Create notes within folders that can be accessed without collapsing the folder, similar to the functionality offered in Notion.",
|
||||
"author": "Lost Paul",
|
||||
|
|
|
|||
17
src/main.ts
17
src/main.ts
|
|
@ -22,6 +22,7 @@ export default class FolderNotesPlugin extends Plugin {
|
|||
mouseEvent: MouseEvent | null = null;
|
||||
hoverLinkTriggered = false;
|
||||
tabManager: TabManager;
|
||||
settingsOpened = false;
|
||||
async onload() {
|
||||
console.log('loading folder notes plugin');
|
||||
await this.loadSettings();
|
||||
|
|
@ -38,7 +39,7 @@ export default class FolderNotesPlugin extends Plugin {
|
|||
if (this.settings.boldNameInPath) { document.body.classList.add('folder-note-bold-path'); }
|
||||
if (this.settings.cursiveNameInPath) { document.body.classList.add('folder-note-cursive-path'); }
|
||||
if (this.settings.underlineFolderInPath) { document.body.classList.add('folder-note-underline-path'); }
|
||||
if (!this.settings.allowWhitespaceCollapsing) { document.body.classList.add('fn-whitespace-stop-collapsing'); }
|
||||
if (this.settings.stopWhitespaceCollapsing) { document.body.classList.add('fn-whitespace-stop-collapsing'); }
|
||||
if (this.settings.hideCollapsingIcon) { document.body.classList.add('fn-hide-collapse-icon'); }
|
||||
|
||||
new Commands(this.app, this).registerCommands();
|
||||
|
|
@ -179,10 +180,10 @@ export default class FolderNotesPlugin extends Plugin {
|
|||
}
|
||||
|
||||
if (file instanceof TFile) {
|
||||
const folderName = extractFolderName(this.settings.folderNoteName, file.basename);
|
||||
const folder = getFolder(this, file);
|
||||
if (!(folder instanceof TFolder)) { return; }
|
||||
if (folderName !== folder.name) { return; }
|
||||
this.addCSSClassToTitleEL(folder.path, 'has-folder-note');
|
||||
this.addCSSClassToTitleEL(file.path, 'is-folder-note');
|
||||
}
|
||||
if (!this.app.workspace.layoutReady) return;
|
||||
|
||||
|
|
@ -368,16 +369,18 @@ export default class FolderNotesPlugin extends Plugin {
|
|||
} else if (folder.children.length > 1) {
|
||||
if (attachmentsAreInRootFolder) {
|
||||
return false;
|
||||
} else if (this.settings.ignoreAttachmentFolder) {
|
||||
} 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) {
|
||||
if (!folder.collapsed) {
|
||||
this.getEL(folder.path)?.click();
|
||||
}
|
||||
return attachmentFolder.children.length <= 2;
|
||||
return folder.children.length <= 2;
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
|
@ -532,6 +535,8 @@ export default class FolderNotesPlugin extends Plugin {
|
|||
async saveSettings() {
|
||||
await this.saveData(this.settings);
|
||||
// cleanup any css if we need too
|
||||
if (!this.settingsOpened) {
|
||||
this.loadFileClasses(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,14 +42,14 @@ export async function renderFileExplorer(settingsTab: SettingsTab) {
|
|||
.setDesc('Only open folder notes in the file explorer by clicking on the folder name')
|
||||
.addToggle((toggle) =>
|
||||
toggle
|
||||
.setValue(settingsTab.plugin.settings.allowWhitespaceCollapsing)
|
||||
.setValue(!settingsTab.plugin.settings.stopWhitespaceCollapsing)
|
||||
.onChange(async (value) => {
|
||||
if (!value) {
|
||||
document.body.classList.add('fn-whitespace-stop-collapsing');
|
||||
} else {
|
||||
document.body.classList.remove('fn-whitespace-stop-collapsing');
|
||||
}
|
||||
settingsTab.plugin.settings.allowWhitespaceCollapsing = value;
|
||||
settingsTab.plugin.settings.stopWhitespaceCollapsing = !value;
|
||||
await settingsTab.plugin.saveSettings();
|
||||
})
|
||||
);
|
||||
|
|
|
|||
|
|
@ -35,24 +35,22 @@ export async function renderPath(settingsTab: SettingsTab) {
|
|||
|
||||
settingsTab.settingsPage.createEl('h3', { text: 'Style settings' });
|
||||
|
||||
if (settingsTab.plugin.settings.openFolderNoteOnClickInPath) {
|
||||
new Setting(containerEl)
|
||||
.setName('Underline folders in the path')
|
||||
.setDesc('Add an underline to folders that have a folder note in the path above a note')
|
||||
.addToggle((toggle) =>
|
||||
toggle
|
||||
.setValue(settingsTab.plugin.settings.underlineFolderInPath)
|
||||
.onChange(async (value) => {
|
||||
settingsTab.plugin.settings.underlineFolderInPath = value;
|
||||
if (value) {
|
||||
document.body.classList.add('folder-note-underline-path');
|
||||
} else {
|
||||
document.body.classList.remove('folder-note-underline-path');
|
||||
}
|
||||
await settingsTab.plugin.saveSettings();
|
||||
})
|
||||
);
|
||||
}
|
||||
new Setting(containerEl)
|
||||
.setName('Underline folders in the path')
|
||||
.setDesc('Add an underline to folders that have a folder note in the path above a note')
|
||||
.addToggle((toggle) =>
|
||||
toggle
|
||||
.setValue(settingsTab.plugin.settings.underlineFolderInPath)
|
||||
.onChange(async (value) => {
|
||||
settingsTab.plugin.settings.underlineFolderInPath = value;
|
||||
if (value) {
|
||||
document.body.classList.add('folder-note-underline-path');
|
||||
} else {
|
||||
document.body.classList.remove('folder-note-underline-path');
|
||||
}
|
||||
await settingsTab.plugin.saveSettings();
|
||||
})
|
||||
);
|
||||
|
||||
new Setting(containerEl)
|
||||
.setName('Bold folders in the path')
|
||||
|
|
@ -87,5 +85,4 @@ export async function renderPath(settingsTab: SettingsTab) {
|
|||
await settingsTab.plugin.saveSettings();
|
||||
})
|
||||
);
|
||||
|
||||
}
|
||||
|
|
@ -21,7 +21,7 @@ export interface FolderNotesSettings {
|
|||
showDeleteConfirmation: boolean;
|
||||
showRenameConfirmation: boolean;
|
||||
underlineFolder: boolean;
|
||||
allowWhitespaceCollapsing: boolean;
|
||||
stopWhitespaceCollapsing: boolean;
|
||||
underlineFolderInPath: boolean;
|
||||
openFolderNoteOnClickInPath: boolean;
|
||||
openInNewTab: boolean;
|
||||
|
|
@ -67,7 +67,7 @@ export const DEFAULT_SETTINGS: FolderNotesSettings = {
|
|||
excludeFolders: [],
|
||||
showDeleteConfirmation: true,
|
||||
underlineFolder: true,
|
||||
allowWhitespaceCollapsing: false,
|
||||
stopWhitespaceCollapsing: false,
|
||||
underlineFolderInPath: true,
|
||||
openFolderNoteOnClickInPath: true,
|
||||
openInNewTab: false,
|
||||
|
|
@ -194,6 +194,7 @@ export class SettingsTab extends PluginSettingTab {
|
|||
}
|
||||
|
||||
display(): void {
|
||||
this.plugin.settingsOpened = true;
|
||||
const { containerEl } = this;
|
||||
|
||||
containerEl.empty();
|
||||
|
|
@ -264,4 +265,8 @@ export class SettingsTab extends PluginSettingTab {
|
|||
});
|
||||
new Notice('Finished switching storage location');
|
||||
}
|
||||
|
||||
onClose(): void {
|
||||
this.plugin.settingsOpened = false;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue