Included file types bug & sort after bug

This commit is contained in:
Lost Paul 2023-08-14 22:19:38 +02:00
parent 23a7e39cb2
commit f235200551
4 changed files with 21 additions and 15 deletions

View file

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

@ -64,7 +64,7 @@ export class FolderOverview {
const root = el.createEl('div', { cls: 'folder-overview' });
const titleEl = root.createEl('h1', { cls: 'folder-overview-title' });
const ul = root.createEl('ul', { cls: 'folder-overview-list' });
if (this.yaml.includeTypes.length === 0) { return; }
if (this.yaml.includeTypes.length === 0) { return this.addEditButton(root); }
let files: TAbstractFile[] = [];
const sourceFile = plugin.app.vault.getAbstractFileByPath(ctx.sourcePath);
if (!sourceFile) return;
@ -106,14 +106,7 @@ export class FolderOverview {
files = this.getAllFiles(files, sourceFolderPath, this.yaml.depth);
}
if (files.length === 0) {
const editButton = root.createEl('button', { cls: 'folder-overview-edit-button' });
editButton.innerText = 'Edit overview';
editButton.addEventListener('click', (e) => {
e.stopImmediatePropagation();
e.preventDefault();
e.stopPropagation();
new FolderOverviewSettings(plugin.app, plugin, this.yaml, ctx, el).open();
}, { capture: true });
this.addEditButton(root)
}
files = this.sortFiles(files, this.yaml, plugin);
@ -124,7 +117,6 @@ export class FolderOverview {
const gridArticle = gridItem.createEl('article', { cls: 'folder-overview-grid-item-article' });
if (file instanceof TFile) {
const fileContent = await plugin.app.vault.read(file);
// skip --- yaml
const descriptionEl = gridArticle.createEl('p', { cls: 'folder-overview-grid-item-description' });
let description = fileContent.split('\n')[0];
if (description.length > 64) {
@ -160,11 +152,24 @@ export class FolderOverview {
});
}
}
if (this.yaml.style !== 'list') { return; }
if (this.yaml.includeTypes.length > 1 && (!this.yaml.showEmptyFolders || this.yaml.onlyIncludeSubfolders)) {
const overviewListEl = el.childNodes[0].childNodes[1];
if (overviewListEl && overviewListEl.childNodes.length === 0) {
this.addEditButton(root);
}
if (this.yaml.includeTypes.length > 1 && (!this.yaml.showEmptyFolders || this.yaml.onlyIncludeSubfolders) && this.yaml.style === 'list') {
this.removeEmptyFolders(ul, 1, this.yaml);
}
}
addEditButton(root: HTMLElement) {
const editButton = root.createEl('button', { cls: 'folder-overview-edit-button' });
editButton.innerText = 'Edit overview';
editButton.addEventListener('click', (e) => {
e.stopImmediatePropagation();
e.preventDefault();
e.stopPropagation();
new FolderOverviewSettings(this.plugin.app, this.plugin, this.yaml, this.ctx, this.el).open();
}, { capture: true });
}
cloneFileExplorerView(plugin: FolderNotesPlugin, ctx: MarkdownPostProcessorContext, root: HTMLElement, yaml: yamlSettings, pathBlacklist: string[]) {
const folder = plugin.getEL(this.yaml.folderPath)
let folderElement = folder?.parentElement;
@ -511,7 +516,7 @@ export function getCodeBlockEndLine(text: string, startLine: number, count = 1)
let line = startLine + 1;
const lines = text.split('\n');
while (line < lines.length) {
if (count > 20) { return -1; }
if (count > 50) { return -1; }
if (lines[line].startsWith('```')) {
return line;
}

View file

@ -29,7 +29,7 @@ export class FolderOverviewSettings extends Modal {
includeTypes: includeTypes.map((type) => type.toLowerCase()) as includeTypes[],
disableFileTag: yaml?.disableFileTag === undefined || yaml?.disableFileTag === null ? plugin.settings.defaultOverview.disableFileTag : yaml?.disableFileTag,
sortBy: yaml?.sortBy || plugin.settings.defaultOverview.sortBy,
sortByAsc: yaml?.sortByAsc || plugin.settings.defaultOverview.sortByAsc,
sortByAsc: yaml?.sortByAsc === undefined || yaml?.sortByAsc === null ? plugin.settings.defaultOverview.sortByAsc : yaml?.sortByAsc,
showEmptyFolders: yaml?.showEmptyFolders === undefined || yaml?.showEmptyFolders === null ? plugin.settings.defaultOverview.showEmptyFolders : yaml?.showEmptyFolders,
onlyIncludeSubfolders: yaml?.onlyIncludeSubfolders === undefined || yaml?.onlyIncludeSubfolders === null ? plugin.settings.defaultOverview.onlyIncludeSubfolders : yaml?.onlyIncludeSubfolders,
storeFolderCondition: yaml?.storeFolderCondition === undefined || yaml?.storeFolderCondition === null ? plugin.settings.defaultOverview.storeFolderCondition : yaml?.storeFolderCondition,

View file

@ -52,6 +52,7 @@ export default class ListComponent {
async addValue(value: string) {
this.values.push(value);
this.addElement(value);
console.log(this.values);
this.modal.yaml.includeTypes = this.values as includeTypes[];
return this;
}