From c52269504c0a013bd793284d4b2d754c1a63dbaf Mon Sep 17 00:00:00 2001 From: "Ryan J.A. Murphy" Date: Mon, 16 Nov 2020 14:01:59 -0700 Subject: [PATCH] Added a setting for a default review date. --- main.ts | 27 +++++++++++++++++++++++++-- manifest.json | 2 +- package.json | 2 +- 3 files changed, 27 insertions(+), 4 deletions(-) diff --git a/main.ts b/main.ts index 703056d..a2353c0 100644 --- a/main.ts +++ b/main.ts @@ -50,6 +50,9 @@ export default class Review extends Plugin { return; } + if (someDate === "") { + someDate = this.settings.defaultReviewDate; + } // Use the Natural Language Dates plugin's processDate method to convert the input date into a daily note title. let parsedResult = naturalLanguageDates.parseDate(someDate); let inputDate = parsedResult.formattedString; @@ -122,6 +125,7 @@ class ReviewSettings { dailyNotesFolder = ""; reviewSectionHeading = "## Review"; linePrefix = "- "; + defaultReviewDate = ""; } class ReviewModal extends Modal { @@ -172,7 +176,7 @@ class ReviewSettingTab extends PluginSettingTab { .setDesc('Set the path to your daily notes. Use the format "folder/subfolder". Do not use leading or trailing slashes "/".') .addText((text) => text - .setPlaceholder('†') + .setPlaceholder('') .setValue(plugin.settings.dailyNotesFolder) .onChange((value) => { console.log("The new daily notes folder:" + value); @@ -208,5 +212,24 @@ class ReviewSettingTab extends PluginSettingTab { plugin.saveData(plugin.settings); }) ); - } + new Setting(containerEl) + .setName('Default review date') + .setDesc('Set a default date to be used when no date is entered. Use natural language: "Next Monday", "November 5th", and "tomorrow" all work.') + .addText((text) => + text + .setPlaceholder('') + .setValue(plugin.settings.defaultReviewDate) + .onChange((value) => { + plugin.settings.defaultReviewDate = value; + plugin.saveData(plugin.settings); + }) + ); + + // containerEl.createEl('h3', { text: 'Preset review schedules' }); + + /* + TKTKTK: Figure out how to add a function to a button inside the setting element. Currently `doSomething`, below, throws errors. + containerEl.createEl('button', { text: "Add a new review schedule preset", attr: { onclick: "doSomething({ console.log('button clicked') });"}}); + */ + } } diff --git a/manifest.json b/manifest.json index 8d45f95..f8eb199 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "id": "review-obsidian", "name": "Review", - "version": "1.3.0", + "version": "1.4.0", "description": "Add a link to the current note to a daily note on a future date (or a past date, you time traveller).", "author": "ryanjamurphy", "authorUrl": "https://axle.design", diff --git a/package.json b/package.json index 88dfe85..49ed873 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "review-obsidian", - "version": "1.3.0", + "version": "1.4.0", "description": "Add a link to the current note to a daily note on a future date (or a past date, you time traveller).", "main": "main.js", "repository": "ryanjamurphy/review-obsidian",