mirror of
https://github.com/lostpaul/obsidian-folder-notes.git
synced 2026-07-22 07:40:24 +00:00
Override excluded folders/patterns with whitelist
This commit is contained in:
parent
8cd11dd959
commit
cd38702394
13 changed files with 514 additions and 417 deletions
|
|
@ -285,7 +285,7 @@ export class Commands {
|
|||
item.setTitle('Exclude folder from folder notes')
|
||||
.setIcon('x-circle')
|
||||
.onClick(() => {
|
||||
const excludedFolder = new ExcludedFolder(file.path, this.plugin.settings.excludeFolders.length, this.plugin);
|
||||
const excludedFolder = new ExcludedFolder(file.path, this.plugin.settings.excludeFolders.length, undefined, this.plugin);
|
||||
this.plugin.settings.excludeFolders.push(excludedFolder);
|
||||
this.plugin.saveSettings();
|
||||
new Notice('Successfully excluded folder from folder notes');
|
||||
|
|
|
|||
|
|
@ -1,17 +1,20 @@
|
|||
import FolderNotesPlugin from '../main';
|
||||
export class WhitelistedFolder {
|
||||
type: string;
|
||||
id: string;
|
||||
path: string;
|
||||
string: string;
|
||||
subFolders: boolean;
|
||||
enableSync: boolean;
|
||||
enableAutoCreate: boolean;
|
||||
enabledFolderNote: boolean;
|
||||
disableCollapsing: boolean;
|
||||
allowAll: boolean;
|
||||
enableFolderNote: boolean;
|
||||
enableCollapsing: boolean;
|
||||
showInFolderOverview: boolean;
|
||||
position: number;
|
||||
constructor(path: string, position: number, plugin: FolderNotesPlugin) {
|
||||
hideInSettings: boolean;
|
||||
constructor(path: string, position: number, id: string | undefined, plugin: FolderNotesPlugin) {
|
||||
this.type = 'folder';
|
||||
this.id = id || crypto.randomUUID();
|
||||
this.path = path;
|
||||
this.subFolders = plugin.settings.excludeFolderDefaultSettings.subFolders;
|
||||
this.position = position;
|
||||
|
|
|
|||
|
|
@ -1,18 +1,20 @@
|
|||
import FolderNotesPlugin from '../main';
|
||||
export class WhitelistedPattern {
|
||||
type: string;
|
||||
id: string;
|
||||
string: string;
|
||||
path: string;
|
||||
position: number;
|
||||
subFolders: boolean;
|
||||
disableSync: boolean;
|
||||
disableAutoCreate: boolean;
|
||||
disableFolderNote: boolean;
|
||||
enableSync: boolean;
|
||||
enableAutoCreate: boolean;
|
||||
enableFolderNote: boolean;
|
||||
enableCollapsing: boolean;
|
||||
allowAll: boolean;
|
||||
showInFolderOverview: boolean;
|
||||
hideInSettings: boolean;
|
||||
constructor(pattern: string, position: number, plugin: FolderNotesPlugin) {
|
||||
constructor(pattern: string, position: number, id: string | undefined, plugin: FolderNotesPlugin) {
|
||||
this.type = 'pattern';
|
||||
this.id = id || crypto.randomUUID();
|
||||
this.subFolders = plugin.settings.excludePatternDefaultSettings.subFolders;
|
||||
this.position = position;
|
||||
this.string = pattern;
|
||||
|
|
|
|||
|
|
@ -1,143 +1,144 @@
|
|||
export {}
|
||||
// import FolderNotesPlugin from '../../main';
|
||||
// import { getFolderNameFromPathString, getFolderPathFromString } from '../../functions/utils';
|
||||
// import { WhitelistedFolder } from '../WhitelistFolder';
|
||||
// import { WhitelistedPattern } from '../WhitelistPattern';
|
||||
// import { Setting } from 'obsidian';
|
||||
// import { FolderSuggest } from '../../suggesters/FolderSuggester';
|
||||
// import { SettingsTab } from '../../settings/SettingsTab';
|
||||
// import WhitelistedFolderSettings from '../modals/WhitelistFolderSettings';
|
||||
// import { updatePattern, getWhitelistedFolderByPattern, addWhitelistPatternListItem } from './patternFunctions';
|
||||
import FolderNotesPlugin from '../../main';
|
||||
import { getFolderNameFromPathString, getFolderPathFromString } from '../../functions/utils';
|
||||
import { WhitelistedFolder } from '../WhitelistFolder';
|
||||
import { WhitelistedPattern } from '../WhitelistPattern';
|
||||
import { Setting } from 'obsidian';
|
||||
import { FolderSuggest } from '../../suggesters/FolderSuggester';
|
||||
import { SettingsTab } from '../../settings/SettingsTab';
|
||||
import WhitelistededFoldersSettings from '../modals/WhitelistedFoldersSettings';
|
||||
import WhitelistFolderSettings from '../modals/WhitelistFolderSettings';
|
||||
import { updateWhitelistedPattern, getWhitelistedFolderByPattern, addWhitelistedPatternListItem } from './whitelistPatternFunctions';
|
||||
|
||||
// export function getWhitelistedFolder(plugin: FolderNotesPlugin, path: string) {
|
||||
// const folderName = getFolderNameFromPathString(path);
|
||||
// const matchedPattern = getWhitelistedFolderByPattern(plugin, folderName);
|
||||
// if (matchedPattern) { return matchedPattern; }
|
||||
// const whitelistedFolder = getWhitelistedFolderByPath(plugin, path);
|
||||
// if (whitelistedFolder?.path === '') { return; }
|
||||
// return whitelistedFolder;
|
||||
// }
|
||||
export function getWhitelistedFolder(plugin: FolderNotesPlugin, path: string) {
|
||||
const folderName = getFolderNameFromPathString(path);
|
||||
const matchedPattern = getWhitelistedFolderByPattern(plugin, folderName);
|
||||
if (matchedPattern) { return matchedPattern; }
|
||||
const whitelistedFolder = getWhitelistedFolderByPath(plugin, path);
|
||||
if (whitelistedFolder?.path === '') { return; }
|
||||
return whitelistedFolder;
|
||||
}
|
||||
|
||||
// export function getWhitelistedFolderByPath(plugin: FolderNotesPlugin, path: string) {
|
||||
// return plugin.settings.whitelistFolders.find((whitelistedFolder) => {
|
||||
// if (whitelistedFolder.path === path) { return true; }
|
||||
// if (!whitelistedFolder.subFolders) { return false; }
|
||||
// return getFolderPathFromString(path).startsWith(whitelistedFolder.path);
|
||||
// });
|
||||
// }
|
||||
export function getWhitelistedFolderByPath(plugin: FolderNotesPlugin, path: string) {
|
||||
return plugin.settings.whitelistFolders.find((whitelistedFolder) => {
|
||||
if (whitelistedFolder.path === path) { return true; }
|
||||
if (!whitelistedFolder.subFolders) { return false; }
|
||||
return getFolderPathFromString(path).startsWith(whitelistedFolder.path);
|
||||
});
|
||||
}
|
||||
|
||||
// export function addWhitelistedFolder(plugin: FolderNotesPlugin, whitelistedFolder: WhitelistedFolder) {
|
||||
// plugin.settings.whitelistFolders.push(whitelistedFolder);
|
||||
// plugin.saveSettings();
|
||||
// }
|
||||
export function addWhitelistedFolder(plugin: FolderNotesPlugin, whitelistedFolder: WhitelistedFolder) {
|
||||
plugin.settings.whitelistFolders.push(whitelistedFolder);
|
||||
plugin.saveSettings(true);
|
||||
}
|
||||
|
||||
// export function deleteWhitelistedFolder(plugin: FolderNotesPlugin, whitelistedFolder: WhitelistedFolder) {
|
||||
// plugin.settings.whitelistFolders = plugin.settings.whitelistFolders.filter((folder) => folder.path !== whitelistedFolder.path || folder.type === 'pattern');
|
||||
// plugin.saveSettings();
|
||||
// resyncArray(plugin);
|
||||
// }
|
||||
export function deleteWhitelistedFolder(plugin: FolderNotesPlugin, whitelistedFolder: WhitelistedFolder) {
|
||||
plugin.settings.whitelistFolders = plugin.settings.whitelistFolders.filter((folder) => folder.id !== whitelistedFolder.id || folder.type === 'pattern');
|
||||
plugin.saveSettings();
|
||||
resyncArray(plugin);
|
||||
}
|
||||
|
||||
// export function updateWhitelistedFolder(plugin: FolderNotesPlugin, whitelistedFolder: WhitelistPattern, newWhitelistFolder: WhitelistPattern) {
|
||||
// plugin.settings.whitelistFolders = plugin.settings.whitelistFolders.filter((folder) => folder.path !== whitelistedFolder.path);
|
||||
// addWhitelistedFolder(plugin, newWhitelistFolder);
|
||||
// }
|
||||
export function updateWhitelistedFolder(plugin: FolderNotesPlugin, whitelistedFolder: WhitelistedFolder, newWhitelistFolder: WhitelistedFolder) {
|
||||
plugin.settings.whitelistFolders = plugin.settings.whitelistFolders.filter((folder) => folder.id !== whitelistedFolder.id);
|
||||
addWhitelistedFolder(plugin, newWhitelistFolder);
|
||||
}
|
||||
|
||||
// export function resyncArray(plugin: FolderNotesPlugin) {
|
||||
// plugin.settings.whitelistFolders = plugin.settings.whitelistFolders.sort((a, b) => a.position - b.position);
|
||||
// plugin.settings.whitelistFolders.forEach((folder, index) => {
|
||||
// folder.position = index;
|
||||
// });
|
||||
// plugin.saveSettings();
|
||||
// }
|
||||
export function resyncArray(plugin: FolderNotesPlugin) {
|
||||
plugin.settings.whitelistFolders = plugin.settings.whitelistFolders.sort((a, b) => a.position - b.position);
|
||||
plugin.settings.whitelistFolders.forEach((folder, index) => {
|
||||
folder.position = index;
|
||||
});
|
||||
plugin.saveSettings();
|
||||
}
|
||||
|
||||
|
||||
// export function addWhitelistFolderListItem(settings: SettingsTab, containerEl: HTMLElement, whitelistedFolder: WhitelistedFolder) {
|
||||
// const plugin: FolderNotesPlugin = settings.plugin;
|
||||
// const setting = new Setting(containerEl);
|
||||
// setting.setClass('fn-exclude-folder-list');
|
||||
// setting.addSearch((cb) => {
|
||||
// new FolderSuggest(
|
||||
// cb.inputEl,
|
||||
// plugin
|
||||
// );
|
||||
// // @ts-ignore
|
||||
// cb.containerEl.addClass('fn-exclude-folder-path');
|
||||
// cb.setPlaceholder('Folder path');
|
||||
// cb.setValue(whitelistedFolder.path);
|
||||
// cb.onChange((value) => {
|
||||
// if (value.startsWith('{regex}') || value.includes('*')) {
|
||||
// deleteWhitelistedFolder(plugin, whitelistedFolder);
|
||||
// const pattern = new WhitelistPattern(value, plugin.settings.whitelistFolders.length, plugin);
|
||||
// addWhitelistedFolder(plugin, pattern);
|
||||
// addWhitelistPatternListItem(settings, containerEl, pattern);
|
||||
// setting.clear();
|
||||
// setting.settingEl.remove();
|
||||
// }
|
||||
// if (!plugin.app.vault.getAbstractFileByPath(value)) return;
|
||||
// whitelistedFolder.path = value;
|
||||
// updateWhitelistedFolder(plugin, whitelistedFolder, whitelistedFolder);
|
||||
// });
|
||||
// });
|
||||
export function addWhitelistFolderListItem(settings: SettingsTab, containerEl: HTMLElement, whitelistedFolder: WhitelistedFolder) {
|
||||
const plugin: FolderNotesPlugin = settings.plugin;
|
||||
const setting = new Setting(containerEl);
|
||||
setting.setClass('fn-exclude-folder-list');
|
||||
setting.addSearch((cb) => {
|
||||
new FolderSuggest(
|
||||
cb.inputEl,
|
||||
plugin,
|
||||
true
|
||||
);
|
||||
// @ts-ignore
|
||||
cb.containerEl.addClass('fn-exclude-folder-path');
|
||||
cb.setPlaceholder('Folder path');
|
||||
cb.setValue(whitelistedFolder.path);
|
||||
cb.onChange((value) => {
|
||||
if (value.startsWith('{regex}') || value.includes('*')) {
|
||||
deleteWhitelistedFolder(plugin, whitelistedFolder);
|
||||
const pattern = new WhitelistedFolder(value, plugin.settings.whitelistFolders.length, whitelistedFolder.id, plugin);
|
||||
addWhitelistedFolder(plugin, pattern);
|
||||
addWhitelistedPatternListItem(settings, containerEl, pattern);
|
||||
setting.clear();
|
||||
setting.settingEl.remove();
|
||||
}
|
||||
if (!plugin.app.vault.getAbstractFileByPath(value)) return;
|
||||
whitelistedFolder.path = value;
|
||||
updateWhitelistedFolder(plugin, whitelistedFolder, whitelistedFolder);
|
||||
});
|
||||
});
|
||||
|
||||
// setting.addButton((cb) => {
|
||||
// cb.setIcon('edit');
|
||||
// cb.setTooltip('Edit folder note');
|
||||
// cb.onClick(() => {
|
||||
// new WhitelistedFolderSettings(plugin.app, plugin, whitelistedFolder).open();
|
||||
// });
|
||||
// });
|
||||
setting.addButton((cb) => {
|
||||
cb.setIcon('edit');
|
||||
cb.setTooltip('Edit folder note');
|
||||
cb.onClick(() => {
|
||||
new WhitelistFolderSettings(plugin.app, plugin, whitelistedFolder).open();
|
||||
});
|
||||
});
|
||||
|
||||
// setting.addButton((cb) => {
|
||||
// cb.setIcon('up-chevron-glyph');
|
||||
// cb.setTooltip('Move up');
|
||||
// cb.onClick(() => {
|
||||
// if (whitelistedFolder.position === 0) { return; }
|
||||
// whitelistedFolder.position -= 1;
|
||||
// updateWhitelistedFolder(plugin, whitelistedFolder, whitelistedFolder);
|
||||
// const oldWhitelistedFolder = plugin.settings.whitelistFolders.find((folder) => folder.position === whitelistedFolder.position);
|
||||
// if (oldWhitelistedFolder) {
|
||||
// oldWhitelistedFolder.position += 1;
|
||||
// if (oldWhitelistedFolder.type === 'pattern') {
|
||||
// updatePattern(plugin, oldWhitelistedFolder, oldWhitelistedFolder);
|
||||
// } else {
|
||||
// updateWhitelistedFolder(plugin, oldWhitelistedFolder, oldWhitelistedFolder);
|
||||
// }
|
||||
// }
|
||||
// settings.display();
|
||||
// });
|
||||
// });
|
||||
setting.addButton((cb) => {
|
||||
cb.setIcon('up-chevron-glyph');
|
||||
cb.setTooltip('Move up');
|
||||
cb.onClick(() => {
|
||||
if (whitelistedFolder.position === 0) { return; }
|
||||
whitelistedFolder.position -= 1;
|
||||
updateWhitelistedFolder(plugin, whitelistedFolder, whitelistedFolder);
|
||||
const oldWhitelistedFolder = plugin.settings.whitelistFolders.find((folder) => folder.position === whitelistedFolder.position);
|
||||
if (oldWhitelistedFolder) {
|
||||
oldWhitelistedFolder.position += 1;
|
||||
if (oldWhitelistedFolder.type === 'pattern') {
|
||||
updateWhitelistedPattern(plugin, oldWhitelistedFolder, oldWhitelistedFolder);
|
||||
} else {
|
||||
updateWhitelistedFolder(plugin, oldWhitelistedFolder, oldWhitelistedFolder);
|
||||
}
|
||||
}
|
||||
settings.display();
|
||||
});
|
||||
});
|
||||
|
||||
// setting.addButton((cb) => {
|
||||
// cb.setIcon('down-chevron-glyph');
|
||||
// cb.setTooltip('Move down');
|
||||
// cb.onClick(() => {
|
||||
// if (whitelistedFolder.position === plugin.settings.whitelistFolders.length - 1) {
|
||||
// return;
|
||||
// }
|
||||
// whitelistedFolder.position += 1;
|
||||
setting.addButton((cb) => {
|
||||
cb.setIcon('down-chevron-glyph');
|
||||
cb.setTooltip('Move down');
|
||||
cb.onClick(() => {
|
||||
if (whitelistedFolder.position === plugin.settings.whitelistFolders.length - 1) {
|
||||
return;
|
||||
}
|
||||
whitelistedFolder.position += 1;
|
||||
|
||||
// updateWhitelistedFolder(plugin, whitelistedFolder, whitelistedFolder);
|
||||
// const oldWhitelistedFolder = plugin.settings.whitelistFolders.find((folder) => folder.position === whitelistedFolder.position);
|
||||
// if (oldWhitelistedFolder) {
|
||||
// oldWhitelistedFolder.position -= 1;
|
||||
// if (oldWhitelistedFolder.type === 'pattern') {
|
||||
// updatePattern(plugin, oldWhitelistedFolder, oldWhitelistedFolder);
|
||||
// } else {
|
||||
// updateWhitelistedFolder(plugin, oldWhitelistedFolder, oldWhitelistedFolder);
|
||||
// }
|
||||
// }
|
||||
updateWhitelistedFolder(plugin, whitelistedFolder, whitelistedFolder);
|
||||
const oldWhitelistedFolder = plugin.settings.whitelistFolders.find((folder) => folder.position === whitelistedFolder.position);
|
||||
if (oldWhitelistedFolder) {
|
||||
oldWhitelistedFolder.position -= 1;
|
||||
if (oldWhitelistedFolder.type === 'pattern') {
|
||||
updateWhitelistedPattern(plugin, oldWhitelistedFolder, oldWhitelistedFolder);
|
||||
} else {
|
||||
updateWhitelistedFolder(plugin, oldWhitelistedFolder, oldWhitelistedFolder);
|
||||
}
|
||||
}
|
||||
|
||||
// settings.display();
|
||||
// });
|
||||
// });
|
||||
settings.display();
|
||||
});
|
||||
});
|
||||
|
||||
// setting.addButton((cb) => {
|
||||
// cb.setIcon('trash-2');
|
||||
// cb.setTooltip('Delete excluded folder');
|
||||
// cb.onClick(() => {
|
||||
// deleteWhitelistedFolder(plugin, whitelistedFolder);
|
||||
// setting.clear();
|
||||
// setting.settingEl.remove();
|
||||
// });
|
||||
// });
|
||||
// }
|
||||
setting.addButton((cb) => {
|
||||
cb.setIcon('trash-2');
|
||||
cb.setTooltip('Delete excluded folder');
|
||||
cb.onClick(() => {
|
||||
deleteWhitelistedFolder(plugin, whitelistedFolder);
|
||||
setting.clear();
|
||||
setting.settingEl.remove();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,124 +1,123 @@
|
|||
export {}
|
||||
// import FolderNotesPlugin from '../../main';
|
||||
// import { ExcludePattern } from '../ExcludePattern';
|
||||
// import { Setting } from 'obsidian';
|
||||
// import { SettingsTab } from '../../settings/SettingsTab';
|
||||
// import { addExcludedFolder, resyncArray, updateExcludedFolder } from './folderFunctions';
|
||||
// import PatternSettings from '../modals/PatternSettings';
|
||||
// import { WhitelistedPattern } from '../WhitelistPattern';
|
||||
import FolderNotesPlugin from '../../main';
|
||||
import { Setting } from 'obsidian';
|
||||
import { SettingsTab } from '../../settings/SettingsTab';
|
||||
import { addExcludedFolder, resyncArray, updateExcludedFolder } from './folderFunctions';
|
||||
import WhitelistPatternSettings from '../modals/WhitelistPatternSettings';
|
||||
import { WhitelistedPattern } from '../WhitelistPattern';
|
||||
import { addWhitelistedFolder, updateWhitelistedFolder } from './whitelistFolderFunctions';
|
||||
|
||||
// export function updatePattern(plugin: FolderNotesPlugin, pattern: ExcludePattern, newPattern: ExcludePattern) {
|
||||
// plugin.settings.excludeFolders = plugin.settings.excludeFolders.filter((folder) => folder.string !== pattern.string);
|
||||
// addExcludedFolder(plugin, newPattern);
|
||||
// }
|
||||
export function updateWhitelistedPattern(plugin: FolderNotesPlugin, pattern: WhitelistedPattern, newPattern: WhitelistedPattern) {
|
||||
plugin.settings.excludeFolders = plugin.settings.excludeFolders.filter((folder) => folder.id !== pattern.id);
|
||||
addWhitelistedFolder(plugin, newPattern);
|
||||
}
|
||||
|
||||
// export function deletePattern(plugin: FolderNotesPlugin, pattern: ExcludePattern) {
|
||||
// plugin.settings.excludeFolders = plugin.settings.excludeFolders.filter((folder) => folder.string !== pattern.string || folder.type === 'folder');
|
||||
// plugin.saveSettings();
|
||||
// resyncArray(plugin);
|
||||
// }
|
||||
export function deletePattern(plugin: FolderNotesPlugin, pattern: WhitelistedPattern) {
|
||||
plugin.settings.excludeFolders = plugin.settings.excludeFolders.filter((folder) => folder.id !== pattern.id || folder.type === 'folder');
|
||||
plugin.saveSettings();
|
||||
resyncArray(plugin);
|
||||
}
|
||||
|
||||
// export function getExcludedFolderByPattern(plugin: FolderNotesPlugin, folderName: string) {
|
||||
// return plugin.settings.excludeFolders.filter((s) => s.type == 'pattern').find((pattern) => {
|
||||
// if (!pattern.string) { return false; }
|
||||
// const string = pattern.string.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 && string.startsWith('{regex}')) {
|
||||
// const match = new RegExp(regex).exec(folderName);
|
||||
// if (match) {
|
||||
// return true;
|
||||
// }
|
||||
// } else if (string.startsWith('*') && string.endsWith('*')) {
|
||||
// if (folderName.includes(string.slice(1, -1))) {
|
||||
// return true;
|
||||
// }
|
||||
// } else if (string.startsWith('*')) {
|
||||
// if (folderName.endsWith(string.slice(1))) {
|
||||
// return true;
|
||||
// }
|
||||
// } else if (string.endsWith('*')) {
|
||||
// if (folderName.startsWith(string.slice(0, -1))) {
|
||||
// return true;
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
export function getWhitelistedFolderByPattern(plugin: FolderNotesPlugin, folderName: string) {
|
||||
return plugin.settings.whitelistFolders.filter((s) => s.type == 'pattern').find((pattern) => {
|
||||
if (!pattern.string) { return false; }
|
||||
const string = pattern.string.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 && string.startsWith('{regex}')) {
|
||||
const match = new RegExp(regex).exec(folderName);
|
||||
if (match) {
|
||||
return true;
|
||||
}
|
||||
} else if (string.startsWith('*') && string.endsWith('*')) {
|
||||
if (folderName.includes(string.slice(1, -1))) {
|
||||
return true;
|
||||
}
|
||||
} else if (string.startsWith('*')) {
|
||||
if (folderName.endsWith(string.slice(1))) {
|
||||
return true;
|
||||
}
|
||||
} else if (string.endsWith('*')) {
|
||||
if (folderName.startsWith(string.slice(0, -1))) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// export function addExcludePatternListItem(settings: SettingsTab, containerEl: HTMLElement, pattern: WhitelistedPattern) {
|
||||
// const plugin: FolderNotesPlugin = settings.plugin;
|
||||
// const setting = new Setting(containerEl);
|
||||
// setting.setClass('fn-exclude-folder-list');
|
||||
// setting.addSearch((cb) => {
|
||||
// // @ts-ignore
|
||||
// cb.containerEl.addClass('fn-exclude-folder-path');
|
||||
// cb.setPlaceholder('Pattern');
|
||||
// cb.setValue(pattern.string);
|
||||
// cb.onChange((value) => {
|
||||
// if (plugin.settings.excludeFolders.find((folder) => folder.string === value)) { return; }
|
||||
// pattern.string = value;
|
||||
// updatePattern(plugin, pattern, pattern);
|
||||
// });
|
||||
// });
|
||||
// setting.addButton((cb) => {
|
||||
// cb.setIcon('edit');
|
||||
// cb.setTooltip('Edit pattern');
|
||||
// cb.onClick(() => {
|
||||
// new PatternSettings(plugin.app, plugin, pattern).open();
|
||||
// });
|
||||
// });
|
||||
export function addWhitelistedPatternListItem(settings: SettingsTab, containerEl: HTMLElement, pattern: WhitelistedPattern) {
|
||||
const plugin: FolderNotesPlugin = settings.plugin;
|
||||
const setting = new Setting(containerEl);
|
||||
setting.setClass('fn-exclude-folder-list');
|
||||
setting.addSearch((cb) => {
|
||||
// @ts-ignore
|
||||
cb.containerEl.addClass('fn-exclude-folder-path');
|
||||
cb.setPlaceholder('Pattern');
|
||||
cb.setValue(pattern.string);
|
||||
cb.onChange((value) => {
|
||||
if (plugin.settings.excludeFolders.find((folder) => folder.string === value)) { return; }
|
||||
pattern.string = value;
|
||||
updateWhitelistedPattern(plugin, pattern, pattern);
|
||||
});
|
||||
});
|
||||
setting.addButton((cb) => {
|
||||
cb.setIcon('edit');
|
||||
cb.setTooltip('Edit pattern');
|
||||
cb.onClick(() => {
|
||||
new WhitelistPatternSettings(plugin.app, plugin, pattern).open();
|
||||
});
|
||||
});
|
||||
|
||||
// setting.addButton((cb) => {
|
||||
// cb.setIcon('up-chevron-glyph');
|
||||
// cb.setTooltip('Move up');
|
||||
// cb.onClick(() => {
|
||||
// if (pattern.position === 0) { return; }
|
||||
// pattern.position -= 1;
|
||||
// updatePattern(plugin, pattern, pattern);
|
||||
// const oldPattern = plugin.settings.excludeFolders.find((folder) => folder.position === pattern.position);
|
||||
// if (oldPattern) {
|
||||
// oldPattern.position += 1;
|
||||
// if (oldPattern.type === 'pattern') {
|
||||
// updatePattern(plugin, oldPattern, oldPattern);
|
||||
// } else {
|
||||
// updateExcludedFolder(plugin, oldPattern, oldPattern);
|
||||
// }
|
||||
// }
|
||||
// settings.display();
|
||||
// });
|
||||
// });
|
||||
setting.addButton((cb) => {
|
||||
cb.setIcon('up-chevron-glyph');
|
||||
cb.setTooltip('Move up');
|
||||
cb.onClick(() => {
|
||||
if (pattern.position === 0) { return; }
|
||||
pattern.position -= 1;
|
||||
updateWhitelistedPattern(plugin, pattern, pattern);
|
||||
const oldPattern = plugin.settings.whitelistFolders.find((folder) => folder.position === pattern.position);
|
||||
if (oldPattern) {
|
||||
oldPattern.position += 1;
|
||||
if (oldPattern.type === 'pattern') {
|
||||
updateWhitelistedPattern(plugin, oldPattern, oldPattern);
|
||||
} else {
|
||||
updateWhitelistedFolder(plugin, oldPattern, oldPattern);
|
||||
}
|
||||
}
|
||||
settings.display();
|
||||
});
|
||||
});
|
||||
|
||||
// setting.addButton((cb) => {
|
||||
// cb.setIcon('down-chevron-glyph');
|
||||
// cb.setTooltip('Move down');
|
||||
// cb.onClick(() => {
|
||||
// if (pattern.position === plugin.settings.excludeFolders.length - 1) {
|
||||
// return;
|
||||
// }
|
||||
// pattern.position += 1;
|
||||
setting.addButton((cb) => {
|
||||
cb.setIcon('down-chevron-glyph');
|
||||
cb.setTooltip('Move down');
|
||||
cb.onClick(() => {
|
||||
if (pattern.position === plugin.settings.excludeFolders.length - 1) {
|
||||
return;
|
||||
}
|
||||
pattern.position += 1;
|
||||
|
||||
// updatePattern(plugin, pattern, pattern);
|
||||
// const oldPattern = plugin.settings.excludeFolders.find((folder) => folder.position === pattern.position);
|
||||
// if (oldPattern) {
|
||||
// oldPattern.position -= 1;
|
||||
// if (oldPattern.type === 'pattern') {
|
||||
// updatePattern(plugin, oldPattern, oldPattern);
|
||||
// } else {
|
||||
// updateExcludedFolder(plugin, oldPattern, oldPattern);
|
||||
// }
|
||||
// }
|
||||
// settings.display();
|
||||
// });
|
||||
// });
|
||||
updateWhitelistedPattern(plugin, pattern, pattern);
|
||||
const oldPattern = plugin.settings.whitelistFolders.find((folder) => folder.position === pattern.position);
|
||||
if (oldPattern) {
|
||||
oldPattern.position -= 1;
|
||||
if (oldPattern.type === 'pattern') {
|
||||
updateWhitelistedPattern(plugin, oldPattern, oldPattern);
|
||||
} else {
|
||||
updateWhitelistedFolder(plugin, oldPattern, oldPattern);
|
||||
}
|
||||
}
|
||||
settings.display();
|
||||
});
|
||||
});
|
||||
|
||||
// setting.addButton((cb) => {
|
||||
// cb.setIcon('trash-2');
|
||||
// cb.setTooltip('Delete pattern');
|
||||
// cb.onClick(() => {
|
||||
// deletePattern(plugin, pattern);
|
||||
// setting.clear();
|
||||
// setting.settingEl.remove();
|
||||
// });
|
||||
// });
|
||||
// }
|
||||
setting.addButton((cb) => {
|
||||
cb.setIcon('trash-2');
|
||||
cb.setTooltip('Delete pattern');
|
||||
cb.onClick(() => {
|
||||
deletePattern(plugin, pattern);
|
||||
setting.clear();
|
||||
setting.settingEl.remove();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
@ -66,7 +66,6 @@ export default class ExcludedFolderSettings extends Modal {
|
|||
})
|
||||
);
|
||||
|
||||
|
||||
new Setting(contentEl)
|
||||
.setName('Disable open folder note')
|
||||
.setDesc('Choose if the folder note should be opened when the folder is opened')
|
||||
|
|
|
|||
|
|
@ -1,104 +1,102 @@
|
|||
export {}
|
||||
// import { App, Modal, Setting } from 'obsidian';
|
||||
// import FolderNotesPlugin from '../../main';
|
||||
// import { ExcludedFolder } from 'src/ExcludeFolders/ExcludeFolder';
|
||||
// import { WhitelistedFolder } from '../WhitelistFolder';
|
||||
// export default class ExcludedFolderSettings extends Modal {
|
||||
// plugin: FolderNotesPlugin;
|
||||
// app: App;
|
||||
// excludedFolder: WhitelistedFolder;
|
||||
// constructor(app: App, plugin: FolderNotesPlugin, excludedFolder: WhitelistedFolder) {
|
||||
// super(app);
|
||||
// this.plugin = plugin;
|
||||
// this.app = app;
|
||||
// this.excludedFolder = excludedFolder;
|
||||
// }
|
||||
// onOpen() {
|
||||
// this.display();
|
||||
// }
|
||||
// display() {
|
||||
// const { contentEl } = this;
|
||||
// contentEl.empty();
|
||||
// contentEl.createEl('h2', { text: 'Excluded folder settings' });
|
||||
// new Setting(contentEl)
|
||||
// .setName('Include subfolders')
|
||||
// .setDesc('Choose if the subfolders of the folder should also be whitelisted')
|
||||
// .addToggle((toggle) =>
|
||||
// toggle
|
||||
// .setValue(this.excludedFolder.subFolders)
|
||||
// .onChange(async (value) => {
|
||||
// this.excludedFolder.subFolders = value;
|
||||
// await this.plugin.saveSettings();
|
||||
// })
|
||||
// );
|
||||
import { App, Modal, Setting } from 'obsidian';
|
||||
import FolderNotesPlugin from '../../main';
|
||||
import { WhitelistedFolder } from '../WhitelistFolder';
|
||||
export default class WhitelistFolderSettings extends Modal {
|
||||
plugin: FolderNotesPlugin;
|
||||
app: App;
|
||||
whitelistedFolder: WhitelistedFolder;
|
||||
constructor(app: App, plugin: FolderNotesPlugin, whitelistedFolder: WhitelistedFolder) {
|
||||
super(app);
|
||||
this.plugin = plugin;
|
||||
this.app = app;
|
||||
this.whitelistedFolder = whitelistedFolder;
|
||||
}
|
||||
onOpen() {
|
||||
this.display();
|
||||
}
|
||||
display() {
|
||||
const { contentEl } = this;
|
||||
contentEl.empty();
|
||||
contentEl.createEl('h2', { text: 'Excluded folder settings' });
|
||||
new Setting(contentEl)
|
||||
.setName('Include subfolders')
|
||||
.setDesc('Choose if the subfolders of the folder should also be whitelisted')
|
||||
.addToggle((toggle) =>
|
||||
toggle
|
||||
.setValue(this.whitelistedFolder.subFolders)
|
||||
.onChange(async (value) => {
|
||||
this.whitelistedFolder.subFolders = value;
|
||||
await this.plugin.saveSettings(true);
|
||||
})
|
||||
);
|
||||
|
||||
// new Setting(contentEl)
|
||||
// .setName('Disable folder name sync')
|
||||
// .setDesc('Choose if the folder note should be renamed when the folder name is changed')
|
||||
// .addToggle((toggle) =>
|
||||
// toggle
|
||||
// .setValue(this.excludedFolder.disableSync)
|
||||
// .onChange(async (value) => {
|
||||
// this.excludedFolder.disableSync = value;
|
||||
// await this.plugin.saveSettings();
|
||||
// })
|
||||
// );
|
||||
new Setting(contentEl)
|
||||
.setName('Enable folder name sync')
|
||||
.setDesc('Choose if the name of a folder note should be renamed when the folder name is changed')
|
||||
.addToggle((toggle) =>
|
||||
toggle
|
||||
.setValue(this.whitelistedFolder.enableSync)
|
||||
.onChange(async (value) => {
|
||||
this.whitelistedFolder.enableSync = value;
|
||||
await this.plugin.saveSettings();
|
||||
})
|
||||
);
|
||||
|
||||
// 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('Don\'t show folder in folder overview')
|
||||
.setDesc('Choose if the folder should be shown in the folder overview')
|
||||
.addToggle((toggle) =>
|
||||
toggle
|
||||
.setValue(this.whitelistedFolder.showInFolderOverview)
|
||||
.onChange(async (value) => {
|
||||
this.whitelistedFolder.showInFolderOverview = 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')
|
||||
// .addToggle((toggle) =>
|
||||
// toggle
|
||||
// .setValue(this.excludedFolder.disableAutoCreate)
|
||||
// .onChange(async (value) => {
|
||||
// this.excludedFolder.disableAutoCreate = value;
|
||||
// await this.plugin.saveSettings();
|
||||
// })
|
||||
// );
|
||||
new Setting(contentEl)
|
||||
.setName('Allow auto creation of folder notes in this folder')
|
||||
.setDesc('Choose if a folder note should be created when a new folder is created')
|
||||
.addToggle((toggle) =>
|
||||
toggle
|
||||
.setValue(this.whitelistedFolder.enableAutoCreate)
|
||||
.onChange(async (value) => {
|
||||
this.whitelistedFolder.enableAutoCreate = value;
|
||||
await this.plugin.saveSettings();
|
||||
})
|
||||
);
|
||||
|
||||
|
||||
// new Setting(contentEl)
|
||||
// .setName('Disable open folder note')
|
||||
// .setDesc('Choose if the folder note should be opened when the folder is opened')
|
||||
// .addToggle((toggle) =>
|
||||
// toggle
|
||||
// .setValue(this.excludedFolder.disableFolderNote)
|
||||
// .onChange(async (value) => {
|
||||
// this.excludedFolder.disableFolderNote = value;
|
||||
// await this.plugin.saveSettings();
|
||||
// this.display();
|
||||
// })
|
||||
// );
|
||||
new Setting(contentEl)
|
||||
.setName('Enable open folder note')
|
||||
.setDesc('Choose if the folder note should be opened when the folder is opened')
|
||||
.addToggle((toggle) =>
|
||||
toggle
|
||||
.setValue(this.whitelistedFolder.enableFolderNote)
|
||||
.onChange(async (value) => {
|
||||
this.whitelistedFolder.enableFolderNote = value;
|
||||
await this.plugin.saveSettings(true);
|
||||
this.display();
|
||||
})
|
||||
);
|
||||
|
||||
// if (!this.excludedFolder.disableFolderNote) {
|
||||
// new Setting(contentEl)
|
||||
// .setName('Collapse folder when opening folder note')
|
||||
// .setDesc('Choose if the folder should be collapsed when the folder note is opened')
|
||||
// .addToggle((toggle) =>
|
||||
// toggle
|
||||
// .setValue(this.excludedFolder.enableCollapsing)
|
||||
// .onChange(async (value) => {
|
||||
// this.excludedFolder.enableCollapsing = value;
|
||||
// await this.plugin.saveSettings();
|
||||
// })
|
||||
// );
|
||||
// }
|
||||
if (this.whitelistedFolder.enableFolderNote) {
|
||||
new Setting(contentEl)
|
||||
.setName('Collapse folder when opening folder note')
|
||||
.setDesc('Choose if the folder should be collapsed when the folder note is opened')
|
||||
.addToggle((toggle) =>
|
||||
toggle
|
||||
.setValue(this.whitelistedFolder.enableCollapsing)
|
||||
.onChange(async (value) => {
|
||||
this.whitelistedFolder.enableCollapsing = value;
|
||||
await this.plugin.saveSettings();
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
// }
|
||||
// onClose() {
|
||||
// const { contentEl } = this;
|
||||
// contentEl.empty();
|
||||
// }
|
||||
// }
|
||||
}
|
||||
onClose() {
|
||||
const { contentEl } = this;
|
||||
contentEl.empty();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,47 +0,0 @@
|
|||
export {}
|
||||
// import { App, ButtonComponent, Modal, Setting, TFolder, Notice } from 'obsidian';
|
||||
// import { SettingsTab } from 'src/settings/SettingsTab';
|
||||
// import FolderNotesPlugin from '../../main';
|
||||
// import { WhitelistedFolder } from '../WhitelistFolder';
|
||||
// export default class ExcludedFoldersWhitelist extends Modal {
|
||||
// plugin: FolderNotesPlugin;
|
||||
// app: App;
|
||||
// settingsTab: SettingsTab;
|
||||
// constructor(app: App, plugin: FolderNotesPlugin) {
|
||||
// super(app);
|
||||
// this.plugin = plugin;
|
||||
// this.settingsTab = plugin.settingsTab
|
||||
// }
|
||||
// onOpen() {
|
||||
|
||||
// const { contentEl } = this;
|
||||
// contentEl.createEl('h2', { text: 'Manage whitelisted folders' });
|
||||
|
||||
// new Setting(contentEl)
|
||||
// .setName('Add excluded folder')
|
||||
// .setClass('add-exclude-folder-item')
|
||||
// .addButton((cb) => {
|
||||
// cb.setIcon('plus');
|
||||
// cb.setClass('add-exclude-folder');
|
||||
// cb.setTooltip('Add whitelisted folder');
|
||||
// cb.onClick(() => {
|
||||
// const whitelistedFolder = new WhitelistedFolder('', this.plugin.settings.whitelistFolders.length, this.plugin);
|
||||
// addWhitelistFolderListItem(this.plugin.settingsTab, contentEl, whitelistedFolder);
|
||||
// addWhitelistedFolder(this.plugin, whitelistedFolder);
|
||||
// this.settingsTab.display();
|
||||
// });
|
||||
// });
|
||||
// this.plugin.settings.whitelistFolders.sort((a, b) => a.position - b.position).forEach((whitelistedFolder) => {
|
||||
// if (whitelistedFolder.string?.trim() !== '' && whitelistedFolder.path?.trim() === '') {
|
||||
// addWhitelistPatternListItem(this.settingsTab, contentEl, whitelistedFolder);
|
||||
// } else {
|
||||
// addExcludeFolderListItem(this.settingsTab, contentEl, whitelistedFolder);
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
|
||||
// onClose() {
|
||||
// const { contentEl } = this;
|
||||
// contentEl.empty();
|
||||
// }
|
||||
// }
|
||||
|
|
@ -1 +1,91 @@
|
|||
export {}
|
||||
import { App, Modal, Setting } from 'obsidian';
|
||||
import FolderNotesPlugin from '../../main';
|
||||
import { WhitelistedPattern } from '../WhitelistPattern';
|
||||
|
||||
export default class WhitelistPatternSettings extends Modal {
|
||||
plugin: FolderNotesPlugin;
|
||||
app: App;
|
||||
pattern: WhitelistedPattern;
|
||||
constructor(app: App, plugin: FolderNotesPlugin, pattern: WhitelistedPattern) {
|
||||
super(app);
|
||||
this.plugin = plugin;
|
||||
this.app = app;
|
||||
this.pattern = pattern;
|
||||
}
|
||||
onOpen() {
|
||||
this.display();
|
||||
}
|
||||
display() {
|
||||
const { contentEl } = this;
|
||||
contentEl.empty();
|
||||
contentEl.createEl('h2', { text: 'Pattern settings' });
|
||||
new Setting(contentEl)
|
||||
.setName('Enable folder name sync')
|
||||
.setDesc('Choose if the name of a folder note should be renamed when the folder name is changed')
|
||||
.addToggle((toggle) =>
|
||||
toggle
|
||||
.setValue(this.pattern.enableSync)
|
||||
.onChange(async (value) => {
|
||||
this.pattern.enableSync = value;
|
||||
await this.plugin.saveSettings();
|
||||
})
|
||||
);
|
||||
|
||||
new Setting(contentEl)
|
||||
.setName('Allow auto creation of folder notes in this folder')
|
||||
.setDesc('Choose if a folder note should be created when a new folder is created that matches this pattern')
|
||||
.addToggle((toggle) =>
|
||||
toggle
|
||||
.setValue(this.pattern.enableAutoCreate)
|
||||
.onChange(async (value) => {
|
||||
this.pattern.enableAutoCreate = value;
|
||||
await this.plugin.saveSettings();
|
||||
})
|
||||
);
|
||||
|
||||
new Setting(contentEl)
|
||||
.setName('Show folder in folder overview')
|
||||
.setDesc('Choose if the folder should be shown in the folder overview')
|
||||
.addToggle((toggle) =>
|
||||
toggle
|
||||
.setValue(this.pattern.showInFolderOverview)
|
||||
.onChange(async (value) => {
|
||||
this.pattern.showInFolderOverview = value;
|
||||
await this.plugin.saveSettings();
|
||||
})
|
||||
);
|
||||
|
||||
|
||||
new Setting(contentEl)
|
||||
.setName('Open folder note when clicking on folder')
|
||||
.setDesc('Choose if the folder note should be opened when you click on the folder')
|
||||
.addToggle((toggle) =>
|
||||
toggle
|
||||
.setValue(this.pattern.enableFolderNote)
|
||||
.onChange(async (value) => {
|
||||
this.pattern.enableFolderNote = value;
|
||||
await this.plugin.saveSettings(true);
|
||||
this.display();
|
||||
})
|
||||
);
|
||||
|
||||
if (this.pattern.enableFolderNote) {
|
||||
new Setting(contentEl)
|
||||
.setName('Collapse folder when opening folder note')
|
||||
.setDesc('Choose if the folder should be collapsed when the folder note is opened')
|
||||
.addToggle((toggle) =>
|
||||
toggle
|
||||
.setValue(this.pattern.enableCollapsing)
|
||||
.onChange(async (value) => {
|
||||
this.pattern.enableCollapsing = value;
|
||||
await this.plugin.saveSettings();
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
onClose() {
|
||||
const { contentEl } = this;
|
||||
contentEl.empty();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
50
src/ExcludeFolders/modals/WhitelistedFoldersSettings.ts
Normal file
50
src/ExcludeFolders/modals/WhitelistedFoldersSettings.ts
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
import { App, ButtonComponent, Modal, Setting, TFolder, Notice } from 'obsidian';
|
||||
import { SettingsTab } from 'src/settings/SettingsTab';
|
||||
import FolderNotesPlugin from '../../main';
|
||||
import { WhitelistedFolder } from '../WhitelistFolder';
|
||||
import { addWhitelistFolderListItem, addWhitelistedFolder } from '../functions/whitelistFolderFunctions';
|
||||
import { addWhitelistedPatternListItem } from '../functions/whitelistPatternFunctions';
|
||||
|
||||
export default class WhitelistedFoldersSettings extends Modal {
|
||||
plugin: FolderNotesPlugin;
|
||||
app: App;
|
||||
settingsTab: SettingsTab;
|
||||
constructor(settingsTab: SettingsTab) {
|
||||
super(app);
|
||||
this.plugin = settingsTab.plugin;
|
||||
this.settingsTab = settingsTab;
|
||||
this.app = settingsTab.app;
|
||||
}
|
||||
onOpen() {
|
||||
|
||||
const { contentEl } = this;
|
||||
contentEl.createEl('h2', { text: 'Manage whitelisted folders' });
|
||||
|
||||
new Setting(contentEl)
|
||||
.setName('Add whitelisted folder')
|
||||
.setClass('add-exclude-folder-item')
|
||||
.addButton((cb) => {
|
||||
cb.setIcon('plus');
|
||||
cb.setClass('add-exclude-folder');
|
||||
cb.setTooltip('Add whitelisted folder');
|
||||
cb.onClick(() => {
|
||||
const whitelistedFolder = new WhitelistedFolder('', this.plugin.settings.whitelistFolders.length, undefined, this.plugin);
|
||||
addWhitelistFolderListItem(this.plugin.settingsTab, contentEl, whitelistedFolder);
|
||||
addWhitelistedFolder(this.plugin, whitelistedFolder);
|
||||
this.settingsTab.display();
|
||||
});
|
||||
});
|
||||
this.plugin.settings.whitelistFolders.sort((a, b) => a.position - b.position).forEach((whitelistedFolder) => {
|
||||
if (whitelistedFolder.string?.trim() !== '' && whitelistedFolder.path?.trim() === '') {
|
||||
addWhitelistedPatternListItem(this.settingsTab, contentEl, whitelistedFolder);
|
||||
} else {
|
||||
addWhitelistFolderListItem(this.settingsTab, contentEl, whitelistedFolder);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
onClose() {
|
||||
const { contentEl } = this;
|
||||
contentEl.empty();
|
||||
}
|
||||
}
|
||||
|
|
@ -246,7 +246,6 @@ export default class FolderNotesPlugin extends Plugin {
|
|||
if (this.fmtpHandler) {
|
||||
this.fmtpHandler.deleteEvent();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
async loadSettings() {
|
||||
|
|
@ -260,7 +259,7 @@ export default class FolderNotesPlugin extends Plugin {
|
|||
delete data.allowWhitespaceCollapsing;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
this.settings = Object.assign({}, DEFAULT_SETTINGS, data);
|
||||
if (!data) { return; }
|
||||
const overview = (data as any).defaultOverview;
|
||||
|
|
|
|||
|
|
@ -1,10 +1,11 @@
|
|||
import { addExcludeFolderListItem, addExcludedFolder} from 'src/ExcludeFolders/functions/folderFunctions';
|
||||
import { addExcludeFolderListItem, addExcludedFolder } from 'src/ExcludeFolders/functions/folderFunctions';
|
||||
import { ExcludedFolder } from 'src/ExcludeFolders/ExcludeFolder';
|
||||
import { addExcludePatternListItem } from 'src/ExcludeFolders/functions/patternFunctions';
|
||||
import { Setting } from 'obsidian';
|
||||
import { SettingsTab } from "./SettingsTab";
|
||||
import ExcludedFolderSettings from 'src/ExcludeFolders/modals/ExcludeFolderSettings';
|
||||
import PatternSettings from 'src/ExcludeFolders/modals/PatternSettings';
|
||||
import WhitelistedFoldersSettings from 'src/ExcludeFolders/modals/WhitelistedFoldersSettings';
|
||||
// import ExcludedFoldersWhitelist from 'src/ExcludeFolders/modals/WhitelistModal';
|
||||
|
||||
export async function renderExcludeFolders(settingsTab: SettingsTab) {
|
||||
|
|
@ -29,17 +30,17 @@ export async function renderExcludeFolders(settingsTab: SettingsTab) {
|
|||
manageExcluded.infoEl.appendText('If you want to switch to a folder path delete the pattern first.');
|
||||
manageExcluded.infoEl.style.color = settingsTab.app.vault.getConfig('accentColor') as string || '#7d5bed';
|
||||
|
||||
// ***Soon***
|
||||
// new Setting(containerEl)
|
||||
// .setName('Whitelisted folders')
|
||||
// .setDesc('Folders that will override the excluded folders/patterns')
|
||||
// .addButton((cb) => {
|
||||
// cb.setButtonText('Manage')
|
||||
// cb.setCta()
|
||||
// cb.onClick(async () => {
|
||||
// new ExcludedFoldersWhitelist(settingsTab.app, settingsTab.plugin).open();
|
||||
// })
|
||||
// })
|
||||
|
||||
new Setting(containerEl)
|
||||
.setName('Whitelisted folders')
|
||||
.setDesc('Folders that override the excluded folders/patterns')
|
||||
.addButton((cb) => {
|
||||
cb.setButtonText('Manage')
|
||||
cb.setCta()
|
||||
cb.onClick(async () => {
|
||||
new WhitelistedFoldersSettings(settingsTab).open();
|
||||
})
|
||||
})
|
||||
|
||||
new Setting(containerEl)
|
||||
.setName('Exclude folder default settings')
|
||||
|
|
@ -70,12 +71,13 @@ export async function renderExcludeFolders(settingsTab: SettingsTab) {
|
|||
cb.setClass('add-exclude-folder');
|
||||
cb.setTooltip('Add excluded folder');
|
||||
cb.onClick(() => {
|
||||
const excludedFolder = new ExcludedFolder('', settingsTab.plugin.settings.excludeFolders.length, settingsTab.plugin);
|
||||
const excludedFolder = new ExcludedFolder('', settingsTab.plugin.settings.excludeFolders.length, undefined, settingsTab.plugin);
|
||||
addExcludeFolderListItem(settingsTab, containerEl, excludedFolder);
|
||||
addExcludedFolder(settingsTab.plugin, excludedFolder);
|
||||
settingsTab.display();
|
||||
});
|
||||
});
|
||||
|
||||
settingsTab.plugin.settings.excludeFolders.sort((a, b) => a.position - b.position).forEach((excludedFolder) => {
|
||||
if (excludedFolder.string?.trim() !== '' && excludedFolder.path?.trim() === '') {
|
||||
addExcludePatternListItem(settingsTab, containerEl, excludedFolder);
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ export class FolderSuggest extends TextInputSuggest<TFolder> {
|
|||
constructor(
|
||||
public inputEl: HTMLInputElement,
|
||||
private plugin: FolderNotesPlugin,
|
||||
private whitelistSuggester: boolean,
|
||||
public folder?: TFolder,
|
||||
) {
|
||||
super(inputEl);
|
||||
|
|
@ -40,7 +41,7 @@ export class FolderSuggest extends TextInputSuggest<TFolder> {
|
|||
if (
|
||||
folder instanceof TFolder &&
|
||||
folder.path.toLowerCase().contains(lower_input_str) &&
|
||||
!this.plugin.settings.excludeFolders.find((f) => f.path === folder.path)
|
||||
(!this.plugin.settings.excludeFolders.find((f) => f.path === folder.path) || this.whitelistSuggester)
|
||||
) {
|
||||
folders.push(folder);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue