Skip to content

Offline, privacy-first grammar checker. Fast, open-source, Rust-powered

feat(obsidian-plugin): added rule descriptions to settings page

Elijah Pottere4fbe7330009
diff --git a/packages/obsidian-plugin/src/HarperSettingTab.js b/packages/obsidian-plugin/src/HarperSettingTab.js
index 7c4ebc0b9..ebf18d1dd 100644
--- a/packages/obsidian-plugin/src/HarperSettingTab.js
+++ b/packages/obsidian-plugin/src/HarperSettingTab.js
@@ -10,12 +10,16 @@ export class HarperSettingTab extends PluginSettingTab {
/** @type Record<string, any> */
settings;
+ /** @type Record<string, string> */
+ descriptions;
+
/** @param {App} app
* @param {HarperPlugin} plugin */
constructor(app, plugin) {
super(app, plugin);
this.plugin = plugin;
+ this.updateDescriptions();
this.updateSettings();
}
@@ -23,6 +27,10 @@ export class HarperSettingTab extends PluginSettingTab {
this.plugin.getSettings().then((v) => (this.settings = v));
}
+ updateDescriptions() {
+ this.plugin.getDescriptions().then((v) => (this.descriptions = v));
+ }
+
display() {
const { containerEl } = this;
containerEl.empty();
@@ -31,10 +39,11 @@ export class HarperSettingTab extends PluginSettingTab {
for (let setting of Object.keys(this.settings.lintSettings)) {
let value = this.settings.lintSettings[setting];
+ let description = this.descriptions[setting];
new Setting(containerEl)
.setName(startCase(setting))
- .setDesc(`Whether to include the ${setting} grammar rule.`)
+ .setDesc(description)
.addDropdown((dropdown) =>
dropdown
.addOption('default', 'Default')
diff --git a/packages/obsidian-plugin/src/index.js b/packages/obsidian-plugin/src/index.js
index fe9cc9df7..d3c39eef6 100644
--- a/packages/obsidian-plugin/src/index.js
+++ b/packages/obsidian-plugin/src/index.js
@@ -78,6 +78,12 @@ export default class HarperPlugin extends Plugin {
/** @public */
lintSettingModified = false;
+ /** @public
+ * @returns {Promise<Record<string, string>>} */
+ async getDescriptions() {
+ return await harper.getLintDescriptions();
+ }
+
/** @public
* @returns {Promise<Record<string, any>>} */
async getSettings() {