Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
Add keyboard shortcuts for tabs
Zack Rauen15254e2dfc77
diff --git a/src/public/app/widgets/tab_row.js b/src/public/app/widgets/tab_row.jsindex 85ab7e3c57..07c581056a 100644--- a/src/public/app/widgets/tab_row.js+++ b/src/public/app/widgets/tab_row.js@@ -267,8 +267,28 @@ export default class TabRowWidget extends BasicWidget {}});});++ keyboardActionService.setupActionsForElement('tabs', $(document), this);+ }++ goToTab(tabNumber) {+ const index = tabNumber === 0 ? this.tabEls.length - 1 : tabNumber - 1;+ const tab = this.tabEls[index];+ if (!tab) return;+ appContext.tabManager.activateNoteContext(tab.getAttribute('data-ntx-id'));}+ firstTabCommand() {this.goToTab(1);}+ secondTabCommand() {this.goToTab(2);}+ thirdTabCommand() {this.goToTab(3);}+ fourthTabCommand() {this.goToTab(4);}+ fifthTabCommand() {this.goToTab(5);}+ sixthTabCommand() {this.goToTab(6);}+ seventhTabCommand() {this.goToTab(7);}+ eigthTabCommand() {this.goToTab(8);}+ ninthTabCommand() {this.goToTab(9);}+ lastTabCommand() {this.goToTab(0);}+setupStyle() {this.$style = $("<style>");this.$widget.append(this.$style);diff --git a/src/services/keyboard_actions.js b/src/services/keyboard_actions.jsindex 94cc7fe17a..a2c1cae26c 100644--- a/src/services/keyboard_actions.js+++ b/src/services/keyboard_actions.js@@ -231,6 +231,66 @@ const DEFAULT_KEYBOARD_ACTIONS = [description: "Open new empty window",scope: "window"},+ {+ actionName: "firstTab",+ defaultShortcuts: ["CommandOrControl+1"],+ description: "Activates the first tab in the list",+ scope: "tabs"+ },+ {+ actionName: "secondTab",+ defaultShortcuts: ["CommandOrControl+2"],+ description: "Activates the second tab in the list",+ scope: "tabs"+ },+ {+ actionName: "thirdTab",+ defaultShortcuts: ["CommandOrControl+3"],+ description: "Activates the third tab in the list",+ scope: "tabs"+ },+ {+ actionName: "fourthTab",+ defaultShortcuts: ["CommandOrControl+4"],+ description: "Activates the fourth tab in the list",+ scope: "tabs"+ },+ {+ actionName: "fifthTab",+ defaultShortcuts: ["CommandOrControl+5"],+ description: "Activates the fifth tab in the list",+ scope: "tabs"+ },+ {+ actionName: "sixthTab",+ defaultShortcuts: ["CommandOrControl+6"],+ description: "Activates the sixth tab in the list",+ scope: "tabs"+ },+ {+ actionName: "seventhTab",+ defaultShortcuts: ["CommandOrControl+7"],+ description: "Activates the seventh tab in the list",+ scope: "tabs"+ },+ {+ actionName: "eigthTab",+ defaultShortcuts: ["CommandOrControl+8"],+ description: "Activates the eigth tab in the list",+ scope: "tabs"+ },+ {+ actionName: "ninthTab",+ defaultShortcuts: ["CommandOrControl+9"],+ description: "Activates the ninth tab in the list",+ scope: "tabs"+ },+ {+ actionName: "lastTab",+ defaultShortcuts: ["CommandOrControl+0"],+ description: "Activates the last tab in the list",+ scope: "tabs"+ },{