mirror of
				https://github.com/zadam/trilium.git
				synced 2025-11-04 05:28:59 +01:00 
			
		
		
		
	add toggleLeftPane command/shortcut, closes #2225
This commit is contained in:
		
							parent
							
								
									23e34e8c02
								
							
						
					
					
						commit
						e2c37a6f8c
					
				@ -50,6 +50,10 @@ class Options {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        await server.put(`options`, payload);
 | 
					        await server.put(`options`, payload);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    async toggle(key) {
 | 
				
			||||||
 | 
					        await this.save(key, (!this.is(key)).toString());
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const options = new Options();
 | 
					const options = new Options();
 | 
				
			||||||
 | 
				
			|||||||
@ -4,6 +4,7 @@ import dateNoteService from "../services/date_notes.js";
 | 
				
			|||||||
import treeService from "../services/tree.js";
 | 
					import treeService from "../services/tree.js";
 | 
				
			||||||
import openService from "./open.js";
 | 
					import openService from "./open.js";
 | 
				
			||||||
import protectedSessionService from "./protected_session.js";
 | 
					import protectedSessionService from "./protected_session.js";
 | 
				
			||||||
 | 
					import options from "./options.js";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export default class RootCommandExecutor extends Component {
 | 
					export default class RootCommandExecutor extends Component {
 | 
				
			||||||
    jumpToNoteCommand() {
 | 
					    jumpToNoteCommand() {
 | 
				
			||||||
@ -101,4 +102,16 @@ export default class RootCommandExecutor extends Component {
 | 
				
			|||||||
    leaveProtectedSessionCommand() {
 | 
					    leaveProtectedSessionCommand() {
 | 
				
			||||||
        protectedSessionService.leaveProtectedSession();
 | 
					        protectedSessionService.leaveProtectedSession();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    hideLeftPaneCommand() {
 | 
				
			||||||
 | 
					        options.save(`leftPaneVisible`, "false");
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    showLeftPaneCommand() {
 | 
				
			||||||
 | 
					        options.save(`leftPaneVisible`, "true");
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    toggleLeftPaneCommand() {
 | 
				
			||||||
 | 
					        options.toggle('leftPaneVisible');
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -11,26 +11,18 @@ export default class LeftPaneToggleWidget extends ButtonWidget {
 | 
				
			|||||||
            : "bx-chevrons-right";
 | 
					            : "bx-chevrons-right";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        this.settings.title = isLeftPaneVisible
 | 
					        this.settings.title = isLeftPaneVisible
 | 
				
			||||||
            ? "Hide sidebar."
 | 
					            ? "Hide panel."
 | 
				
			||||||
            : "Open sidebar.";
 | 
					            : "Open panel.";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        this.settings.command = isLeftPaneVisible
 | 
					        this.settings.command = isLeftPaneVisible
 | 
				
			||||||
            ? "hideSidebar"
 | 
					            ? "hideLeftPane"
 | 
				
			||||||
            : "showSidebar";
 | 
					            : "showLeftPane";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        super.refreshIcon();
 | 
					        super.refreshIcon();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        splitService.setupLeftPaneResizer(isLeftPaneVisible);
 | 
					        splitService.setupLeftPaneResizer(isLeftPaneVisible);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    hideSidebarCommand() {
 | 
					 | 
				
			||||||
        options.save(`leftPaneVisible`, "false");
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    showSidebarCommand() {
 | 
					 | 
				
			||||||
        options.save(`leftPaneVisible`, "true");
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    entitiesReloadedEvent({loadResults}) {
 | 
					    entitiesReloadedEvent({loadResults}) {
 | 
				
			||||||
        if (loadResults.isOptionReloaded("leftPaneVisible")) {
 | 
					        if (loadResults.isOptionReloaded("leftPaneVisible")) {
 | 
				
			||||||
            this.refreshIcon();
 | 
					            this.refreshIcon();
 | 
				
			||||||
 | 
				
			|||||||
@ -299,6 +299,7 @@ const DEFAULT_KEYBOARD_ACTIONS = [
 | 
				
			|||||||
    {
 | 
					    {
 | 
				
			||||||
        actionName: "insertDateTimeToText",
 | 
					        actionName: "insertDateTimeToText",
 | 
				
			||||||
        defaultShortcuts: ["Alt+T"],
 | 
					        defaultShortcuts: ["Alt+T"],
 | 
				
			||||||
 | 
					        description: "Insert current date & time into text",
 | 
				
			||||||
        scope: "text-detail"
 | 
					        scope: "text-detail"
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
@ -456,11 +457,13 @@ const DEFAULT_KEYBOARD_ACTIONS = [
 | 
				
			|||||||
    {
 | 
					    {
 | 
				
			||||||
        actionName: "reloadFrontendApp",
 | 
					        actionName: "reloadFrontendApp",
 | 
				
			||||||
        defaultShortcuts: ["F5", "CommandOrControl+R"],
 | 
					        defaultShortcuts: ["F5", "CommandOrControl+R"],
 | 
				
			||||||
 | 
					        description: "Reload frontend App",
 | 
				
			||||||
        scope: "window"
 | 
					        scope: "window"
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        actionName: "openDevTools",
 | 
					        actionName: "openDevTools",
 | 
				
			||||||
        defaultShortcuts: isElectron ? ["CommandOrControl+Shift+I"] : [],
 | 
					        defaultShortcuts: isElectron ? ["CommandOrControl+Shift+I"] : [],
 | 
				
			||||||
 | 
					        description: "Open dev tools",
 | 
				
			||||||
        scope: "window"
 | 
					        scope: "window"
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
@ -468,24 +471,34 @@ const DEFAULT_KEYBOARD_ACTIONS = [
 | 
				
			|||||||
        defaultShortcuts: isElectron ? ["CommandOrControl+F"] : [],
 | 
					        defaultShortcuts: isElectron ? ["CommandOrControl+F"] : [],
 | 
				
			||||||
        scope: "window"
 | 
					        scope: "window"
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        actionName: "toggleLeftPane",
 | 
				
			||||||
 | 
					        defaultShortcuts: [],
 | 
				
			||||||
 | 
					        description: "Toggle left (note tree) panel",
 | 
				
			||||||
 | 
					        scope: "window"
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        actionName: "toggleFullscreen",
 | 
					        actionName: "toggleFullscreen",
 | 
				
			||||||
        defaultShortcuts: ["F11"],
 | 
					        defaultShortcuts: ["F11"],
 | 
				
			||||||
 | 
					        description: "Toggle full screen",
 | 
				
			||||||
        scope: "window"
 | 
					        scope: "window"
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        actionName: "zoomOut",
 | 
					        actionName: "zoomOut",
 | 
				
			||||||
        defaultShortcuts: isElectron ? ["CommandOrControl+-"] : [],
 | 
					        defaultShortcuts: isElectron ? ["CommandOrControl+-"] : [],
 | 
				
			||||||
 | 
					        description: "Zoom Out",
 | 
				
			||||||
        scope: "window"
 | 
					        scope: "window"
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        actionName: "zoomIn",
 | 
					        actionName: "zoomIn",
 | 
				
			||||||
 | 
					        description: "Zoom In",
 | 
				
			||||||
        defaultShortcuts: isElectron ? ["CommandOrControl+="] : [],
 | 
					        defaultShortcuts: isElectron ? ["CommandOrControl+="] : [],
 | 
				
			||||||
        scope: "window"
 | 
					        scope: "window"
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        actionName: "copyWithoutFormatting",
 | 
					        actionName: "copyWithoutFormatting",
 | 
				
			||||||
        defaultShortcuts: ["CommandOrControl+Alt+C"],
 | 
					        defaultShortcuts: ["CommandOrControl+Alt+C"],
 | 
				
			||||||
 | 
					        description: "Copy selected text without formatting",
 | 
				
			||||||
        scope: "text-detail"
 | 
					        scope: "text-detail"
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
];
 | 
					];
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user