60 lines
1.4 KiB
TypeScript
60 lines
1.4 KiB
TypeScript
import { App, PluginSettingTab, Setting } from "obsidian";
|
||
import type TabPinButtonPlugin from "./main";
|
||
|
||
|
||
export interface TabPinSettings {
|
||
showPinOnlyOnHover: boolean;
|
||
autoPinNewTabs: boolean;
|
||
}
|
||
|
||
|
||
export const DEFAULT_SETTINGS: TabPinSettings = {
|
||
showPinOnlyOnHover: true,
|
||
autoPinNewTabs: false,
|
||
};
|
||
|
||
|
||
export class TabPinSettingTab extends PluginSettingTab {
|
||
plugin: TabPinButtonPlugin;
|
||
|
||
|
||
constructor(app: App, plugin: TabPinButtonPlugin) {
|
||
super(app, plugin);
|
||
this.plugin = plugin;
|
||
}
|
||
|
||
|
||
display(): void {
|
||
const { containerEl } = this;
|
||
containerEl.empty();
|
||
containerEl.createEl("h2", { text: "Tab Pin Button Settings" });
|
||
|
||
|
||
new Setting(containerEl)
|
||
.setName("Show pin only on hover")
|
||
.setDesc("When ON, the pin icon appears on hover; when OFF, it is always visible.")
|
||
.addToggle((toggle) =>
|
||
toggle
|
||
.setValue(this.plugin.settings.showPinOnlyOnHover)
|
||
.onChange(async (v) => {
|
||
this.plugin.settings.showPinOnlyOnHover = v;
|
||
await this.plugin.saveSettings();
|
||
this.plugin.applyHoverStyle();
|
||
})
|
||
);
|
||
|
||
|
||
new Setting(containerEl)
|
||
.setName("Auto‑pin newly opened tabs")
|
||
.setDesc("Automatically pin tabs when they are first created.")
|
||
.addToggle((toggle) =>
|
||
toggle
|
||
.setValue(this.plugin.settings.autoPinNewTabs)
|
||
.onChange(async (v) => {
|
||
this.plugin.settings.autoPinNewTabs = v;
|
||
await this.plugin.saveSettings();
|
||
})
|
||
);
|
||
}
|
||
}
|