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

Keyboard shortcut to open the sticker picker #7985

Merged
merged 6 commits into from
Mar 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/Keyboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export const Key = {
SLASH: "/",
SQUARE_BRACKET_LEFT: "[",
SQUARE_BRACKET_RIGHT: "]",
SEMICOLON: ";",
A: "a",
B: "b",
C: "c",
Expand Down
10 changes: 10 additions & 0 deletions src/accessibility/KeyboardShortcuts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ export enum KeyBindingAction {
EditNextMessage = 'KeyBinding.editNextMessage',
/** Cancel editing a message or cancel replying to a message */
CancelReplyOrEdit = 'KeyBinding.cancelReplyInComposer',
/** Show the sticker picker */
ShowStickerPicker = 'KeyBinding.showStickerPicker',

/** Set bold format the current selection */
FormatBold = 'KeyBinding.toggleBoldInComposer',
Expand Down Expand Up @@ -227,6 +229,7 @@ export const CATEGORIES: Record<CategoryName, ICategory> = {
KeyBindingAction.EditPrevMessage,
KeyBindingAction.SelectNextSendHistory,
KeyBindingAction.SelectPrevSendHistory,
KeyBindingAction.ShowStickerPicker,
],
}, [CategoryName.CALLS]: {
categoryLabel: _td("Calls"),
Expand Down Expand Up @@ -392,6 +395,13 @@ export const KEYBOARD_SHORTCUTS: IKeyboardShortcuts = {
},
displayName: _td("Navigate to previous message in composer history"),
},
[KeyBindingAction.ShowStickerPicker]: {
default: {
ctrlOrCmdKey: true,
key: Key.SEMICOLON,
},
displayName: _td("Send a sticker"),
},
andybalaam marked this conversation as resolved.
Show resolved Hide resolved
[KeyBindingAction.ToggleMicInCall]: {
default: {
ctrlOrCmdKey: true,
Expand Down
5 changes: 5 additions & 0 deletions src/components/views/rooms/MessageComposer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,10 @@ export default class MessageComposer extends React.Component<IProps, IState> {
});
};

private toggleStickerPickerOpen = () => {
this.setStickerPickerOpen(!this.state.isStickerPickerOpen);
};

private toggleButtonMenu = (): void => {
this.setState({
isMenuOpen: !this.state.isMenuOpen,
Expand Down Expand Up @@ -363,6 +367,7 @@ export default class MessageComposer extends React.Component<IProps, IState> {
replyToEvent={this.props.replyToEvent}
onChange={this.onChange}
disabled={this.state.haveRecording}
toggleStickerPickerOpen={this.toggleStickerPickerOpen}
/>,
);

Expand Down
9 changes: 9 additions & 0 deletions src/components/views/rooms/SendMessageComposer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ interface ISendMessageComposerProps extends MatrixClientProps {
disabled?: boolean;
onChange?(model: EditorModel): void;
includeReplyLegacyFallback?: boolean;
toggleStickerPickerOpen: () => void;
}

@replaceableComponent("views.rooms.SendMessageComposer")
Expand Down Expand Up @@ -237,6 +238,14 @@ export class SendMessageComposer extends React.Component<ISendMessageComposerPro
}
break;
}
case KeyBindingAction.ShowStickerPicker: {
if (!SettingsStore.getValue("MessageComposerInput.showStickersButton")) {
return; // Do nothing if there is no Stickers button
}
this.props.toggleStickerPickerOpen();
event.preventDefault();
break;
}
case KeyBindingAction.EditPrevMessage:
// selection must be collapsed and caret at start
if (this.editorRef.current?.isSelectionCollapsed() && this.editorRef.current?.isCaretAtStart()) {
Expand Down
1 change: 1 addition & 0 deletions src/i18n/strings/en_EN.json
Original file line number Diff line number Diff line change
Expand Up @@ -3427,6 +3427,7 @@
"Jump to end of the composer": "Jump to end of the composer",
"Navigate to next message in composer history": "Navigate to next message in composer history",
"Navigate to previous message in composer history": "Navigate to previous message in composer history",
"Send a sticker": "Send a sticker",
"Toggle microphone mute": "Toggle microphone mute",
"Toggle webcam on/off": "Toggle webcam on/off",
"Dismiss read marker and jump to bottom": "Dismiss read marker and jump to bottom",
Expand Down