mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
Merge pull request #4251 from rauenzi/tab-navigation
Add keyboard shortcuts for tabs
This commit is contained in:
commit
7848c7e319
@ -267,8 +267,28 @@ export default class TabRowWidget extends BasicWidget {
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
keyboardActionService.setupActionsForElement('window', $(document), this);
|
||||
}
|
||||
|
||||
goToTab(tabNumber) {
|
||||
const index = tabNumber === Number.POSITIVE_INFINITY ? 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(Number.POSITIVE_INFINITY);}
|
||||
|
||||
setupStyle() {
|
||||
this.$style = $("<style>");
|
||||
this.$widget.append(this.$style);
|
||||
|
@ -240,6 +240,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: "window"
|
||||
},
|
||||
{
|
||||
actionName: "secondTab",
|
||||
defaultShortcuts: ["CommandOrControl+2"],
|
||||
description: "Activates the second tab in the list",
|
||||
scope: "window"
|
||||
},
|
||||
{
|
||||
actionName: "thirdTab",
|
||||
defaultShortcuts: ["CommandOrControl+3"],
|
||||
description: "Activates the third tab in the list",
|
||||
scope: "window"
|
||||
},
|
||||
{
|
||||
actionName: "fourthTab",
|
||||
defaultShortcuts: ["CommandOrControl+4"],
|
||||
description: "Activates the fourth tab in the list",
|
||||
scope: "window"
|
||||
},
|
||||
{
|
||||
actionName: "fifthTab",
|
||||
defaultShortcuts: ["CommandOrControl+5"],
|
||||
description: "Activates the fifth tab in the list",
|
||||
scope: "window"
|
||||
},
|
||||
{
|
||||
actionName: "sixthTab",
|
||||
defaultShortcuts: ["CommandOrControl+6"],
|
||||
description: "Activates the sixth tab in the list",
|
||||
scope: "window"
|
||||
},
|
||||
{
|
||||
actionName: "seventhTab",
|
||||
defaultShortcuts: ["CommandOrControl+7"],
|
||||
description: "Activates the seventh tab in the list",
|
||||
scope: "window"
|
||||
},
|
||||
{
|
||||
actionName: "eigthTab",
|
||||
defaultShortcuts: ["CommandOrControl+8"],
|
||||
description: "Activates the eigth tab in the list",
|
||||
scope: "window"
|
||||
},
|
||||
{
|
||||
actionName: "ninthTab",
|
||||
defaultShortcuts: ["CommandOrControl+9"],
|
||||
description: "Activates the ninth tab in the list",
|
||||
scope: "window"
|
||||
},
|
||||
{
|
||||
actionName: "lastTab",
|
||||
defaultShortcuts: ["CommandOrControl+0"],
|
||||
description: "Activates the last tab in the list",
|
||||
scope: "window"
|
||||
},
|
||||
|
||||
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user