Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit 57a5647

Browse files
Work towards unifying KeyboardShortcuts and KeyBindingsDefaults #1 (#7651)
1 parent f2249b3 commit 57a5647

File tree

6 files changed

+237
-139
lines changed

6 files changed

+237
-139
lines changed

src/KeyBindingsManager.ts

Lines changed: 48 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -20,117 +20,121 @@ import { isMac } from './Keyboard';
2020
/** Actions for the chat message composer component */
2121
export enum MessageComposerAction {
2222
/** Send a message */
23-
Send = 'Send',
23+
Send = 'KeyBinding.sendMessageInComposer',
2424
/** Go backwards through the send history and use the message in composer view */
25-
SelectPrevSendHistory = 'SelectPrevSendHistory',
25+
SelectPrevSendHistory = 'KeyBinding.previousMessageInComposerHistory',
2626
/** Go forwards through the send history */
27-
SelectNextSendHistory = 'SelectNextSendHistory',
27+
SelectNextSendHistory = 'KeyBinding.nextMessageInComposerHistory',
2828
/** Start editing the user's last sent message */
29-
EditPrevMessage = 'EditPrevMessage',
29+
EditPrevMessage = 'KeyBinding.editPreviousMessage',
3030
/** Start editing the user's next sent message */
31-
EditNextMessage = 'EditNextMessage',
31+
EditNextMessage = 'KeyBinding.editNextMessage',
3232
/** Cancel editing a message or cancel replying to a message */
33-
CancelEditing = 'CancelEditing',
33+
CancelEditing = 'KeyBinding.cancelReplyInComposer',
3434

3535
/** Set bold format the current selection */
36-
FormatBold = 'FormatBold',
36+
FormatBold = 'KeyBinding.toggleBoldInComposer',
3737
/** Set italics format the current selection */
38-
FormatItalics = 'FormatItalics',
38+
FormatItalics = 'KeyBinding.toggleItalicsInComposer',
3939
/** Format the current selection as quote */
40-
FormatQuote = 'FormatQuote',
40+
FormatQuote = 'KeyBinding.toggleQuoteInComposer',
4141
/** Undo the last editing */
42-
EditUndo = 'EditUndo',
42+
EditUndo = 'KeyBinding.editUndoInComposer',
4343
/** Redo editing */
44-
EditRedo = 'EditRedo',
44+
EditRedo = 'KeyBinding.editRedoInComposer',
4545
/** Insert new line */
46-
NewLine = 'NewLine',
46+
NewLine = 'KeyBinding.newLineInComposer',
4747
/** Move the cursor to the start of the message */
48-
MoveCursorToStart = 'MoveCursorToStart',
48+
MoveCursorToStart = 'KeyBinding.jumpToStartInComposer',
4949
/** Move the cursor to the end of the message */
50-
MoveCursorToEnd = 'MoveCursorToEnd',
50+
MoveCursorToEnd = 'KeyBinding.jumpToEndInComposer',
5151
}
5252

5353
/** Actions for text editing autocompletion */
5454
export enum AutocompleteAction {
5555
/** Accepts chosen autocomplete selection */
56-
Complete = 'Complete',
56+
Complete = 'KeyBinding.completeAutocomplete',
5757
/** Accepts chosen autocomplete selection or,
5858
* if the autocompletion window is not shown, open the window and select the first selection */
59-
ForceComplete = 'ForceComplete',
59+
ForceComplete = 'KeyBinding.forceCompleteAutocomplete',
6060
/** Move to the previous autocomplete selection */
61-
PrevSelection = 'PrevSelection',
61+
PrevSelection = 'KeyBinding.previousOptionInAutoComplete',
6262
/** Move to the next autocomplete selection */
63-
NextSelection = 'NextSelection',
63+
NextSelection = 'KeyBinding.nextOptionInAutoComplete',
6464
/** Close the autocompletion window */
65-
Cancel = 'Cancel',
65+
Cancel = 'KeyBinding.cancelAutoComplete',
6666
}
6767

6868
/** Actions for the room list sidebar */
6969
export enum RoomListAction {
7070
/** Clear room list filter field */
71-
ClearSearch = 'ClearSearch',
71+
ClearSearch = 'KeyBinding.clearRoomFilter',
7272
/** Navigate up/down in the room list */
73-
PrevRoom = 'PrevRoom',
73+
PrevRoom = 'KeyBinding.downerRoom',
7474
/** Navigate down in the room list */
75-
NextRoom = 'NextRoom',
75+
NextRoom = 'KeyBinding.upperRoom',
7676
/** Select room from the room list */
77-
SelectRoom = 'SelectRoom',
77+
SelectRoom = 'KeyBinding.selectRoomInRoomList',
7878
/** Collapse room list section */
79-
CollapseSection = 'CollapseSection',
79+
CollapseSection = 'KeyBinding.collapseSectionInRoomList',
8080
/** Expand room list section, if already expanded, jump to first room in the selection */
81-
ExpandSection = 'ExpandSection',
81+
ExpandSection = 'KeyBinding.expandSectionInRoomList',
8282
}
8383

