From e040d554ecdadef5da57c175a164758bfd98aa94 Mon Sep 17 00:00:00 2001 From: Lost Paul <70213368+LostPaul@users.noreply.github.com> Date: Sat, 12 Aug 2023 18:01:16 +0200 Subject: [PATCH] Rename files and fix one overview bug --- src/excludedFolder.ts | 6 +++--- src/folderOverview/FolderOverview.ts | 15 +++++++++------ src/folderOverview/modalSettings.ts | 6 +++--- src/functions/ListComponent.ts | 2 +- src/functions/folderNoteFunctions.ts | 4 ++-- src/main.ts | 6 +++--- src/settings.ts | 8 ++++---- src/suggesters/FileSuggester.ts | 2 +- src/suggesters/FolderSuggester.ts | 2 +- src/suggesters/templateSuggester.ts | 2 +- 10 files changed, 28 insertions(+), 25 deletions(-) diff --git a/src/excludedFolder.ts b/src/excludedFolder.ts index 690fee1..db731b2 100644 --- a/src/excludedFolder.ts +++ b/src/excludedFolder.ts @@ -1,9 +1,9 @@ import { Setting } from 'obsidian'; import FolderNotesPlugin from './main'; -import ExcludedFolderSettings from './modals/excludeFolderSettings'; +import ExcludedFolderSettings from './modals/ExcludeFolderSettings'; import { FolderSuggest } from './suggesters/FolderSuggester'; -import { SettingsTab } from './settings'; -import PatternSettings from './modals/patternSettings'; +import { SettingsTab } from './Settings'; +import PatternSettings from './modals/PatternSettings'; export class ExcludedFolder { type: string; diff --git a/src/folderOverview/FolderOverview.ts b/src/folderOverview/FolderOverview.ts index ba6c7ce..94336e5 100644 --- a/src/folderOverview/FolderOverview.ts +++ b/src/folderOverview/FolderOverview.ts @@ -1,9 +1,11 @@ import { MarkdownPostProcessorContext, parseYaml, TAbstractFile, TFolder, TFile, stringifyYaml, Notice } from 'obsidian'; import { extractFolderName, getFolderNote } from '../functions/folderNoteFunctions'; import FolderNotesPlugin from '../main'; -import { FolderOverviewSettings } from './modalSettings'; +import { FolderOverviewSettings } from './ModalSettings'; import { getExcludedFolder } from '../excludedFolder'; + export type includeTypes = 'folder' | 'markdown' | 'canvas' | 'other' | 'pdf' | 'images' | 'audio' | 'video' | 'all'; + export type yamlSettings = { folderPath: string; title: string; @@ -18,6 +20,7 @@ export type yamlSettings = { onlyIncludeSubfolders: boolean; storeFolderCondition: boolean; }; + export class FolderOverview { yaml: yamlSettings; plugin: FolderNotesPlugin; @@ -38,16 +41,16 @@ export class FolderOverview { this.yaml = { folderPath: yaml?.folderPath || plugin.getFolderPathFromString(ctx.sourcePath), title: yaml?.title || plugin.settings.defaultOverview.title, - disableTitle: yaml?.disableTitle || plugin.settings.defaultOverview.disableTitle, + disableTitle: yaml?.disableTitle !== undefined && yaml?.disableTitle !== null ? yaml?.disableTitle : plugin.settings.defaultOverview.disableTitle, depth: yaml?.depth || plugin.settings.defaultOverview.depth, style: yaml?.style || 'list', includeTypes: includeTypes.map((type) => type.toLowerCase()) as includeTypes[], - disableFileTag: yaml?.disableFileTag || plugin.settings.defaultOverview.disableFileTag, + disableFileTag: yaml?.disableFileTag !== undefined && yaml?.disableFileTag !== null ? yaml?.disableFileTag : plugin.settings.defaultOverview.disableFileTag, sortBy: yaml?.sortBy || plugin.settings.defaultOverview.sortBy, sortByAsc: yaml?.sortByAsc || plugin.settings.defaultOverview.sortByAsc, - showEmptyFolders: yaml?.showEmptyFolders || plugin.settings.defaultOverview.showEmptyFolders, - onlyIncludeSubfolders: yaml?.onlyIncludeSubfolders || plugin.settings.defaultOverview.onlyIncludeSubfolders, - storeFolderCondition: yaml?.storeFolderCondition || plugin.settings.defaultOverview.storeFolderCondition + showEmptyFolders: yaml?.showEmptyFolders !== undefined && yaml?.showEmptyFolders !== null ? yaml?.showEmptyFolders : plugin.settings.defaultOverview.showEmptyFolders, + onlyIncludeSubfolders: yaml?.onlyIncludeSubfolders !== undefined && yaml?.onlyIncludeSubfolders !== null ? yaml?.onlyIncludeSubfolders : plugin.settings.defaultOverview.onlyIncludeSubfolders, + storeFolderCondition: yaml?.storeFolderCondition !== undefined && yaml?.storeFolderCondition !== null ? yaml?.storeFolderCondition : plugin.settings.defaultOverview.storeFolderCondition, } } create(plugin: FolderNotesPlugin, source: string, el: HTMLElement, ctx: MarkdownPostProcessorContext) { diff --git a/src/folderOverview/modalSettings.ts b/src/folderOverview/modalSettings.ts index 41ffce7..175e5ea 100644 --- a/src/folderOverview/modalSettings.ts +++ b/src/folderOverview/modalSettings.ts @@ -187,7 +187,7 @@ export class FolderOverviewSettings extends Modal { .setDesc('Choose if the file tag should be shown after the file name') .addToggle((toggle) => { toggle - .setValue(this.yaml.disableFileTag || this.plugin.settings.defaultOverview.disableFileTag || false) + .setValue(this.yaml.disableFileTag) .onChange(async (value) => { this.yaml.disableFileTag = value; if (this.defaultSettings) { @@ -255,7 +255,7 @@ export class FolderOverviewSettings extends Modal { .setDesc('Show the names of folders that appear to have no files/folders in the folder overview. That\'s mostly the case when you set the file depth to 1.') .addToggle((toggle) => { toggle - .setValue(this.yaml.showEmptyFolders || this.plugin.settings.defaultOverview.showEmptyFolders || false) + .setValue(this.yaml.showEmptyFolders) .onChange(async (value) => { this.yaml.showEmptyFolders = value; this.yaml.onlyIncludeSubfolders = false; @@ -272,7 +272,7 @@ export class FolderOverviewSettings extends Modal { .setName('Only show first empty subfolders of current folder') .addToggle((toggle) => { toggle - .setValue(this.yaml.onlyIncludeSubfolders || this.plugin.settings.defaultOverview.onlyIncludeSubfolders || false) + .setValue(this.yaml.onlyIncludeSubfolders) .onChange(async (value) => { this.yaml.onlyIncludeSubfolders = value; if (this.defaultSettings) { diff --git a/src/functions/ListComponent.ts b/src/functions/ListComponent.ts index 602087f..cbf5d52 100644 --- a/src/functions/ListComponent.ts +++ b/src/functions/ListComponent.ts @@ -1,5 +1,5 @@ import { Setting } from 'obsidian'; -import { FolderOverviewSettings } from '../folderOverview/modalSettings'; +import { FolderOverviewSettings } from '../folderOverview/ModalSettings'; import { includeTypes } from 'src/folderOverview/FolderOverview'; import { updateYaml } from 'src/folderOverview/FolderOverview'; export default class ListComponent { diff --git a/src/functions/folderNoteFunctions.ts b/src/functions/folderNoteFunctions.ts index d744568..f2022cd 100644 --- a/src/functions/folderNoteFunctions.ts +++ b/src/functions/folderNoteFunctions.ts @@ -1,8 +1,8 @@ import FolderNotesPlugin from '../main'; -import ExistingFolderNoteModal from '../modals/existingNote'; +import ExistingFolderNoteModal from '../modals/ExistingNote'; import { applyTemplate } from '../template'; import { TFolder, TFile, TAbstractFile, Keymap } from 'obsidian'; -import DeleteConfirmationModal from '../modals/deleteConfirmation'; +import DeleteConfirmationModal from '../modals/DeleteConfirmation'; import { addExcludedFolder, deleteExcludedFolder, getExcludedFolder, ExcludedFolder, updateExcludedFolder } from '../excludedFolder'; export async function createFolderNote(plugin: FolderNotesPlugin, folderPath: string, openFile: boolean, useModal?: boolean, existingNote?: TFile) { diff --git a/src/main.ts b/src/main.ts index fb7dadf..2ad7a1b 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,13 +1,13 @@ import { Plugin, TFile, TFolder, TAbstractFile, MarkdownPostProcessorContext, parseYaml, Notice } from 'obsidian'; -import { DEFAULT_SETTINGS, FolderNotesSettings, SettingsTab } from './settings'; +import { DEFAULT_SETTINGS, FolderNotesSettings, SettingsTab } from './Settings'; import { Commands } from './commands'; import { FileExplorerWorkspaceLeaf } from './globals'; import { handleViewHeaderClick, handleFolderClick } from './events/handleClick'; import { handleFileRename, handleFolderRename } from './events/handleRename'; import { createFolderNote, extractFolderName, getFolderNote, getFolder } from './functions/folderNoteFunctions'; import { getExcludedFolder } from './excludedFolder'; -import { FrontMatterTitlePluginHandler } from './events/frontMatterTitle'; -import { FolderOverviewSettings } from './folderOverview/modalSettings'; +import { FrontMatterTitlePluginHandler } from './events/FrontMatterTitle'; +import { FolderOverviewSettings } from './folderOverview/ModalSettings'; import { FolderOverview } from './folderOverview/FolderOverview'; import './functions/ListComponent'; export default class FolderNotesPlugin extends Plugin { diff --git a/src/settings.ts b/src/settings.ts index 77e0d40..e67e7b8 100644 --- a/src/settings.ts +++ b/src/settings.ts @@ -1,12 +1,12 @@ import { App, Notice, Platform, PluginSettingTab, Setting, TFile, TFolder } from 'obsidian'; import FolderNotesPlugin from './main'; -import { TemplateSuggest } from './suggesters/templateSuggester'; +import { TemplateSuggest } from './suggesters/TemplateSuggester'; import { extractFolderName, getFolderNote } from './functions/folderNoteFunctions'; import { addExcludeFolderListItem, ExcludedFolder, addExcludedFolder, ExcludePattern, addExcludePatternListItem } from './excludedFolder'; -import { FrontMatterTitlePluginHandler } from './events/frontMatterTitle'; -import ConfirmationModal from "./modals/confirmCreation"; +import { FrontMatterTitlePluginHandler } from './events/FrontMatterTitle'; +import ConfirmationModal from "./modals/ConfirmCreation"; import { yamlSettings } from './folderOverview/FolderOverview'; -import { FolderOverviewSettings } from './folderOverview/modalSettings'; +import { FolderOverviewSettings } from './folderOverview/ModalSettings'; export interface FolderNotesSettings { syncFolderName: boolean; ctrlKey: boolean; diff --git a/src/suggesters/FileSuggester.ts b/src/suggesters/FileSuggester.ts index 8857bac..6b0c685 100644 --- a/src/suggesters/FileSuggester.ts +++ b/src/suggesters/FileSuggester.ts @@ -1,7 +1,7 @@ // Credits go to Liam's Periodic Notes Plugin: https://github.com/liamcain/obsidian-periodic-notes and https://github.com/SilentVoid13/Templater import { TAbstractFile, TFile } from 'obsidian'; -import { TextInputSuggest } from './suggest'; +import { TextInputSuggest } from './Suggest'; import FolderNotesPlugin from '../main'; export enum FileSuggestMode { TemplateFiles, diff --git a/src/suggesters/FolderSuggester.ts b/src/suggesters/FolderSuggester.ts index cf62d1e..6129fd2 100644 --- a/src/suggesters/FolderSuggester.ts +++ b/src/suggesters/FolderSuggester.ts @@ -1,7 +1,7 @@ // Credits go to Liam's Periodic Notes Plugin: https://github.com/liamcain/obsidian-periodic-notes and https://github.com/SilentVoid13/Templater import { TAbstractFile, TFolder } from 'obsidian'; -import { TextInputSuggest } from './suggest'; +import { TextInputSuggest } from './Suggest'; import FolderNotesPlugin from '../main'; export enum FileSuggestMode { TemplateFiles, diff --git a/src/suggesters/templateSuggester.ts b/src/suggesters/templateSuggester.ts index 92864e0..a32abc3 100644 --- a/src/suggesters/templateSuggester.ts +++ b/src/suggesters/templateSuggester.ts @@ -1,7 +1,7 @@ // Credits go to Liam's Periodic Notes Plugin: https://github.com/liamcain/obsidian-periodic-notes and https://github.com/SilentVoid13/Templater import { TAbstractFile, TFile, TFolder, Vault } from 'obsidian'; -import { TextInputSuggest } from './suggest'; +import { TextInputSuggest } from './Suggest'; import FolderNotesPlugin from '../main'; import { getTemplatePlugins } from 'src/template'; export enum FileSuggestMode {