mirror of
https://github.com/markusmo3/obsidian-private-mode.git
synced 2026-07-22 05:42:42 +00:00
Add command to cycle the private mode
This improves the ease of use when going keyboard only
This commit is contained in:
parent
a0498c683c
commit
6fdfdf1a0e
1 changed files with 28 additions and 5 deletions
33
main.ts
33
main.ts
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Reference in a new issue