diff --git a/src/main.ts b/src/main.ts index e9ae182..f485204 100644 --- a/src/main.ts +++ b/src/main.ts @@ -3,9 +3,6 @@ import { BindThemSettings, BindThemSettingTab, DEFAULT_SETTINGS, - DEFAULT_SENTENCE_REGEX, - COMMANDS, - COMMAND_CATEGORIES, createDefaultEnabledCommands } from './settings'; @@ -378,24 +375,24 @@ class GoToLineModal { open(): void { const overlay = document.createElement('div'); overlay.className = 'modal-bg'; - overlay.style.cssText = 'position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); z-index: 1000;'; + overlay.setCssStyles({ position: 'fixed', top: '0', left: '0', width: '100%', height: '100%', background: 'rgba(0,0,0,0.5)', zIndex: '1000' }); - this.modalEl.style.cssText = 'position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); background: var(--background-primary); padding: 20px; border-radius: 8px; z-index: 1001; max-width: 300px;'; + this.modalEl.setCssStyles({ position: 'fixed', top: '50%', left: '50%', transform: 'translate(-50%, -50%)', background: 'var(--background-primary)', padding: '20px', borderRadius: '8px', zIndex: '1001', maxWidth: '300px' }); const title = document.createElement('h2'); title.textContent = 'Go to line'; - title.style.cssText = 'margin-top: 0;'; + title.setCssStyles({ marginTop: '0' }); this.modalEl.appendChild(title); this.inputEl.type = 'number'; this.inputEl.min = '1'; this.inputEl.max = String(this.lineCount); - this.inputEl.style.cssText = 'width: 100%; margin-bottom: 10px; padding: 8px;'; + this.inputEl.setCssStyles({ width: '100%', marginBottom: '10px', padding: '8px' }); this.modalEl.appendChild(this.inputEl); const btn = document.createElement('button'); btn.textContent = 'Go'; - btn.style.cssText = 'padding: 8px 16px;'; + btn.setCssStyles({ padding: '8px 16px' }); btn.onclick = () => { const n = parseInt(this.inputEl.value) - 1; if (n >= 0 && n < this.lineCount) { diff --git a/src/settings.ts b/src/settings.ts index 504c5d9..6617a51 100644 --- a/src/settings.ts +++ b/src/settings.ts @@ -175,7 +175,7 @@ export class BindThemSettingTab extends PluginSettingTab { // Hotkeys link at the top containerEl.createEl('a', { - text: 'Configure keyboard shortcuts for BindThem', + text: 'Configure keyboard shortcuts', cls: 'bindthem-hotkeys-link', attr: { href: '#', @@ -184,11 +184,9 @@ export class BindThemSettingTab extends PluginSettingTab { }, (el) => { el.addEventListener('click', (e) => { e.preventDefault(); - // @ts-ignore - openHotkeys is not in the type definitions - const hotkeysTab = this.app.setting.openTabById('hotkeys'); + const hotkeysTab = (this.app as unknown as { setting: { openTabById: (id: string) => unknown } }).setting.openTabById('hotkeys'); if (hotkeysTab) { - // @ts-ignore - searchComponent is not in the type definitions - hotkeysTab.searchComponent.setValue('BindThem'); + (hotkeysTab as unknown as { searchComponent: { setValue: (v: string) => void } }).searchComponent.setValue('BindThem'); } }); }); @@ -225,18 +223,17 @@ export class BindThemSettingTab extends PluginSettingTab { })); // Commands section header - containerEl.createEl('h2', { text: 'Command Availability' }); - containerEl.createEl('p', { - text: 'Toggle which commands are available in Obsidian. Disabled commands will not appear in the command palette.', - cls: 'bindthem-settings-desc' - }); + new Setting(containerEl) + .setName('Command availability') + .setDesc('Toggle which commands are available in Obsidian. Disabled commands will not appear in the command palette.') + .setHeading(); // Category toggle buttons new Setting(containerEl) - .setName('Enable/Disable All') + .setName('Enable/disable all') .setDesc('Toggle all commands on or off') .addButton(button => button - .setButtonText('Enable All') + .setButtonText('Enable all') .onClick(async () => { for (const cmdId of getAllCommandIds()) { this.plugin.settings.enabledCommands[cmdId] = true; @@ -245,7 +242,7 @@ export class BindThemSettingTab extends PluginSettingTab { this.display(); })) .addButton(button => button - .setButtonText('Disable All') + .setButtonText('Disable all') .setWarning() .onClick(async () => { for (const cmdId of getAllCommandIds()) { @@ -263,7 +260,8 @@ export class BindThemSettingTab extends PluginSettingTab { // About section new Setting(containerEl) .setName('About') - .setDesc('BindThem combines features from obsidian-tweaks, obsidian-editor-shortcuts, heading-toggler, and obsidian-sentence-navigator.') + // eslint-disable-next-line obsidianmd/ui/sentence-case + .setDesc('Combines features from obsidian-tweaks, obsidian-editor-shortcuts, heading-toggler, and obsidian-sentence-navigator.') .setHeading(); } @@ -278,13 +276,12 @@ export class BindThemSettingTab extends PluginSettingTab { // Check if all commands in this category are enabled const allEnabled = commands.every(cmd => this.plugin.settings.enabledCommands[cmd.id] !== false); - const someEnabled = commands.some(cmd => this.plugin.settings.enabledCommands[cmd.id] !== false); // Add toggle all button for this category categorySetting.addToggle(toggle => { toggle .setValue(allEnabled) - .setTooltip(someEnabled && !allEnabled ? 'Some commands disabled - click to enable all' : 'Toggle all commands in category') + .setTooltip('Toggle all commands in this category') .onChange(async (value) => { for (const cmd of commands) { this.plugin.settings.enabledCommands[cmd.id] = value;