From 31e58642798fc4d276c78e977c03dfe5de83d7a1 Mon Sep 17 00:00:00 2001 From: phibr0 Date: Sat, 14 Aug 2021 10:05:36 +0200 Subject: [PATCH] Add Custom Commands --- manifest.json | 2 +- src/main.ts | 52 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+), 1 deletion(-) diff --git a/manifest.json b/manifest.json index 32bbe14..53c38de 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "id": "customizable-sidebar", "name": "Customizable Sidebar", - "version": "1.1.0", + "version": "1.1.1", "minAppVersion": "0.12.11", "description": "This Plugin allows to add any Command to Obsidian's Sidebar Ribbon.", "author": "phibr0", diff --git a/src/main.ts b/src/main.ts index 7274e7d..f6293fe 100644 --- a/src/main.ts +++ b/src/main.ts @@ -52,5 +52,57 @@ export default class CustomSidebarPlugin extends Plugin { : this.app.commands.executeCommandById("theme:use-dark"); } }); + + this.addCommand({ + id: "close-left-sidebar", + name: "Close left Sidebar", + icon: "feather-minimize", + callback: () => { + //@ts-ignore + if(!this.app.workspace.leftRibbon.containerEl.hasClass("is-collapsed")){ + //@ts-ignore + this.app.workspace.leftRibbon.collapseButtonEl.click(); + } + } + }); + + this.addCommand({ + id: "open-left-sidebar", + name: "Open left Sidebar", + icon: "feather-maximize", + callback: () => { + //@ts-ignore + if(this.app.workspace.leftRibbon.containerEl.hasClass("is-collapsed")){ + //@ts-ignore + this.app.workspace.leftRibbon.collapseButtonEl.click(); + } + } + }); + + this.addCommand({ + id: "close-right-sidebar", + name: "Close right Sidebar", + icon: "feather-minimize", + callback: () => { + //@ts-ignore + if(!this.app.workspace.rightRibbon.containerEl.hasClass("is-collapsed")){ + //@ts-ignore + this.app.workspace.rightRibbon.collapseButtonEl.click(); + } + } + }); + + this.addCommand({ + id: "open-right-sidebar", + name: "Open right Sidebar", + icon: "feather-maximize", + callback: () => { + //@ts-ignore + if(this.app.workspace.rightRibbon.containerEl.hasClass("is-collapsed")){ + //@ts-ignore + this.app.workspace.rightRibbon.collapseButtonEl.click(); + } + } + }); } } \ No newline at end of file