From 06df987b539cf892bdab6e205cefcf529ffc26f0 Mon Sep 17 00:00:00 2001 From: Hongbo Wu Date: Mon, 22 May 2023 16:11:35 +0800 Subject: [PATCH] fix: add a reset template button to reset the template to default template --- src/main.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/main.ts b/src/main.ts index 811dc0f..7319bf4 100644 --- a/src/main.ts +++ b/src/main.ts @@ -521,7 +521,6 @@ class OmnivoreSettingTab extends PluginSettingTab { .setPlaceholder("Enter the template") .setValue(this.plugin.settings.template) .onChange(async (value) => { - // TODO: validate template // if template is empty, use default template this.plugin.settings.template = value ? value @@ -530,6 +529,17 @@ class OmnivoreSettingTab extends PluginSettingTab { }); text.inputEl.setAttr("rows", 30); text.inputEl.setAttr("cols", 60); + }).addExtraButton((button) => { + // add a button to reset template + button + .setIcon("reset") + .setTooltip("Reset template") + .onClick(async () => { + this.plugin.settings.template = DEFAULT_SETTINGS.template; + await this.plugin.saveSettings(); + this.display(); + new Notice("Template reset"); + }); }); new Setting(generalSettings)