8484
/** Actions for the current room view */
8585
export enum RoomAction {
8686
/** Scroll up in the timeline */
87-
ScrollUp = 'ScrollUp',
87+
ScrollUp = 'KeyBinding.scrollUpInTimeline',
8888
/** Scroll down in the timeline */
89-
RoomScrollDown = 'RoomScrollDown',
89+
RoomScrollDown = 'KeyBinding.scrollDownInTimeline',
9090
/** Dismiss read marker and jump to bottom */
91-
DismissReadMarker = 'DismissReadMarker',
91+
DismissReadMarker = 'KeyBinding.dismissReadMarkerAndJumpToBottom',
9292
/** Jump to oldest unread message */
93-
JumpToOldestUnread = 'JumpToOldestUnread',
93+
JumpToOldestUnread = 'KeyBinding.jumpToOldestUnreadMessage',
9494
/** Upload a file */
95-
UploadFile = 'UploadFile',
95+
UploadFile = 'KeyBinding.uploadFileToRoom',
9696
/** Focus search message in a room (must be enabled) */
97-
FocusSearch = 'FocusSearch',
97+
FocusSearch = 'KeyBinding.searchInRoom',
9898
/** Jump to the first (downloaded) message in the room */
99-
JumpToFirstMessage = 'JumpToFirstMessage',
99+
JumpToFirstMessage = 'KeyBinding.jumpToFirstMessageInTimeline',
100100
/** Jump to the latest message in the room */
101-
JumpToLatestMessage = 'JumpToLatestMessage',
101+
JumpToLatestMessage = 'KeyBinding.jumpToLastMessageInTimeline',
102102
}
103103

104104
/** Actions for navigating do various menus, dialogs or screens */
105105
export enum NavigationAction {
106106
/** Jump to room search (search for a room) */
107-
FocusRoomSearch = 'FocusRoomSearch',
107+
FocusRoomSearch = 'KeyBinding.filterRooms',
108108
/** Toggle the space panel */
109-
ToggleSpacePanel = 'ToggleSpacePanel',
109+
ToggleSpacePanel = 'KeyBinding.toggleSpacePanel',
110110
/** Toggle the room side panel */
111-
ToggleRoomSidePanel = 'ToggleRoomSidePanel',
111+
ToggleRoomSidePanel = 'KeyBinding.toggleRightPanel',
112112
/** Toggle the user menu */
113-
ToggleUserMenu = 'ToggleUserMenu',
113+
ToggleUserMenu = 'KeyBinding.toggleTopLeftMenu',
114114
/** Toggle the short cut help dialog */
115-
OpenShortCutDialog = 'OpenShortCutDialog',
115+
OpenShortCutDialog = 'KeyBinding.showKeyBindingsSettings',
116116
/** Got to the Element home screen */
117-
GoToHome = 'GoToHome',
117+
GoToHome = 'KeyBinding.goToHomeView',
118118
/** Select prev room */
119-
SelectPrevRoom = 'SelectPrevRoom',
119+
SelectPrevRoom = 'KeyBinding.previousRoom',
120120
/** Select next room */
121-
SelectNextRoom = 'SelectNextRoom',
121+
SelectNextRoom = 'KeyBinding.nextRoom',
122122
/** Select prev room with unread messages */
123-
SelectPrevUnreadRoom = 'SelectPrevUnreadRoom',
123+
SelectPrevUnreadRoom = 'KeyBinding.previousUnreadRoom',
124124
/** Select next room with unread messages */
125-
SelectNextUnreadRoom = 'SelectNextUnreadRoom',
125+
SelectNextUnreadRoom = 'KeyBinding.nextUnreadRoom',
126126
}
127127

128128
/** Actions only available when labs are enabled */
129129
export enum LabsAction {
130130
/** Toggle visibility of hidden events */
131-
ToggleHiddenEventVisibility = 'ToggleHiddenEventVisibility',
131+
ToggleHiddenEventVisibility = 'KeyBinding.toggleHiddenEventVisibility',
132132
}
133133

134+
export type KeyBindingAction = (
135+
MessageComposerAction | AutocompleteAction | RoomListAction | RoomAction | NavigationAction | LabsAction
136+
);
137+
134138
/**
135139
* Represent a key combination.
136140
*

0 commit comments

Comments
 (0)