2023-01-03 19:55:46 +00:00
|
|
|
// Copyright 2019 Signal Messenger, LLC
|
2020-10-30 20:34:04 +00:00
|
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
2019-11-07 21:36:16 +00:00
|
|
|
import * as React from 'react';
|
|
|
|
import classNames from 'classnames';
|
2021-09-17 22:24:21 +00:00
|
|
|
import { useRestoreFocus } from '../hooks/useRestoreFocus';
|
2021-10-26 19:15:33 +00:00
|
|
|
import type { LocalizerType } from '../types/Util';
|
2019-11-07 21:36:16 +00:00
|
|
|
|
|
|
|
export type Props = {
|
|
|
|
hasInstalledStickers: boolean;
|
2023-04-14 18:16:28 +00:00
|
|
|
isFormattingFlagEnabled: boolean;
|
|
|
|
isFormattingSpoilersFlagEnabled: boolean;
|
2019-11-07 21:36:16 +00:00
|
|
|
platform: string;
|
|
|
|
readonly close: () => unknown;
|
|
|
|
readonly i18n: LocalizerType;
|
|
|
|
};
|
|
|
|
|
|
|
|
type KeyType =
|
|
|
|
| 'commandOrCtrl'
|
2022-05-10 18:14:08 +00:00
|
|
|
| 'ctrlOrAlt'
|
2019-11-07 21:36:16 +00:00
|
|
|
| 'optionOrAlt'
|
|
|
|
| 'shift'
|
|
|
|
| 'enter'
|
2020-04-20 18:23:46 +00:00
|
|
|
| 'tab'
|
|
|
|
| 'ctrl'
|
2023-05-09 15:52:03 +00:00
|
|
|
| 'F6'
|
2019-11-07 21:36:16 +00:00
|
|
|
| '↑'
|
|
|
|
| '↓'
|
|
|
|
| ','
|
|
|
|
| '.'
|
|
|
|
| 'A'
|
2023-04-14 18:16:28 +00:00
|
|
|
| 'B'
|
2019-11-07 21:36:16 +00:00
|
|
|
| 'C'
|
|
|
|
| 'D'
|
2020-01-23 23:57:37 +00:00
|
|
|
| 'E'
|
2019-11-07 21:36:16 +00:00
|
|
|
| 'F'
|
2023-04-06 01:04:41 +00:00
|
|
|
| 'G'
|
2023-04-14 18:16:28 +00:00
|
|
|
| 'I'
|
2019-11-19 23:03:00 +00:00
|
|
|
| 'J'
|
2023-04-14 18:16:28 +00:00
|
|
|
| 'K'
|
2019-11-15 22:31:51 +00:00
|
|
|
| 'L'
|
2019-11-07 21:36:16 +00:00
|
|
|
| 'M'
|
2021-02-23 20:34:28 +00:00
|
|
|
| 'N'
|
2019-11-07 21:36:16 +00:00
|
|
|
| 'P'
|
|
|
|
| 'R'
|
|
|
|
| 'S'
|
|
|
|
| 'T'
|
|
|
|
| 'U'
|
|
|
|
| 'V'
|
2020-04-20 18:23:46 +00:00
|
|
|
| 'X'
|
2022-05-10 18:14:08 +00:00
|
|
|
| 'Y'
|
2020-04-20 18:23:46 +00:00
|
|
|
| '1 to 9';
|
2019-11-07 21:36:16 +00:00
|
|
|
type ShortcutType = {
|
2023-03-28 18:26:46 +00:00
|
|
|
id: string;
|
2019-11-07 21:36:16 +00:00
|
|
|
description: string;
|
2020-04-20 18:23:46 +00:00
|
|
|
keys: Array<Array<KeyType>>;
|
2019-11-07 21:36:16 +00:00
|
|
|
};
|
|
|
|
|
2023-03-28 18:26:46 +00:00
|
|
|
function getNavigationShortcuts(i18n: LocalizerType): Array<ShortcutType> {
|
|
|
|
return [
|
|
|
|
{
|
|
|
|
id: 'Keyboard--navigate-by-section',
|
2023-03-30 00:03:25 +00:00
|
|
|
description: i18n('icu:Keyboard--navigate-by-section'),
|
2023-05-09 15:52:03 +00:00
|
|
|
keys: [
|
|
|
|
['commandOrCtrl', 'T'],
|
|
|
|
['commandOrCtrl', 'F6'],
|
|
|
|
],
|
2023-03-28 18:26:46 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 'Keyboard--previous-conversation',
|
2023-03-30 00:03:25 +00:00
|
|
|
description: i18n('icu:Keyboard--previous-conversation'),
|
2023-03-28 18:26:46 +00:00
|
|
|
keys: [
|
|
|
|
['optionOrAlt', '↑'],
|
|
|
|
['ctrl', 'shift', 'tab'],
|
|
|
|
],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 'Keyboard--next-conversation',
|
2023-03-30 00:03:25 +00:00
|
|
|
description: i18n('icu:Keyboard--next-conversation'),
|
2023-03-28 18:26:46 +00:00
|
|
|
keys: [
|
|
|
|
['optionOrAlt', '↓'],
|
|
|
|
['ctrl', 'tab'],
|
|
|
|
],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 'Keyboard--previous-unread-conversation',
|
2023-03-30 00:03:25 +00:00
|
|
|
description: i18n('icu:Keyboard--previous-unread-conversation'),
|
2023-03-28 18:26:46 +00:00
|
|
|
keys: [['optionOrAlt', 'shift', '↑']],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 'Keyboard--next-unread-conversation',
|
2023-03-30 00:03:25 +00:00
|
|
|
description: i18n('icu:Keyboard--next-unread-conversation'),
|
2023-03-28 18:26:46 +00:00
|
|
|
keys: [['optionOrAlt', 'shift', '↓']],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 'Keyboard--conversation-by-index',
|
2023-03-30 00:03:25 +00:00
|
|
|
description: i18n('icu:Keyboard--conversation-by-index'),
|
2023-03-28 18:26:46 +00:00
|
|
|
keys: [['commandOrCtrl', '1 to 9']],
|
|
|
|
},
|
2023-05-09 15:52:03 +00:00
|
|
|
{
|
|
|
|
id: 'Keyboard--most-recent-message',
|
|
|
|
description: i18n('icu:Keyboard--focus-most-recent-message'),
|
|
|
|
keys: [['commandOrCtrl', 'J']],
|
|
|
|
},
|
2023-03-28 18:26:46 +00:00
|
|
|
{
|
|
|
|
id: 'Keyboard--preferences',
|
2023-03-30 00:03:25 +00:00
|
|
|
description: i18n('icu:Keyboard--preferences'),
|
2023-03-28 18:26:46 +00:00
|
|
|
keys: [['commandOrCtrl', ',']],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 'Keyboard--open-conversation-menu',
|
2023-03-30 00:03:25 +00:00
|
|
|
description: i18n('icu:Keyboard--open-conversation-menu'),
|
2023-03-28 18:26:46 +00:00
|
|
|
keys: [['commandOrCtrl', 'shift', 'L']],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 'Keyboard--new-conversation',
|
2023-03-30 00:03:25 +00:00
|
|
|
description: i18n('icu:Keyboard--new-conversation'),
|
2023-03-28 18:26:46 +00:00
|
|
|
keys: [['commandOrCtrl', 'N']],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 'Keyboard--search',
|
2023-03-30 00:03:25 +00:00
|
|
|
description: i18n('icu:Keyboard--search'),
|
2023-03-28 18:26:46 +00:00
|
|
|
keys: [['commandOrCtrl', 'F']],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 'Keyboard--search-in-conversation',
|
2023-03-30 00:03:25 +00:00
|
|
|
description: i18n('icu:Keyboard--search-in-conversation'),
|
2023-03-28 18:26:46 +00:00
|
|
|
keys: [['commandOrCtrl', 'shift', 'F']],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 'Keyboard--focus-composer',
|
2023-03-30 00:03:25 +00:00
|
|
|
description: i18n('icu:Keyboard--focus-composer'),
|
2023-03-28 18:26:46 +00:00
|
|
|
keys: [['commandOrCtrl', 'shift', 'T']],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 'Keyboard--open-all-media-view',
|
2023-03-30 00:03:25 +00:00
|
|
|
description: i18n('icu:Keyboard--open-all-media-view'),
|
2023-03-28 18:26:46 +00:00
|
|
|
keys: [['commandOrCtrl', 'shift', 'M']],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 'Keyboard--open-emoji-chooser',
|
2023-03-30 00:03:25 +00:00
|
|
|
description: i18n('icu:Keyboard--open-emoji-chooser'),
|
2023-03-28 18:26:46 +00:00
|
|
|
keys: [['commandOrCtrl', 'shift', 'J']],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 'Keyboard--open-sticker-chooser',
|
2023-03-30 00:03:25 +00:00
|
|
|
description: i18n('icu:Keyboard--open-sticker-chooser'),
|
2023-04-06 01:04:41 +00:00
|
|
|
keys: [['commandOrCtrl', 'shift', 'G']],
|
2023-03-28 18:26:46 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 'Keyboard--begin-recording-voice-note',
|
2023-03-30 00:03:25 +00:00
|
|
|
description: i18n('icu:Keyboard--begin-recording-voice-note'),
|
2023-03-28 18:26:46 +00:00
|
|
|
keys: [['commandOrCtrl', 'shift', 'V']],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 'Keyboard--archive-conversation',
|
2023-03-30 00:03:25 +00:00
|
|
|
description: i18n('icu:Keyboard--archive-conversation'),
|
2023-03-28 18:26:46 +00:00
|
|
|
keys: [['commandOrCtrl', 'shift', 'A']],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 'Keyboard--unarchive-conversation',
|
2023-03-30 00:03:25 +00:00
|
|
|
description: i18n('icu:Keyboard--unarchive-conversation'),
|
2023-03-28 18:26:46 +00:00
|
|
|
keys: [['commandOrCtrl', 'shift', 'U']],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 'Keyboard--scroll-to-top',
|
2023-03-30 00:03:25 +00:00
|
|
|
description: i18n('icu:Keyboard--scroll-to-top'),
|
2023-03-28 18:26:46 +00:00
|
|
|
keys: [['commandOrCtrl', '↑']],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 'Keyboard--scroll-to-bottom',
|
2023-03-30 00:03:25 +00:00
|
|
|
description: i18n('icu:Keyboard--scroll-to-bottom'),
|
2023-03-28 18:26:46 +00:00
|
|
|
keys: [['commandOrCtrl', '↓']],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 'Keyboard--close-curent-conversation',
|
2023-03-30 00:03:25 +00:00
|
|
|
description: i18n('icu:Keyboard--close-curent-conversation'),
|
2023-03-28 18:26:46 +00:00
|
|
|
keys: [['commandOrCtrl', 'shift', 'C']],
|
|
|
|
},
|
|
|
|
];
|
|
|
|
}
|
2019-11-07 21:36:16 +00:00
|
|
|
|
2023-03-28 18:26:46 +00:00
|
|
|
function getMessageShortcuts(i18n: LocalizerType): Array<ShortcutType> {
|
|
|
|
return [
|
|
|
|
{
|
|
|
|
id: 'Keyboard--default-message-action',
|
2023-03-30 00:03:25 +00:00
|
|
|
description: i18n('icu:Keyboard--default-message-action'),
|
2023-03-28 18:26:46 +00:00
|
|
|
keys: [['enter']],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 'Keyboard--view-details-for-selected-message',
|
2023-03-30 00:03:25 +00:00
|
|
|
description: i18n('icu:Keyboard--view-details-for-selected-message'),
|
2023-03-28 18:26:46 +00:00
|
|
|
keys: [['commandOrCtrl', 'D']],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 'Keyboard--toggle-reply',
|
2023-03-30 00:03:25 +00:00
|
|
|
description: i18n('icu:Keyboard--toggle-reply'),
|
2023-03-28 18:26:46 +00:00
|
|
|
keys: [['commandOrCtrl', 'shift', 'R']],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 'Keyboard--toggle-reaction-picker',
|
2023-03-30 00:03:25 +00:00
|
|
|
description: i18n('icu:Keyboard--toggle-reaction-picker'),
|
2023-03-28 18:26:46 +00:00
|
|
|
keys: [['commandOrCtrl', 'shift', 'E']],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 'Keyboard--save-attachment',
|
2023-03-30 00:03:25 +00:00
|
|
|
description: i18n('icu:Keyboard--save-attachment'),
|
2023-03-28 18:26:46 +00:00
|
|
|
keys: [['commandOrCtrl', 'S']],
|
|
|
|
},
|
|
|
|
{
|
2023-03-30 00:03:25 +00:00
|
|
|
id: 'Keyboard--delete-messages',
|
|
|
|
description: i18n('icu:Keyboard--delete-messages'),
|
2023-03-28 18:26:46 +00:00
|
|
|
keys: [['commandOrCtrl', 'shift', 'D']],
|
|
|
|
},
|
2023-04-06 01:04:41 +00:00
|
|
|
{
|
|
|
|
id: 'Keyboard--forward-messages',
|
|
|
|
description: i18n('icu:Keyboard--forward-messages'),
|
|
|
|
keys: [['commandOrCtrl', 'shift', 'S']],
|
|
|
|
},
|
2023-03-28 18:26:46 +00:00
|
|
|
];
|
|
|
|
}
|
2019-11-07 21:36:16 +00:00
|
|
|
|
2023-04-14 18:16:28 +00:00
|
|
|
function getComposerShortcuts(
|
|
|
|
i18n: LocalizerType,
|
|
|
|
isFormattingFlagEnabled: boolean,
|
|
|
|
isFormattingSpoilersFlagEnabled: boolean
|
|
|
|
): Array<ShortcutType> {
|
|
|
|
const shortcuts: Array<ShortcutType> = [
|
2023-03-28 18:26:46 +00:00
|
|
|
{
|
|
|
|
id: 'Keyboard--add-newline',
|
2023-03-30 00:03:25 +00:00
|
|
|
description: i18n('icu:Keyboard--add-newline'),
|
2023-03-28 18:26:46 +00:00
|
|
|
keys: [['shift', 'enter']],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 'Keyboard--expand-composer',
|
2023-03-30 00:03:25 +00:00
|
|
|
description: i18n('icu:Keyboard--expand-composer'),
|
2023-04-14 18:16:28 +00:00
|
|
|
keys: [['commandOrCtrl', 'shift', 'K']],
|
2023-03-28 18:26:46 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 'Keyboard--send-in-expanded-composer',
|
2023-03-30 00:03:25 +00:00
|
|
|
description: i18n('icu:Keyboard--send-in-expanded-composer'),
|
2023-03-28 18:26:46 +00:00
|
|
|
keys: [['commandOrCtrl', 'enter']],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 'Keyboard--attach-file',
|
2023-03-30 00:03:25 +00:00
|
|
|
description: i18n('icu:Keyboard--attach-file'),
|
2023-03-28 18:26:46 +00:00
|
|
|
keys: [['commandOrCtrl', 'U']],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 'Keyboard--remove-draft-link-preview',
|
2023-03-30 00:03:25 +00:00
|
|
|
description: i18n('icu:Keyboard--remove-draft-link-preview'),
|
2023-03-28 18:26:46 +00:00
|
|
|
keys: [['commandOrCtrl', 'P']],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 'Keyboard--remove-draft-attachments',
|
2023-03-30 00:03:25 +00:00
|
|
|
description: i18n('icu:Keyboard--remove-draft-attachments'),
|
2023-03-28 18:26:46 +00:00
|
|
|
keys: [['commandOrCtrl', 'shift', 'P']],
|
|
|
|
},
|
2023-05-12 00:27:19 +00:00
|
|
|
{
|
|
|
|
id: 'Keyboard--edit-last-message',
|
|
|
|
description: i18n('icu:Keyboard--edit-last-message'),
|
|
|
|
keys: [['↑']],
|
|
|
|
},
|
2023-03-28 18:26:46 +00:00
|
|
|
];
|
2023-04-14 18:16:28 +00:00
|
|
|
|
|
|
|
if (isFormattingFlagEnabled) {
|
|
|
|
shortcuts.push({
|
|
|
|
id: 'Keyboard--composer--bold',
|
|
|
|
description: i18n('icu:Keyboard--composer--bold'),
|
|
|
|
keys: [['commandOrCtrl', 'B']],
|
|
|
|
});
|
|
|
|
shortcuts.push({
|
|
|
|
id: 'Keyboard--composer--italic',
|
|
|
|
description: i18n('icu:Keyboard--composer--italic'),
|
|
|
|
keys: [['commandOrCtrl', 'I']],
|
|
|
|
});
|
|
|
|
shortcuts.push({
|
|
|
|
id: 'Keyboard--composer--strikethrough',
|
|
|
|
description: i18n('icu:Keyboard--composer--strikethrough'),
|
|
|
|
keys: [['commandOrCtrl', 'shift', 'X']],
|
|
|
|
});
|
|
|
|
shortcuts.push({
|
|
|
|
id: 'Keyboard--composer--monospace',
|
|
|
|
description: i18n('icu:Keyboard--composer--monospace'),
|
|
|
|
keys: [['commandOrCtrl', 'E']],
|
|
|
|
});
|
|
|
|
|
|
|
|
if (isFormattingSpoilersFlagEnabled) {
|
|
|
|
shortcuts.push({
|
|
|
|
id: 'Keyboard--composer--spoiler',
|
|
|
|
description: i18n('icu:Keyboard--composer--spoiler'),
|
|
|
|
keys: [['commandOrCtrl', 'shift', 'B']],
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return shortcuts;
|
2023-03-28 18:26:46 +00:00
|
|
|
}
|
2019-11-07 21:36:16 +00:00
|
|
|
|
2023-03-28 18:26:46 +00:00
|
|
|
function getCallingShortcuts(i18n: LocalizerType): Array<ShortcutType> {
|
|
|
|
return [
|
|
|
|
{
|
|
|
|
id: 'Keyboard--toggle-audio',
|
2023-03-30 00:03:25 +00:00
|
|
|
description: i18n('icu:Keyboard--toggle-audio'),
|
2023-03-28 18:26:46 +00:00
|
|
|
keys: [['shift', 'M']],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 'Keyboard--toggle-video',
|
2023-03-30 00:03:25 +00:00
|
|
|
description: i18n('icu:Keyboard--toggle-video'),
|
2023-03-28 18:26:46 +00:00
|
|
|
keys: [['shift', 'V']],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 'icu:Keyboard--accept-video-call',
|
|
|
|
description: i18n('icu:Keyboard--accept-video-call'),
|
|
|
|
keys: [['ctrlOrAlt', 'shift', 'V']],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 'icu:Keyboard--accept-call-without-video',
|
|
|
|
description: i18n('icu:Keyboard--accept-call-without-video'),
|
|
|
|
keys: [['ctrlOrAlt', 'shift', 'A']],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 'Keyboard--decline-call',
|
2023-03-30 00:03:25 +00:00
|
|
|
description: i18n('icu:Keyboard--decline-call'),
|
2023-03-28 18:26:46 +00:00
|
|
|
keys: [['ctrlOrAlt', 'shift', 'D']],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 'Keyboard--start-audio-call',
|
2023-03-30 00:03:25 +00:00
|
|
|
description: i18n('icu:Keyboard--start-audio-call'),
|
2023-03-28 18:26:46 +00:00
|
|
|
keys: [['ctrlOrAlt', 'shift', 'C']],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 'Keyboard--start-video-call',
|
2023-03-30 00:03:25 +00:00
|
|
|
description: i18n('icu:Keyboard--start-video-call'),
|
2023-03-28 18:26:46 +00:00
|
|
|
keys: [['ctrlOrAlt', 'shift', 'Y']],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 'Keyboard--hang-up',
|
2023-03-30 00:03:25 +00:00
|
|
|
description: i18n('icu:Keyboard--hang-up'),
|
2023-03-28 18:26:46 +00:00
|
|
|
keys: [['ctrlOrAlt', 'shift', 'E']],
|
|
|
|
},
|
|
|
|
];
|
|
|
|
}
|
2020-06-04 18:16:19 +00:00
|
|
|
|
2022-11-18 00:45:19 +00:00
|
|
|
export function ShortcutGuide(props: Props): JSX.Element {
|
2023-04-14 18:16:28 +00:00
|
|
|
const {
|
|
|
|
i18n,
|
|
|
|
close,
|
|
|
|
hasInstalledStickers,
|
|
|
|
isFormattingFlagEnabled,
|
|
|
|
isFormattingSpoilersFlagEnabled,
|
|
|
|
platform,
|
|
|
|
} = props;
|
2019-11-07 21:36:16 +00:00
|
|
|
const isMacOS = platform === 'darwin';
|
|
|
|
|
|
|
|
// Restore focus on teardown
|
2021-07-30 20:30:59 +00:00
|
|
|
const [focusRef] = useRestoreFocus();
|
2019-11-07 21:36:16 +00:00
|
|
|
|
|
|
|
return (
|
|
|
|
<div className="module-shortcut-guide">
|
|
|
|
<div className="module-shortcut-guide__header">
|
|
|
|
<div className="module-shortcut-guide__header-text">
|
2023-03-30 00:03:25 +00:00
|
|
|
{i18n('icu:Keyboard--header')}
|
2019-11-07 21:36:16 +00:00
|
|
|
</div>
|
|
|
|
<button
|
2023-03-30 00:03:25 +00:00
|
|
|
aria-label={i18n('icu:close-popup')}
|
2019-11-07 21:36:16 +00:00
|
|
|
className="module-shortcut-guide__header-close"
|
|
|
|
onClick={close}
|
2023-03-30 00:03:25 +00:00
|
|
|
title={i18n('icu:close-popup')}
|
2020-09-12 00:46:52 +00:00
|
|
|
type="button"
|
2019-11-07 21:36:16 +00:00
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
<div
|
|
|
|
className="module-shortcut-guide__scroll-container"
|
|
|
|
ref={focusRef}
|
|
|
|
tabIndex={-1}
|
|
|
|
>
|
|
|
|
<div className="module-shortcut-guide__section-container">
|
|
|
|
<div className="module-shortcut-guide__section">
|
|
|
|
<div className="module-shortcut-guide__section-header">
|
2023-03-30 00:03:25 +00:00
|
|
|
{i18n('icu:Keyboard--navigation-header')}
|
2019-11-07 21:36:16 +00:00
|
|
|
</div>
|
|
|
|
<div className="module-shortcut-guide__section-list">
|
2023-03-28 18:26:46 +00:00
|
|
|
{getNavigationShortcuts(i18n).map((shortcut, index) => {
|
2019-11-07 21:36:16 +00:00
|
|
|
if (
|
|
|
|
!hasInstalledStickers &&
|
|
|
|
shortcut.description === 'Keyboard--open-sticker-chooser'
|
|
|
|
) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
return renderShortcut(shortcut, index, isMacOS, i18n);
|
|
|
|
})}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div className="module-shortcut-guide__section">
|
|
|
|
<div className="module-shortcut-guide__section-header">
|
2023-03-30 00:03:25 +00:00
|
|
|
{i18n('icu:Keyboard--messages-header')}
|
2019-11-07 21:36:16 +00:00
|
|
|
</div>
|
|
|
|
<div className="module-shortcut-guide__section-list">
|
2023-03-28 18:26:46 +00:00
|
|
|
{getMessageShortcuts(i18n).map((shortcut, index) =>
|
2019-11-07 21:36:16 +00:00
|
|
|
renderShortcut(shortcut, index, isMacOS, i18n)
|
|
|
|
)}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div className="module-shortcut-guide__section">
|
|
|
|
<div className="module-shortcut-guide__section-header">
|
2023-03-30 00:03:25 +00:00
|
|
|
{i18n('icu:Keyboard--composer-header')}
|
2019-11-07 21:36:16 +00:00
|
|
|
</div>
|
|
|
|
<div className="module-shortcut-guide__section-list">
|
2023-04-14 18:16:28 +00:00
|
|
|
{getComposerShortcuts(
|
|
|
|
i18n,
|
|
|
|
isFormattingFlagEnabled,
|
|
|
|
isFormattingSpoilersFlagEnabled
|
|
|
|
).map((shortcut, index) =>
|
2019-11-07 21:36:16 +00:00
|
|
|
renderShortcut(shortcut, index, isMacOS, i18n)
|
|
|
|
)}
|
|
|
|
</div>
|
|
|
|
</div>
|
2020-06-04 18:16:19 +00:00
|
|
|
<div className="module-shortcut-guide__section">
|
|
|
|
<div className="module-shortcut-guide__section-header">
|
2023-03-30 00:03:25 +00:00
|
|
|
{i18n('icu:Keyboard--calling-header')}
|
2020-06-04 18:16:19 +00:00
|
|
|
</div>
|
|
|
|
<div className="module-shortcut-guide__section-list">
|
2023-03-28 18:26:46 +00:00
|
|
|
{getCallingShortcuts(i18n).map((shortcut, index) =>
|
2020-06-04 18:16:19 +00:00
|
|
|
renderShortcut(shortcut, index, isMacOS, i18n)
|
|
|
|
)}
|
|
|
|
</div>
|
|
|
|
</div>
|
2019-11-07 21:36:16 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
2022-11-18 00:45:19 +00:00
|
|
|
}
|
2019-11-07 21:36:16 +00:00
|
|
|
|
|
|
|
function renderShortcut(
|
|
|
|
shortcut: ShortcutType,
|
|
|
|
index: number,
|
|
|
|
isMacOS: boolean,
|
|
|
|
i18n: LocalizerType
|
|
|
|
) {
|
|
|
|
return (
|
2020-09-12 00:46:52 +00:00
|
|
|
<div key={index} className="module-shortcut-guide__shortcut">
|
2019-11-07 21:36:16 +00:00
|
|
|
<div className="module-shortcut-guide__shortcut__description">
|
2023-03-28 18:26:46 +00:00
|
|
|
{shortcut.description}
|
2019-11-07 21:36:16 +00:00
|
|
|
</div>
|
|
|
|
<div className="module-shortcut-guide__shortcut__key-container">
|
2020-09-12 00:46:52 +00:00
|
|
|
{shortcut.keys.map(keys => (
|
2020-04-20 18:23:46 +00:00
|
|
|
<div
|
2020-09-12 00:46:52 +00:00
|
|
|
key={`${shortcut.description}--${keys.map(k => k).join('-')}`}
|
2020-04-20 18:23:46 +00:00
|
|
|
className="module-shortcut-guide__shortcut__key-inner-container"
|
|
|
|
>
|
2020-09-12 00:46:52 +00:00
|
|
|
{keys.map(key => {
|
2020-04-20 18:23:46 +00:00
|
|
|
let label: string = key;
|
|
|
|
let isSquare = true;
|
2019-11-07 21:36:16 +00:00
|
|
|
|
2020-04-20 18:23:46 +00:00
|
|
|
if (key === 'commandOrCtrl' && isMacOS) {
|
|
|
|
label = '⌘';
|
|
|
|
}
|
|
|
|
if (key === 'commandOrCtrl' && !isMacOS) {
|
2023-03-30 00:03:25 +00:00
|
|
|
label = i18n('icu:Keyboard--Key--ctrl');
|
2020-04-20 18:23:46 +00:00
|
|
|
isSquare = false;
|
|
|
|
}
|
2022-05-10 18:14:08 +00:00
|
|
|
if (key === 'ctrlOrAlt' && isMacOS) {
|
2023-03-30 00:03:25 +00:00
|
|
|
label = i18n('icu:Keyboard--Key--ctrl');
|
2022-05-10 18:14:08 +00:00
|
|
|
isSquare = false;
|
|
|
|
}
|
|
|
|
if (key === 'ctrlOrAlt' && !isMacOS) {
|
2023-03-30 00:03:25 +00:00
|
|
|
label = i18n('icu:Keyboard--Key--alt');
|
2022-05-10 18:14:08 +00:00
|
|
|
isSquare = false;
|
|
|
|
}
|
2020-04-20 18:23:46 +00:00
|
|
|
if (key === 'optionOrAlt' && isMacOS) {
|
2023-03-30 00:03:25 +00:00
|
|
|
label = i18n('icu:Keyboard--Key--option');
|
2020-04-20 18:23:46 +00:00
|
|
|
isSquare = false;
|
|
|
|
}
|
|
|
|
if (key === 'optionOrAlt' && !isMacOS) {
|
2023-03-30 00:03:25 +00:00
|
|
|
label = i18n('icu:Keyboard--Key--alt');
|
2020-04-20 18:23:46 +00:00
|
|
|
isSquare = false;
|
|
|
|
}
|
|
|
|
if (key === 'ctrl') {
|
2023-03-30 00:03:25 +00:00
|
|
|
label = i18n('icu:Keyboard--Key--ctrl');
|
2020-04-20 18:23:46 +00:00
|
|
|
isSquare = false;
|
|
|
|
}
|
|
|
|
if (key === 'shift') {
|
2023-03-30 00:03:25 +00:00
|
|
|
label = i18n('icu:Keyboard--Key--shift');
|
2020-04-20 18:23:46 +00:00
|
|
|
isSquare = false;
|
|
|
|
}
|
|
|
|
if (key === 'enter') {
|
2023-03-30 00:03:25 +00:00
|
|
|
label = i18n('icu:Keyboard--Key--enter');
|
2020-04-20 18:23:46 +00:00
|
|
|
isSquare = false;
|
|
|
|
}
|
|
|
|
if (key === 'tab') {
|
2023-03-30 00:03:25 +00:00
|
|
|
label = i18n('icu:Keyboard--Key--tab');
|
2020-04-20 18:23:46 +00:00
|
|
|
isSquare = false;
|
|
|
|
}
|
|
|
|
if (key === '1 to 9') {
|
2023-03-30 00:03:25 +00:00
|
|
|
label = i18n('icu:Keyboard--Key--one-to-nine-range');
|
2020-04-20 18:23:46 +00:00
|
|
|
isSquare = false;
|
|
|
|
}
|
2019-11-07 21:36:16 +00:00
|
|
|
|
2020-04-20 18:23:46 +00:00
|
|
|
return (
|
|
|
|
<span
|
2020-09-12 00:46:52 +00:00
|
|
|
key={`shortcut__key--${key}`}
|
2020-04-20 18:23:46 +00:00
|
|
|
className={classNames(
|
|
|
|
'module-shortcut-guide__shortcut__key',
|
|
|
|
isSquare
|
|
|
|
? 'module-shortcut-guide__shortcut__key--square'
|
|
|
|
: null
|
|
|
|
)}
|
|
|
|
>
|
|
|
|
{label}
|
|
|
|
</span>
|
|
|
|
);
|
|
|
|
})}
|
|
|
|
</div>
|
|
|
|
))}
|
2019-11-07 21:36:16 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|