Initial commit
This commit is contained in:
59
settings.ts
Normal file
59
settings.ts
Normal file
@@ -0,0 +1,59 @@
|
||||
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();
|
||||
})
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user