mirror of
https://github.com/rordaz/ColorTab.git
synced 2026-07-22 07:48:53 +00:00
release: prepare v1.0.4
This commit is contained in:
parent
6e014792ed
commit
fff95809f5
4 changed files with 6 additions and 108 deletions
104
main.ts
104
main.ts
|
|
@ -376,107 +376,5 @@ class ColorTabSettingTab extends PluginSettingTab {
|
|||
];
|
||||
}
|
||||
|
||||
// Fallback for Obsidian < 1.13.0 (not called when getSettingDefinitions
|
||||
// returns a non-empty array on 1.13.0+).
|
||||
display(): void {
|
||||
const { containerEl } = this;
|
||||
containerEl.empty();
|
||||
|
||||
this.plugin.settings.colors.forEach((entry, index) => {
|
||||
let hexInputEl: HTMLInputElement;
|
||||
let colorPickerEl: HTMLInputElement;
|
||||
let swatchEl: HTMLSpanElement;
|
||||
|
||||
const setting = new Setting(containerEl)
|
||||
.setName(`Color ${index + 1}`)
|
||||
// ── Meaning / name field ──────────────────────────────────
|
||||
.addText((text) => {
|
||||
text.setPlaceholder("Meaning")
|
||||
.setValue(entry.name)
|
||||
.onChange(async (value) => {
|
||||
this.plugin.settings.colors[index].name = value;
|
||||
await this.plugin.saveSettings();
|
||||
});
|
||||
text.inputEl.setCssStyles({ width: "120px" });
|
||||
text.inputEl.setAttribute("aria-label", "Color meaning / name");
|
||||
})
|
||||
// ── Hex code text input ───────────────────────────────────
|
||||
.addText((hex) => {
|
||||
hex.setPlaceholder("#rrggbb")
|
||||
.setValue(entry.color)
|
||||
.onChange(async (value) => {
|
||||
const normalized = value.trim();
|
||||
if (!/^#[0-9a-fA-F]{6}$/.test(normalized)) return;
|
||||
this.plugin.settings.colors[index].color = normalized;
|
||||
await this.plugin.saveSettings();
|
||||
this.plugin.applyAllColors();
|
||||
if (colorPickerEl) colorPickerEl.value = normalized;
|
||||
if (swatchEl) swatchEl.style.backgroundColor = normalized;
|
||||
});
|
||||
hex.inputEl.setCssStyles({ width: "88px", fontFamily: "monospace" });
|
||||
hex.inputEl.setAttribute("aria-label", "Hex color code");
|
||||
hexInputEl = hex.inputEl;
|
||||
})
|
||||
// ── Color picker ──────────────────────────────────────────
|
||||
.addColorPicker((picker) => {
|
||||
picker
|
||||
.setValue(entry.color)
|
||||
.onChange(async (value) => {
|
||||
this.plugin.settings.colors[index].color = value;
|
||||
await this.plugin.saveSettings();
|
||||
this.plugin.applyAllColors();
|
||||
if (hexInputEl) hexInputEl.value = value;
|
||||
if (swatchEl) swatchEl.style.backgroundColor = value;
|
||||
});
|
||||
});
|
||||
|
||||
// Live swatch preview
|
||||
swatchEl = setting.controlEl.createEl("span", {
|
||||
cls: "color-tab-settings-swatch",
|
||||
});
|
||||
swatchEl.style.backgroundColor = entry.color;
|
||||
|
||||
// Grab the native <input type="color"> for cross-sync
|
||||
colorPickerEl = setting.controlEl.querySelector(
|
||||
"input[type=color]"
|
||||
) as HTMLInputElement;
|
||||
|
||||
colorPickerEl?.addEventListener("input", () => {
|
||||
if (hexInputEl) hexInputEl.value = colorPickerEl.value;
|
||||
if (swatchEl) swatchEl.style.backgroundColor = colorPickerEl.value;
|
||||
});
|
||||
});
|
||||
|
||||
new Setting(containerEl)
|
||||
.setName("Auto-pin colored tabs")
|
||||
.setDesc(
|
||||
"When enabled, applying a tab color pins the tab and removing color unpins it."
|
||||
)
|
||||
.addToggle((toggle) => {
|
||||
toggle
|
||||
.setValue(this.plugin.settings.autoPinColoredTabs)
|
||||
.onChange(async (value) => {
|
||||
this.plugin.settings.autoPinColoredTabs = value;
|
||||
await this.plugin.saveSettings();
|
||||
this.plugin.applyAllColors();
|
||||
});
|
||||
});
|
||||
|
||||
new Setting(containerEl)
|
||||
.setName("Reset to defaults")
|
||||
.setDesc("Restore the original pastel color palette.")
|
||||
.addButton((btn) => {
|
||||
btn.setButtonText("Reset")
|
||||
.onClick(async () => {
|
||||
this.plugin.settings.colors = DEFAULT_COLORS.map(
|
||||
(c) => ({ ...c })
|
||||
);
|
||||
this.plugin.settings.autoPinColoredTabs =
|
||||
DEFAULT_SETTINGS.autoPinColoredTabs;
|
||||
await this.plugin.saveSettings();
|
||||
this.plugin.applyAllColors();
|
||||
this.display();
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
{
|
||||
"id": "color-tab",
|
||||
"name": "Color Tab",
|
||||
"version": "1.0.3",
|
||||
"minAppVersion": "1.0.0",
|
||||
"version": "1.0.4",
|
||||
"minAppVersion": "1.13.0",
|
||||
"description": "Colorize open tabs to visually distinguish notes at a glance, using a right-click context menu.",
|
||||
"author": "Rafael Ordaz",
|
||||
"authorUrl": "https://github.com/rordaz",
|
||||
|
|
|
|||
4
package-lock.json
generated
4
package-lock.json
generated
|
|
@ -1,12 +1,12 @@
|
|||
{
|
||||
"name": "color-tab",
|
||||
"version": "1.0.0",
|
||||
"version": "1.0.4",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "color-tab",
|
||||
"version": "1.0.0",
|
||||
"version": "1.0.4",
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"@types/node": "^16.11.6",
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "color-tab",
|
||||
"version": "1.0.3",
|
||||
"version": "1.0.4",
|
||||
"description": "Obsidian plugin to colorize open tabs",
|
||||
"main": "main.js",
|
||||
"scripts": {
|
||||
|
|
|
|||
Loading…
Reference in a new issue