mirror of
https://github.com/lostpaul/obsidian-folder-notes.git
synced 2026-07-22 07:40:24 +00:00
Exclude folder from overview
This commit is contained in:
parent
4b3a5a09a2
commit
5e3424ae3e
5 changed files with 39 additions and 4 deletions
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"id": "folder-notes",
|
||||
"name": "Folder notes",
|
||||
"version": "1.4.6",
|
||||
"version": "1.4.7",
|
||||
"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",
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ export class ExcludedFolder {
|
|||
disableFolderNote: boolean;
|
||||
enableCollapsing: boolean;
|
||||
position: number;
|
||||
excludeFromFolderOverview: boolean;
|
||||
constructor(path: string, position: number) {
|
||||
this.type = 'folder';
|
||||
this.path = path;
|
||||
|
|
@ -24,6 +25,7 @@ export class ExcludedFolder {
|
|||
this.disableFolderNote = false;
|
||||
this.enableCollapsing = false;
|
||||
this.position = position;
|
||||
this.excludeFromFolderOverview = false;
|
||||
this.string = '';
|
||||
}
|
||||
}
|
||||
|
|
@ -38,6 +40,7 @@ export class ExcludePattern {
|
|||
disableAutoCreate: boolean;
|
||||
disableFolderNote: boolean;
|
||||
enableCollapsing: boolean;
|
||||
excludeFromFolderOverview: boolean;
|
||||
constructor(pattern: string, position: number) {
|
||||
this.type = 'pattern';
|
||||
this.string = pattern;
|
||||
|
|
@ -47,6 +50,7 @@ export class ExcludePattern {
|
|||
this.disableAutoCreate = true;
|
||||
this.disableFolderNote = false;
|
||||
this.enableCollapsing = false;
|
||||
this.excludeFromFolderOverview = false;
|
||||
this.path = '';
|
||||
}
|
||||
}
|
||||
|
|
@ -61,10 +65,14 @@ export function getExcludedFolder(plugin: FolderNotesPlugin, path: string) {
|
|||
}
|
||||
|
||||
export function getExcludedFolderByPattern(plugin: FolderNotesPlugin, folderName: string) {
|
||||
return plugin.settings.excludeFolders.filter((s) => s.path === '').find((pattern) => {
|
||||
return plugin.settings.excludeFolders.filter((s) => s.type == 'pattern').find((pattern) => {
|
||||
if (!pattern.string) { return false; }
|
||||
if (pattern.string.toLocaleLowerCase().startsWith('{regex}') && pattern.string.slice(7).trim() !== '') {
|
||||
const match = new RegExp(pattern.string.slice(7).trim()).exec(folderName);
|
||||
const string = pattern.string.toLocaleLowerCase().trim();
|
||||
if (!string.startsWith('{regex}') || string.startsWith('*') || string.endsWith('*')) { return false; }
|
||||
const regex = string.replace('{regex}', '').trim();
|
||||
if (string.startsWith('{regex}') && regex === '') { return false; }
|
||||
if (regex !== undefined) {
|
||||
const match = new RegExp(regex).exec(folderName);
|
||||
if (match) {
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ import { MarkdownPostProcessorContext, parseYaml, TAbstractFile, TFolder, TFile
|
|||
import { extractFolderName, getFolderNote } from './functions/folderNoteFunctions';
|
||||
import FolderNotesPlugin from './main';
|
||||
import { FolderOverviewSettings } from './modals/folderOverview';
|
||||
import { getExcludedFolder } from './excludedFolder';
|
||||
export type yamlSettings = {
|
||||
title?: string;
|
||||
disableTitle?: boolean;
|
||||
|
|
@ -71,6 +72,8 @@ export function createOverview(plugin: FolderNotesPlugin, source: string, el: HT
|
|||
files = files.filter((file) => {
|
||||
const folderPath = plugin.getFolderPathFromString(file.path);
|
||||
if (!folderPath.startsWith(sourceFolderPath)) { return false; }
|
||||
const excludedFolder = getExcludedFolder(plugin, file.path);
|
||||
if (excludedFolder?.excludeFromFolderOverview) { return false; }
|
||||
if (file.path === ctx.sourcePath) { return false; }
|
||||
if ((file.path.split('/').length - sourceFolderPath.split('/').length) - 1 < depth) {
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -42,6 +42,18 @@ export default class ExcludedFolderSettings extends Modal {
|
|||
})
|
||||
);
|
||||
|
||||
new Setting(contentEl)
|
||||
.setName('Don\'t show folder in folder overview')
|
||||
.setDesc('Choose if the folder should be shown in the folder overview')
|
||||
.addToggle((toggle) =>
|
||||
toggle
|
||||
.setValue(this.excludedFolder.excludeFromFolderOverview)
|
||||
.onChange(async (value) => {
|
||||
this.excludedFolder.excludeFromFolderOverview = value;
|
||||
await this.plugin.saveSettings();
|
||||
})
|
||||
);
|
||||
|
||||
new Setting(contentEl)
|
||||
.setName('Disable auto creation of folder notes in this folder')
|
||||
.setDesc('Choose if a folder note should be created when a new folder is created')
|
||||
|
|
|
|||
|
|
@ -42,6 +42,18 @@ export default class PatternSettings extends Modal {
|
|||
})
|
||||
);
|
||||
|
||||
new Setting(contentEl)
|
||||
.setName('Don\'t show folder in folder overview')
|
||||
.setDesc('Choose if the folder should be shown in the folder overview')
|
||||
.addToggle((toggle) =>
|
||||
toggle
|
||||
.setValue(this.pattern.excludeFromFolderOverview)
|
||||
.onChange(async (value) => {
|
||||
this.pattern.excludeFromFolderOverview = value;
|
||||
await this.plugin.saveSettings();
|
||||
})
|
||||
);
|
||||
|
||||
|
||||
new Setting(contentEl)
|
||||
.setName('Disable open folder note')
|
||||
|
|
|
|||
Loading…
Reference in a new issue