From 20a892247f8bfd05308a8e7b4ae87a393fccee9b Mon Sep 17 00:00:00 2001 From: Scott Nonnenberg Date: Thu, 7 Nov 2019 13:36:16 -0800 Subject: [PATCH] Keyboard shortcuts and accessibility --- _locales/en/messages.json | 191 +++++- app/menu.js | 10 +- background.html | 12 +- js/about_start.js | 2 +- js/background.js | 511 +++++++++++++++- js/debug_log_start.js | 2 +- js/models/messages.js | 12 + js/modules/signal.js | 13 +- js/permissions_popup_start.js | 2 +- js/settings_start.js | 2 +- js/views/confirmation_dialog_view.js | 24 +- js/views/conversation_view.js | 164 ++++- js/views/inbox_view.js | 9 +- js/views/phone-input-view.js | 2 +- js/views/recorder_view.js | 13 + js/views/toast_view.js | 6 + main.js | 7 + patches/react-contextmenu+2.11.0.patch | 34 + patches/react-virtualized+9.21.0.patch | 28 +- preload.js | 13 +- stylesheets/_conversation.scss | 5 +- stylesheets/_global.scss | 29 +- stylesheets/_lightbox.scss | 6 +- stylesheets/_mixins.scss | 2 + stylesheets/_modules.scss | 579 ++++++++++++++---- test/app/fixtures/menu-mac-os-setup.json | 7 +- test/app/fixtures/menu-mac-os.json | 7 +- .../fixtures/menu-windows-linux-setup.json | 7 +- test/app/fixtures/menu-windows-linux.json | 7 +- test/app/menu_test.js | 1 + ts/components/Avatar.tsx | 19 +- ts/components/AvatarPopup.tsx | 23 +- ts/components/CaptionEditor.tsx | 22 +- ts/components/CompositionArea.tsx | 10 +- ts/components/ConfirmationDialog.tsx | 4 +- ts/components/ConfirmationModal.tsx | 12 +- ts/components/ContactListItem.tsx | 5 +- ts/components/ConversationListItem.tsx | 10 +- ts/components/LeftPane.tsx | 201 +++++- ts/components/Lightbox.tsx | 71 ++- ts/components/MainHeader.tsx | 35 +- ts/components/MessageSearchResult.tsx | 6 +- ts/components/SearchResults.tsx | 244 +++++++- ts/components/ShortcutGuide.md | 7 + ts/components/ShortcutGuide.tsx | 304 +++++++++ ts/components/ShortcutGuideModal.tsx | 45 ++ ts/components/StartNewConversation.tsx | 8 +- ts/components/conversation/AttachmentList.tsx | 8 +- ts/components/conversation/ContactDetail.tsx | 13 +- .../conversation/EmbeddedContact.tsx | 14 +- ts/components/conversation/Image.tsx | 88 ++- ts/components/conversation/ImageGrid.tsx | 20 +- .../InlineNotificationWrapper.tsx | 52 ++ ts/components/conversation/Message.tsx | 464 +++++++++----- ts/components/conversation/MessageDetail.tsx | 19 +- ts/components/conversation/Quote.tsx | 46 +- .../conversation/SafetyNumberNotification.tsx | 5 +- .../conversation/StagedGenericAttachment.tsx | 3 +- .../conversation/StagedLinkPreview.tsx | 3 +- .../StagedPlaceholderAttachment.md | 5 +- .../StagedPlaceholderAttachment.tsx | 10 +- ts/components/conversation/Timeline.tsx | 150 ++++- ts/components/conversation/TimelineItem.tsx | 77 ++- .../conversation/UnsupportedMessage.tsx | 5 +- .../media-gallery/DocumentListItem.tsx | 5 +- .../media-gallery/MediaGallery.tsx | 14 +- .../media-gallery/MediaGridItem.tsx | 8 +- ts/components/emoji/EmojiButton.tsx | 36 +- ts/components/emoji/EmojiPicker.tsx | 36 +- ts/components/stickers/StickerButton.tsx | 33 +- ts/components/stickers/StickerManager.tsx | 13 +- .../stickers/StickerManagerPackRow.tsx | 23 +- ts/components/stickers/StickerPicker.tsx | 74 ++- .../stickers/StickerPreviewModal.tsx | 29 +- ts/state/ducks/conversations.ts | 45 +- ts/state/ducks/search.ts | 54 +- ts/state/ducks/user.ts | 2 + ts/state/roots/createShortcutGuideModal.tsx | 16 + ts/state/selectors/search.ts | 22 +- ts/state/selectors/user.ts | 5 + ts/state/smart/LeftPane.tsx | 8 +- ts/state/smart/MainHeader.tsx | 2 + ts/state/smart/ShortcutGuideModal.tsx | 47 ++ ts/state/smart/Timeline.tsx | 17 +- ts/state/smart/TimelineItem.tsx | 14 +- ts/util/lint/exceptions.json | 144 ++++- yarn.lock | 1 + 87 files changed, 3652 insertions(+), 711 deletions(-) create mode 100644 patches/react-contextmenu+2.11.0.patch create mode 100644 ts/components/ShortcutGuide.md create mode 100644 ts/components/ShortcutGuide.tsx create mode 100644 ts/components/ShortcutGuideModal.tsx create mode 100644 ts/components/conversation/InlineNotificationWrapper.tsx create mode 100644 ts/state/roots/createShortcutGuideModal.tsx create mode 100644 ts/state/smart/ShortcutGuideModal.tsx diff --git a/_locales/en/messages.json b/_locales/en/messages.json index 7a6e477684ce..ae3755ced024 100644 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -688,9 +688,15 @@ "message": "Debug Log", "description": "View menu item to open the debug log (title case)" }, + "helpMenuShowKeyboardShortcuts": { + "message": "Show Keyboard Shortcuts", + "description": + "Item under the help menu, pops up a screen showing the application's keyboard shortcuts" + }, "goToReleaseNotes": { "message": "Go to Release Notes", - "description": "" + "description": + "Item under the help menu, takes you to GitHub page for release notes" }, "goToForums": { "message": "Go to Forums", @@ -1949,5 +1955,188 @@ "message": "(draft)", "description": "Text shown in left pane as preview for conversation with saved a saved draft message" + }, + "Keyboard--navigate-by-section": { + "message": "Navigate by section", + "description": "Shown in the shortcuts guide" + }, + "Keyboard--previous-conversation": { + "message": "Previous conversation", + "description": "Shown in the shortcuts guide" + }, + "Keyboard--next-conversation": { + "message": "Next conversation", + "description": "Shown in the shortcuts guide" + }, + "Keyboard--previous-unread-conversation": { + "message": "Previous unread conversation", + "description": "Shown in the shortcuts guide" + }, + "Keyboard--next-unread-conversation": { + "message": "Next unread conversation", + "description": "Shown in the shortcuts guide" + }, + "Keyboard--preferences": { + "message": "Preferences", + "description": "Shown in the shortcuts guide" + }, + "Keyboard--open-conversation-menu": { + "message": "Open conversation menu", + "description": "Shown in the shortcuts guide" + }, + "Keyboard--archive-conversation": { + "message": "Archive conversation", + "description": "Shown in the shortcuts guide" + }, + "Keyboard--unarchive-conversation": { + "message": "Unarchive conversation", + "description": "Shown in the shortcuts guide" + }, + "Keyboard--search": { + "message": "Search", + "description": "Shown in the shortcuts guide" + }, + "Keyboard--search-in-conversation": { + "message": "Search in conversation", + "description": "Shown in the shortcuts guide" + }, + "Keyboard--focus-composer": { + "message": "Focus composer", + "description": "Shown in the shortcuts guide" + }, + "Keyboard--open-all-media-view": { + "message": "Open All Media view", + "description": "Shown in the shortcuts guide" + }, + "Keyboard--open-emoji-chooser": { + "message": "Open emoji chooser", + "description": "Shown in the shortcuts guide" + }, + "Keyboard--open-sticker-chooser": { + "message": "Open sticker chooser", + "description": "Shown in the shortcuts guide" + }, + "Keyboard--begin-recording-voice-note": { + "message": "Begin recording voice note", + "description": "Shown in the shortcuts guide" + }, + "Keyboard--default-message-action": { + "message": "Default action for selected message", + "description": "Shown in the shortcuts guide" + }, + "Keyboard--view-details-for-selected-message": { + "message": "View selected message details", + "description": "Shown in the shortcuts guide" + }, + "Keyboard--toggle-reply": { + "message": "Toggle reply to selected message", + "description": "Shown in the shortcuts guide" + }, + "Keyboard--save-attachment": { + "message": "Save attachment from selected message", + "description": "Shown in the shortcuts guide" + }, + "Keyboard--delete-message": { + "message": "Delete selected message", + "description": "Shown in the shortcuts guide" + }, + "Keyboard--add-newline": { + "message": "Add newline to message", + "description": "Shown in the shortcuts guide" + }, + "Keyboard--expand-composer": { + "message": "Expand composer", + "description": "Shown in the shortcuts guide" + }, + "Keyboard--send-in-expanded-composer": { + "message": "Send (in expanded composer)", + "description": "Shown in the shortcuts guide" + }, + "Keyboard--attach-file": { + "message": "Attach file", + "description": "Shown in the shortcuts guide" + }, + "Keyboard--remove-draft-link-preview": { + "message": "Remove draft link preview", + "description": "Shown in the shortcuts guide" + }, + "Keyboard--remove-draft-attachments": { + "message": "Remove all draft attachments", + "description": "Shown in the shortcuts guide" + }, + "Keyboard--Key--ctrl": { + "message": "Ctrl", + "description": "Key shown in shortcut combination in shortcuts guide" + }, + "Keyboard--Key--option": { + "message": "Option", + "description": "Key shown in shortcut combination in shortcuts guide" + }, + "Keyboard--Key--alt": { + "message": "Alt", + "description": "Key shown in shortcut combination in shortcuts guide" + }, + "Keyboard--Key--shift": { + "message": "Shift", + "description": "Key shown in shortcut combination in shortcuts guide" + }, + "Keyboard--Key--enter": { + "message": "Enter", + "description": "Key shown in shortcut combination in shortcuts guide" + }, + "Keyboard--header": { + "message": "Keyboard Shortcuts", + "description": "Title header of the keyboard shortcuts guide" + }, + "Keyboard--navigation-header": { + "message": "Navigation", + "description": "Header of the keyboard shortcuts guide - navigation section" + }, + "Keyboard--messages-header": { + "message": "Messages", + "description": "Header of the keyboard shortcuts guide - messages section" + }, + "Keyboard--composer-header": { + "message": "Composer", + "description": "Header of the keyboard shortcuts guide - composer section" + }, + "Keyboard--scroll-to-top": { + "message": "Scroll to top of list", + "description": "Shown in the shortcuts guide" + }, + "Keyboard--scroll-to-bottom": { + "message": "Scroll to bottom of list", + "description": "Shown in the shortcuts guide" + }, + "Keyboard--close-curent-conversation": { + "message": "Close current conversation", + "description": "Shown in the shortcuts guide" + }, + "close-popup": { + "message": "Close Popup", + "description": "Used as alt text for any button closing a popup" + }, + "add-image-attachment": { + "message": "Add image attachment", + "description": + "Used in draft attachment list for the big 'add new attachment' button" + }, + "remove-attachment": { + "message": "Remove attachment", + "description": + "Used in draft attachment list to remove an individual attachment" + }, + "backToInbox": { + "message": "Back to inbox", + "description": "Used as alt-text of button on archived conversations screen" + }, + "conversationArchived": { + "message": "Conversation archived", + "description": "A toast that shows up when user archives a conversation" + }, + "conversationReturnedToInbox": { + "message": "Conversation returned to inbox", + "description": + "A toast that shows up when the user unarchives a conversation" } } diff --git a/app/menu.js b/app/menu.js index 0e745beb20da..cfaadf7cf8d2 100644 --- a/app/menu.js +++ b/app/menu.js @@ -17,6 +17,7 @@ exports.createTemplate = (options, messages) => { setupWithImport, showAbout, showDebugLog, + showKeyboardShortcuts, showSettings, } = options; @@ -131,12 +132,17 @@ exports.createTemplate = (options, messages) => { role: 'help', submenu: [ { - label: messages.goToReleaseNotes.message, - click: openReleaseNotes, + label: messages.helpMenuShowKeyboardShortcuts.message, + accelerator: 'CmdOrCtrl+/', + click: showKeyboardShortcuts, }, { type: 'separator', }, + { + label: messages.goToReleaseNotes.message, + click: openReleaseNotes, + }, { label: messages.goToForums.message, click: openForums, diff --git a/background.html b/background.html index c0da6a5288ac..2f213bbfe4cf 100644 --- a/background.html +++ b/background.html @@ -111,19 +111,19 @@ @@ -155,13 +155,13 @@