From 15254e2dfc7757077d13af88617f94d421936ed4 Mon Sep 17 00:00:00 2001 From: Zack Rauen Date: Fri, 8 Sep 2023 22:53:21 -0400 Subject: [PATCH 1/2] Add keyboard shortcuts for tabs --- src/public/app/widgets/tab_row.js | 20 +++++++++++ src/services/keyboard_actions.js | 60 +++++++++++++++++++++++++++++++ 2 files changed, 80 insertions(+) diff --git a/src/public/app/widgets/tab_row.js b/src/public/app/widgets/tab_row.js index 85ab7e3c5..07c581056 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 = $("