Skip to content

Commit

Permalink
feat(obsidian-plugin): added rule descriptions to settings page
Browse files Browse the repository at this point in the history
  • Loading branch information
elijah-potter committed Dec 31, 2024
1 parent d822782 commit e4fbe73
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
11 changes: 10 additions & 1 deletion packages/obsidian-plugin/src/HarperSettingTab.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,27 @@ 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();
}

updateSettings() {
this.plugin.getSettings().then((v) => (this.settings = v));
}

updateDescriptions() {
this.plugin.getDescriptions().then((v) => (this.descriptions = v));
}

display() {
const { containerEl } = this;
containerEl.empty();
Expand All @@ -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')
Expand Down
6 changes: 6 additions & 0 deletions packages/obsidian-plugin/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down

0 comments on commit e4fbe73

Please sign in to comment.