From 9d81354a650f04b0f61848d18a0ac834b7189b4b Mon Sep 17 00:00:00 2001 From: John Lynn Date: Mon, 30 Sep 2024 20:02:29 -0400 Subject: [PATCH 1/3] make 'add' button consistent --- src/settings/Settings.ts | 41 ++++++++++++++++++---------------------- 1 file changed, 18 insertions(+), 23 deletions(-) diff --git a/src/settings/Settings.ts b/src/settings/Settings.ts index 5200a927..393112bd 100644 --- a/src/settings/Settings.ts +++ b/src/settings/Settings.ts @@ -1,11 +1,10 @@ +import TemplaterPlugin from "main"; import { ButtonComponent, PluginSettingTab, Setting } from "obsidian"; import { errorWrapperSync, TemplaterError } from "utils/Error"; -import { FolderSuggest } from "./suggesters/FolderSuggester"; -import { FileSuggest, FileSuggestMode } from "./suggesters/FileSuggester"; -import TemplaterPlugin from "main"; -import { arraymove, get_tfiles_from_folder } from "utils/Utils"; import { log_error } from "utils/Log"; -import { HEART, PAYPAL } from "utils/Constants"; +import { arraymove, get_tfiles_from_folder } from "utils/Utils"; +import { FileSuggest, FileSuggestMode } from "./suggesters/FileSuggester"; +import { FolderSuggest } from "./suggesters/FolderSuggester"; export interface FolderTemplate { folder: string; @@ -367,24 +366,6 @@ export class TemplaterSettingTab extends PluginSettingTab { return; } - new Setting(this.containerEl) - .setName("Add new") - .setDesc("Add new folder template") - .addButton((button: ButtonComponent) => { - button - .setTooltip("Add additional folder template") - .setButtonText("+") - .setCta() - .onClick(() => { - this.plugin.settings.folder_templates.push({ - folder: "", - template: "", - }); - this.plugin.save_settings(); - this.display(); - }); - }); - this.plugin.settings.folder_templates.forEach( (folder_template, index) => { const s = new Setting(this.containerEl) @@ -473,6 +454,20 @@ export class TemplaterSettingTab extends PluginSettingTab { s.infoEl.remove(); } ); + + new Setting(this.containerEl).addButton((button: ButtonComponent) => { + button.setButtonText("Add new folder template") + .setTooltip("Add additional folder template") + .setCta() + .onClick(() => { + this.plugin.settings.folder_templates.push({ + folder: "", + template: "", + }); + this.plugin.save_settings(); + this.display(); + }); + }); } add_startup_templates_setting(): void { From 7de477ca8ce88a3a626e0b6eb3ba31ebb1691731 Mon Sep 17 00:00:00 2001 From: John Lynn Date: Mon, 30 Sep 2024 20:02:59 -0400 Subject: [PATCH 2/3] remove duplicate folder template header --- src/settings/Settings.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/settings/Settings.ts b/src/settings/Settings.ts index 393112bd..2cff2ec5 100644 --- a/src/settings/Settings.ts +++ b/src/settings/Settings.ts @@ -324,7 +324,6 @@ export class TemplaterSettingTab extends PluginSettingTab { } add_folder_templates_setting(): void { - this.containerEl.createEl("h2", { text: "Folder templates" }); new Setting(this.containerEl).setName("Folder templates").setHeading(); const descHeading = document.createDocumentFragment(); From cbd28cafff80f69f63859c10c278b9dbc768cb86 Mon Sep 17 00:00:00 2001 From: John Lynn Date: Mon, 30 Sep 2024 20:04:06 -0400 Subject: [PATCH 3/3] move folder templates beneath file creation --- src/settings/Settings.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/settings/Settings.ts b/src/settings/Settings.ts index 2cff2ec5..9f07751d 100644 --- a/src/settings/Settings.ts +++ b/src/settings/Settings.ts @@ -58,10 +58,10 @@ export class TemplaterSettingTab extends PluginSettingTab { this.add_syntax_highlighting_settings(); this.add_auto_jump_to_cursor(); this.add_trigger_on_new_file_creation_setting(); - this.add_templates_hotkeys_setting(); if (this.plugin.settings.trigger_on_file_creation) { this.add_folder_templates_setting(); } + this.add_templates_hotkeys_setting(); this.add_startup_templates_setting(); this.add_user_script_functions_setting(); this.add_user_system_command_functions_setting();