groldsf_obsidian_check_plugin/src/CheckboxSyncPluginSettingTab.ts

51 lines
2 KiB
TypeScript
Raw Normal View History

2025-03-15 10:29:19 +00:00
import { App, PluginSettingTab, Setting } from "obsidian";
import CheckboxSyncPlugin from "./main";
export class CheckboxSyncPluginSettingTab extends PluginSettingTab {
plugin: CheckboxSyncPlugin;
constructor(app: App, plugin: CheckboxSyncPlugin) {
super(app, plugin);
this.plugin = plugin;
}
display(): void {
const { containerEl } = this;
containerEl.empty();
2025-04-11 15:07:53 +00:00
2025-03-15 10:29:19 +00:00
new Setting(containerEl)
.setName("X-Only Mode")
.setDesc("When enabled, only 'x' marks a task as complete. When disabled, any character except space marks a task as complete")
.addToggle((toggle) =>
toggle
.setValue(this.plugin.settings.xOnlyMode)
.onChange(async (value) => {
2025-04-11 18:09:29 +00:00
await this.plugin.updateSettings(settings => {
2025-04-11 15:07:53 +00:00
settings.xOnlyMode = value;
});
2025-03-15 10:29:19 +00:00
})
);
2025-04-11 18:09:29 +00:00
new Setting(containerEl)
.setName('Update parent checkbox state automatically')
.setDesc('If enabled, the state of a parent checkbox will be automatically updated based on the state of its children (all children checked = parent checked). If disabled, only manually changing a parent will affect its children.')
.addToggle(toggle => toggle
.setValue(this.plugin.settings.enableAutomaticParentState)
.onChange(async (value) => {
await this.plugin.updateSettings(settings => {
settings.enableAutomaticParentState = value;
});
}));
new Setting(containerEl)
.setName('Update child checkbox state automatically')
.setDesc('If enabled, changing the state of a parent checkbox will automatically update the state of all its direct and nested children. If disabled, changing a parent checkbox will not affect its children.')
.addToggle(toggle => toggle
.setValue(this.plugin.settings.enableAutomaticChildState)
.onChange(async (value) => {
await this.plugin.updateSettings(settings => {
settings.enableAutomaticChildState = value;
});
}));
2025-03-15 10:29:19 +00:00
}
}