Add all file types dropdown option

This commit is contained in:
Lost Paul 2023-07-08 22:41:32 +02:00
parent 3eefeef7fd
commit cd943b3df4
3 changed files with 11 additions and 4 deletions

View file

@ -1,7 +1,7 @@
{
"id": "folder-notes",
"name": "Folder notes",
"version": "1.4.0",
"version": "1.4.1",
"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",

View file

@ -5,7 +5,7 @@ export type yamlSettings = {
title?: string;
disableTitle?: boolean;
depth?: number;
type?: 'folder' | 'markdown' | 'canvas' | 'other' | 'pdf' | 'images' | 'audio' | 'video';
type?: 'folder' | 'markdown' | 'canvas' | 'other' | 'pdf' | 'images' | 'audio' | 'video' | 'all';
includeTypes?: string[];
style?: 'list' | 'grid';
disableFileTag?: boolean;
@ -243,7 +243,7 @@ function addFolderList(plugin: FolderNotesPlugin, list: HTMLUListElement | HTMLL
}
function addFileList(plugin: FolderNotesPlugin, list: HTMLUListElement | HTMLLIElement, pathBlacklist: string[], file: TFile, includeTypes: string[], disableFileTag: boolean) {
if (includeTypes.length > 0) {
if (includeTypes.length > 0 && !includeTypes.includes('all')) {
if (file.extension === 'md' && !includeTypes.includes('markdown')) return;
if (file.extension === 'canvas' && !includeTypes.includes('canvas')) return;
if (file.extension === 'pdf' && !includeTypes.includes('pdf')) return;

View file

@ -76,7 +76,7 @@ export class FolderOverviewSettings extends Modal {
.setValues(this.yaml?.includeTypes || this.plugin.settings.defaultOverview.includeTypes || [])
.addResetButton()
);
if ((this.yaml?.includeTypes?.length || 0) < 8) {
if ((this.yaml?.includeTypes?.length || 0) < 8 && !this.yaml.includeTypes?.includes('all')) {
setting.addDropdown((dropdown) => {
if (!this.yaml.includeTypes) this.yaml.includeTypes = this.plugin.settings.defaultOverview.includeTypes || [];
this.yaml.includeTypes = this.yaml.includeTypes.map((type: string) => type.toLowerCase());
@ -89,6 +89,7 @@ export class FolderOverviewSettings extends Modal {
{ value: 'audio', label: 'Audio' },
{ value: 'video', label: 'Video' },
{ value: 'other', label: 'All other file types' },
{ value: 'all', label: 'All file types' },
];
options.forEach((option) => {
@ -99,6 +100,11 @@ export class FolderOverviewSettings extends Modal {
dropdown.addOption('+', '+');
dropdown.setValue('+');
dropdown.onChange(async (value) => {
if (value === 'all') {
this.yaml.includeTypes = this.yaml.includeTypes?.filter((type: string) => type === 'folder');
// @ts-ignore
list.setValues(this.yaml.includeTypes);
}
// @ts-ignore
await list.addValue(value.toLowerCase());
await this.updateYaml();
@ -177,6 +183,7 @@ export class FolderOverviewSettings extends Modal {
.onChange(async (value) => {
this.yaml.showEmptyFolders = value;
this.yaml.onlyIncludeSubfolders = false;
this.display();
await this.updateYaml();
});
});