Add command to cycle the private mode

This improves the ease of use when going keyboard only
This commit is contained in:
Markus Moser 2025-03-13 10:44:04 +01:00
parent a0498c683c
commit 6fdfdf1a0e
No known key found for this signature in database
GPG key ID: AD411FF94FFE07BD

33
main.ts
View file

@ -32,11 +32,7 @@ export default class PrivateModePlugin extends Plugin {
this.statusBar.ariaLabel = "Toggle Private Mode"
this.statusBar.setAttr("data-tooltip-position", "top")
this.statusBar.onClickEvent(() => {
switch (this.currentLevel) {
case Level.HidePrivate: this.currentLevel = Level.RevealOnHover; break;
case Level.RevealOnHover: this.currentLevel = Level.RevealAll; break;
case Level.RevealAll: this.currentLevel = Level.HidePrivate; break;
}
this.cycleCurrentLevel();
this.updateGlobalRevealStyle();
});
this.statusBarSpan = this.statusBar.createSpan( { text: "" });
@ -72,11 +68,38 @@ export default class PrivateModePlugin extends Plugin {
},
});
this.addCommand({
id: "private-mode-cycle",
name: "Cycle #private mode",
hotkeys: [{
modifiers: ['Alt'],
key: "L"
}],
callback: () => {
this.cycleCurrentLevel();
this.updateGlobalRevealStyle();
},
});
this.app.workspace.onLayoutReady(() => {
this.updateGlobalRevealStyle();
});
}
private cycleCurrentLevel() {
switch (this.currentLevel) {
case Level.HidePrivate:
this.currentLevel = Level.RevealOnHover;
break;
case Level.RevealOnHover:
this.currentLevel = Level.RevealAll;
break;
case Level.RevealAll:
this.currentLevel = Level.HidePrivate;
break;
}
}
updateGlobalRevealStyle() {
this.removeAllClasses();
this.setClassToDocumentBody(this.currentLevel);