Skip to content

Build your personal knowledge base with Trilium Notes

add toggleLeftPane command/shortcut, closes #2225

zadame2c37a6f8c37
diff --git a/src/public/app/services/options.js b/src/public/app/services/options.js
index 587e433aa7..954832eb69 100644
--- a/src/public/app/services/options.js
+++ b/src/public/app/services/options.js
@@ -50,6 +50,10 @@ class Options {
await server.put(`options`, payload);
}
+
+ async toggle(key) {
+ await this.save(key, (!this.is(key)).toString());
+ }
}
const options = new Options();
diff --git a/src/public/app/services/root_command_executor.js b/src/public/app/services/root_command_executor.js
index 804db3b6dd..d3ac6f0491 100644
--- a/src/public/app/services/root_command_executor.js
+++ b/src/public/app/services/root_command_executor.js
@@ -4,6 +4,7 @@ import dateNoteService from "../services/date_notes.js";
import treeService from "../services/tree.js";
import openService from "./open.js";
import protectedSessionService from "./protected_session.js";
+import options from "./options.js";
export default class RootCommandExecutor extends Component {
jumpToNoteCommand() {
@@ -101,4 +102,16 @@ export default class RootCommandExecutor extends Component {
leaveProtectedSessionCommand() {
protectedSessionService.leaveProtectedSession();
}
+
+ hideLeftPaneCommand() {
+ options.save(`leftPaneVisible`, "false");
+ }
+
+ showLeftPaneCommand() {
+ options.save(`leftPaneVisible`, "true");
+ }
+
+ toggleLeftPaneCommand() {
+ options.toggle('leftPaneVisible');
+ }
}
diff --git a/src/public/app/widgets/buttons/left_pane_toggle.js b/src/public/app/widgets/buttons/left_pane_toggle.js
index 896428ce7b..fde0b36823 100644
--- a/src/public/app/widgets/buttons/left_pane_toggle.js
+++ b/src/public/app/widgets/buttons/left_pane_toggle.js
@@ -11,26 +11,18 @@ export default class LeftPaneToggleWidget extends ButtonWidget {
: "bx-chevrons-right";
this.settings.title = isLeftPaneVisible
- ? "Hide sidebar."
- : "Open sidebar.";
+ ? "Hide panel."
+ : "Open panel.";
this.settings.command = isLeftPaneVisible
- ? "hideSidebar"
- : "showSidebar";
+ ? "hideLeftPane"
+ : "showLeftPane";
super.refreshIcon();
splitService.setupLeftPaneResizer(isLeftPaneVisible);
}
- hideSidebarCommand() {
- options.save(`leftPaneVisible`, "false");
- }
-
- showSidebarCommand() {
- options.save(`leftPaneVisible`, "true");
- }
-
entitiesReloadedEvent({loadResults}) {
if (loadResults.isOptionReloaded("leftPaneVisible")) {
this.refreshIcon();
diff --git a/src/services/keyboard_actions.js b/src/services/keyboard_actions.js
index c736e7bead..3f2620e3ce 100644
--- a/src/services/keyboard_actions.js
+++ b/src/services/keyboard_actions.js
@@ -299,6 +299,7 @@ const DEFAULT_KEYBOARD_ACTIONS = [
{
actionName: "insertDateTimeToText",
defaultShortcuts: ["Alt+T"],
+ description: "Insert current date & time into text",
scope: "text-detail"
},
{
@@ -456,11 +457,13 @@ const DEFAULT_KEYBOARD_ACTIONS = [
{
actionName: "reloadFrontendApp",
defaultShortcuts: ["F5", "CommandOrControl+R"],
+ description: "Reload frontend App",
scope: "window"
},
{
actionName: "openDevTools",
defaultShortcuts: isElectron ? ["CommandOrControl+Shift+I"] : [],
+ description: "Open dev tools",
scope: "window"
},
{
@@ -468,24 +471,34 @@ const DEFAULT_KEYBOARD_ACTIONS = [
defaultShortcuts: isElectron ? ["CommandOrControl+F"] : [],
scope: "window"
},
+ {
+ actionName: "toggleLeftPane",
+ defaultShortcuts: [],
+ description: "Toggle left (note tree) panel",
+ scope: "window"
+ },
{
actionName: "toggleFullscreen",
defaultShortcuts: ["F11"],
+ description: "Toggle full screen",
scope: "window"
},
{
actionName: "zoomOut",
defaultShortcuts: isElectron ? ["CommandOrControl+-"] : [],
+ description: "Zoom Out",
scope: "window"
},
{
actionName: "zoomIn",
+ description: "Zoom In",
defaultShortcuts: isElectron ? ["CommandOrControl+="] : [],
scope: "window"
},
{
actionName: "copyWithoutFormatting",
defaultShortcuts: ["CommandOrControl+Alt+C"],
+ description: "Copy selected text without formatting",
scope: "text-detail"
}
];