diff --git a/main.ts b/main.ts index e56cd6b..90876cd 100644 --- a/main.ts +++ b/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);