| 16 | } |
| 17 | |
| 18 | export class TaskNotesSettingTab extends PluginSettingTab { |
| 19 | plugin: TaskNotesPlugin; |
| 20 | private activeTab = "general"; |
| 21 | private tabContents: Record<string, HTMLElement> = {}; |
| 22 | private debouncedSave: DebouncedFunction<() => Promise<void>> = debounce( |
| 23 | () => this.plugin.saveSettings(), |
| 24 | 500 |
| 25 | ); |
| 26 | |
| 27 | constructor(app: App, plugin: TaskNotesPlugin) { |
| 28 | super(app, plugin); |
| 29 | this.plugin = plugin; |
| 30 | |
| 31 | // Set icon for settings sidebar (Obsidian 1.11.0+) |
| 32 | if (requireApiVersion("1.11.0")) { |
| 33 | this.icon = "tasknotes-simple"; |
| 34 | } |
| 35 | |
| 36 | this.plugin.registerEvent( |
| 37 | this.plugin.i18n.on("locale-changed", () => { |
| 38 | if (this.containerEl.isConnected) { |
| 39 | this.display(); |
| 40 | } |
| 41 | }) |
| 42 | ); |
| 43 | } |
| 44 | |
| 45 | display(): void { |
| 46 | const { containerEl } = this; |
| 47 | containerEl.empty(); |
| 48 | containerEl.addClass("tasknotes-settings"); |
| 49 | containerEl.addClass("tasknotes-plugin"); |
| 50 | containerEl.addClass("settings-view"); |
| 51 | |
| 52 | const translate = (key: TranslationKey) => this.plugin.i18n.translate(key); |
| 53 | |
| 54 | const settingsToolbar = containerEl.createDiv("settings-view__toolbar"); |
| 55 | const tabNav = settingsToolbar.createDiv("settings-tab-nav settings-view__tab-nav"); |
| 56 | |
| 57 | // Define the 6-tab structure (defaults merged into task-properties) |
| 58 | const allTabs: TabConfig[] = [ |
| 59 | { |
| 60 | id: "general", |
| 61 | nameKey: "settings.tabs.general", |
| 62 | renderFn: renderGeneralTab, |
| 63 | }, |
| 64 | { |
| 65 | id: "task-properties", |
| 66 | nameKey: "settings.tabs.taskProperties", |
| 67 | renderFn: renderTaskPropertiesTab, |
| 68 | }, |
| 69 | { |
| 70 | id: "modal-fields", |
| 71 | nameKey: "settings.tabs.modalFields", |
| 72 | renderFn: renderModalFieldsTab, |
| 73 | }, |
| 74 | { |
| 75 | id: "appearance", |
nothing calls this directly
no test coverage detected