fix problems
This commit is contained in:
13
src/main.ts
13
src/main.ts
@@ -3,9 +3,6 @@ import {
|
|||||||
BindThemSettings,
|
BindThemSettings,
|
||||||
BindThemSettingTab,
|
BindThemSettingTab,
|
||||||
DEFAULT_SETTINGS,
|
DEFAULT_SETTINGS,
|
||||||
DEFAULT_SENTENCE_REGEX,
|
|
||||||
COMMANDS,
|
|
||||||
COMMAND_CATEGORIES,
|
|
||||||
createDefaultEnabledCommands
|
createDefaultEnabledCommands
|
||||||
} from './settings';
|
} from './settings';
|
||||||
|
|
||||||
@@ -378,24 +375,24 @@ class GoToLineModal {
|
|||||||
open(): void {
|
open(): void {
|
||||||
const overlay = document.createElement('div');
|
const overlay = document.createElement('div');
|
||||||
overlay.className = 'modal-bg';
|
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');
|
const title = document.createElement('h2');
|
||||||
title.textContent = 'Go to line';
|
title.textContent = 'Go to line';
|
||||||
title.style.cssText = 'margin-top: 0;';
|
title.setCssStyles({ marginTop: '0' });
|
||||||
this.modalEl.appendChild(title);
|
this.modalEl.appendChild(title);
|
||||||
|
|
||||||
this.inputEl.type = 'number';
|
this.inputEl.type = 'number';
|
||||||
this.inputEl.min = '1';
|
this.inputEl.min = '1';
|
||||||
this.inputEl.max = String(this.lineCount);
|
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);
|
this.modalEl.appendChild(this.inputEl);
|
||||||
|
|
||||||
const btn = document.createElement('button');
|
const btn = document.createElement('button');
|
||||||
btn.textContent = 'Go';
|
btn.textContent = 'Go';
|
||||||
btn.style.cssText = 'padding: 8px 16px;';
|
btn.setCssStyles({ padding: '8px 16px' });
|
||||||
btn.onclick = () => {
|
btn.onclick = () => {
|
||||||
const n = parseInt(this.inputEl.value) - 1;
|
const n = parseInt(this.inputEl.value) - 1;
|
||||||
if (n >= 0 && n < this.lineCount) {
|
if (n >= 0 && n < this.lineCount) {
|
||||||
|
|||||||
@@ -175,7 +175,7 @@ export class BindThemSettingTab extends PluginSettingTab {
|
|||||||
|
|
||||||
// Hotkeys link at the top
|
// Hotkeys link at the top
|
||||||
containerEl.createEl('a', {
|
containerEl.createEl('a', {
|
||||||
text: 'Configure keyboard shortcuts for BindThem',
|
text: 'Configure keyboard shortcuts',
|
||||||
cls: 'bindthem-hotkeys-link',
|
cls: 'bindthem-hotkeys-link',
|
||||||
attr: {
|
attr: {
|
||||||
href: '#',
|
href: '#',
|
||||||
@@ -184,11 +184,9 @@ export class BindThemSettingTab extends PluginSettingTab {
|
|||||||
}, (el) => {
|
}, (el) => {
|
||||||
el.addEventListener('click', (e) => {
|
el.addEventListener('click', (e) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
// @ts-ignore - openHotkeys is not in the type definitions
|
const hotkeysTab = (this.app as unknown as { setting: { openTabById: (id: string) => unknown } }).setting.openTabById('hotkeys');
|
||||||
const hotkeysTab = this.app.setting.openTabById('hotkeys');
|
|
||||||
if (hotkeysTab) {
|
if (hotkeysTab) {
|
||||||
// @ts-ignore - searchComponent is not in the type definitions
|
(hotkeysTab as unknown as { searchComponent: { setValue: (v: string) => void } }).searchComponent.setValue('BindThem');
|
||||||
hotkeysTab.searchComponent.setValue('BindThem');
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -225,18 +223,17 @@ export class BindThemSettingTab extends PluginSettingTab {
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
// Commands section header
|
// Commands section header
|
||||||
containerEl.createEl('h2', { text: 'Command Availability' });
|
new Setting(containerEl)
|
||||||
containerEl.createEl('p', {
|
.setName('Command availability')
|
||||||
text: 'Toggle which commands are available in Obsidian. Disabled commands will not appear in the command palette.',
|
.setDesc('Toggle which commands are available in Obsidian. Disabled commands will not appear in the command palette.')
|
||||||
cls: 'bindthem-settings-desc'
|
.setHeading();
|
||||||
});
|
|
||||||
|
|
||||||
// Category toggle buttons
|
// Category toggle buttons
|
||||||
new Setting(containerEl)
|
new Setting(containerEl)
|
||||||
.setName('Enable/Disable All')
|
.setName('Enable/disable all')
|
||||||
.setDesc('Toggle all commands on or off')
|
.setDesc('Toggle all commands on or off')
|
||||||
.addButton(button => button
|
.addButton(button => button
|
||||||
.setButtonText('Enable All')
|
.setButtonText('Enable all')
|
||||||
.onClick(async () => {
|
.onClick(async () => {
|
||||||
for (const cmdId of getAllCommandIds()) {
|
for (const cmdId of getAllCommandIds()) {
|
||||||
this.plugin.settings.enabledCommands[cmdId] = true;
|
this.plugin.settings.enabledCommands[cmdId] = true;
|
||||||
@@ -245,7 +242,7 @@ export class BindThemSettingTab extends PluginSettingTab {
|
|||||||
this.display();
|
this.display();
|
||||||
}))
|
}))
|
||||||
.addButton(button => button
|
.addButton(button => button
|
||||||
.setButtonText('Disable All')
|
.setButtonText('Disable all')
|
||||||
.setWarning()
|
.setWarning()
|
||||||
.onClick(async () => {
|
.onClick(async () => {
|
||||||
for (const cmdId of getAllCommandIds()) {
|
for (const cmdId of getAllCommandIds()) {
|
||||||
@@ -263,7 +260,8 @@ export class BindThemSettingTab extends PluginSettingTab {
|
|||||||
// About section
|
// About section
|
||||||
new Setting(containerEl)
|
new Setting(containerEl)
|
||||||
.setName('About')
|
.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();
|
.setHeading();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -278,13 +276,12 @@ export class BindThemSettingTab extends PluginSettingTab {
|
|||||||
|
|
||||||
// Check if all commands in this category are enabled
|
// Check if all commands in this category are enabled
|
||||||
const allEnabled = commands.every(cmd => this.plugin.settings.enabledCommands[cmd.id] !== false);
|
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
|
// Add toggle all button for this category
|
||||||
categorySetting.addToggle(toggle => {
|
categorySetting.addToggle(toggle => {
|
||||||
toggle
|
toggle
|
||||||
.setValue(allEnabled)
|
.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) => {
|
.onChange(async (value) => {
|
||||||
for (const cmd of commands) {
|
for (const cmd of commands) {
|
||||||
this.plugin.settings.enabledCommands[cmd.id] = value;
|
this.plugin.settings.enabledCommands[cmd.id] = value;
|
||||||
|
|||||||
Reference in New Issue
Block a user