mirror of
https://github.com/rordaz/ColorTab.git
synced 2026-07-22 07:48:53 +00:00
feat: add option to remove all tab colors from context menu
This commit is contained in:
parent
524489ae11
commit
34e78eb25f
1 changed files with 14 additions and 0 deletions
14
main.ts
14
main.ts
|
|
@ -89,6 +89,12 @@ export default class ColorTabPlugin extends Plugin {
|
|||
item.setIcon("x");
|
||||
item.onClick(() => this.removeTabColor(leaf));
|
||||
});
|
||||
|
||||
menu.addItem((item) => {
|
||||
item.setTitle("Remove all tabs' color");
|
||||
item.setIcon("x-circle");
|
||||
item.onClick(() => this.removeAllTabColors());
|
||||
});
|
||||
}
|
||||
|
||||
// ── Color application ─────────────────────────────────────────────────────
|
||||
|
|
@ -111,6 +117,14 @@ export default class ColorTabPlugin extends Plugin {
|
|||
this.applyColorToLeaf(leaf, null);
|
||||
}
|
||||
|
||||
removeAllTabColors() {
|
||||
this.settings.fileColors = {};
|
||||
this.saveSettings();
|
||||
this.app.workspace.iterateAllLeaves((leaf) =>
|
||||
this.applyColorToLeaf(leaf, null)
|
||||
);
|
||||
}
|
||||
|
||||
applyColorToLeaf(leaf: WorkspaceLeaf, color: string | null) {
|
||||
const tabHeader = (
|
||||
leaf as unknown as { tabHeaderEl: HTMLElement }
|
||||
|
|
|
|||
Loading…
Reference in a new issue