From bfaf41596bda297d0de1b77b998e099813c22c9c Mon Sep 17 00:00:00 2001 From: Lim Chee Aun Date: Mon, 22 Sep 2025 10:55:15 +0800 Subject: [PATCH] 'q' keyboard shortcut for Quote --- src/components/keyboard-shortcuts-help.jsx | 4 + src/components/status.jsx | 31 +++++ src/locales/en.po | 127 +++++++++++---------- 3 files changed, 99 insertions(+), 63 deletions(-) diff --git a/src/components/keyboard-shortcuts-help.jsx b/src/components/keyboard-shortcuts-help.jsx index 7f42add9..fee32685 100644 --- a/src/components/keyboard-shortcuts-help.jsx +++ b/src/components/keyboard-shortcuts-help.jsx @@ -180,6 +180,10 @@ export default memo(function KeyboardShortcutsHelp() { ), }, + { + action: t`Quote`, + keys: q, + }, { action: t`Bookmark`, keys: d, diff --git a/src/components/status.jsx b/src/components/status.jsx index 07ea2d54..39b662ad 100644 --- a/src/components/status.jsx +++ b/src/components/status.jsx @@ -1677,6 +1677,36 @@ function Status({ ignoreEventWhen: (e) => e.metaKey || e.ctrlKey || e.altKey || e.shiftKey, }, ); + const qRef = useHotkeys( + 'q', + (e) => { + if (!sameInstance || !authenticated) { + return alert(unauthInteractionErrorMessage); + } + + if (supportsNativeQuote) { + if (quoteDisabled) { + showToast(quoteMetaText); + } else { + showCompose({ + quoteStatus: status, + }); + } + // Don't fallback to non-native if quoteDisabled + } else { + showCompose({ + draftStatus: { + status: `\n${url}`, + }, + }); + } + }, + { + enabled: hotkeysEnabled, + useKey: true, + ignoreEventWhen: (e) => e.metaKey || e.ctrlKey || e.altKey || e.shiftKey, + }, + ); const displayedMediaAttachments = mediaAttachments.slice( 0, @@ -1830,6 +1860,7 @@ function Status({ dRef.current = nodeRef; bRef.current = nodeRef; xRef.current = nodeRef; + qRef.current = nodeRef; }} tabindex="-1" class={`status ${ diff --git a/src/locales/en.po b/src/locales/en.po index e9e03a31..18ea9d8b 100644 --- a/src/locales/en.po +++ b/src/locales/en.po @@ -115,11 +115,11 @@ msgstr "" #: src/components/media-attachment.jsx:380 #: src/components/media-modal.jsx:363 #: src/components/related-actions.jsx:238 -#: src/components/status.jsx:1942 -#: src/components/status.jsx:1959 -#: src/components/status.jsx:2095 -#: src/components/status.jsx:2748 -#: src/components/status.jsx:2751 +#: src/components/status.jsx:1973 +#: src/components/status.jsx:1990 +#: src/components/status.jsx:2126 +#: src/components/status.jsx:2779 +#: src/components/status.jsx:2782 #: src/pages/account-statuses.jsx:539 #: src/pages/accounts.jsx:118 #: src/pages/hashtag.jsx:203 @@ -224,7 +224,7 @@ msgid "Original" msgstr "" #: src/components/account-info.jsx:943 -#: src/components/status.jsx:2504 +#: src/components/status.jsx:2535 #: src/pages/catchup.jsx:70 #: src/pages/catchup.jsx:1446 #: src/pages/catchup.jsx:2059 @@ -274,8 +274,8 @@ msgstr "View post stats" #: src/components/shortcuts-settings.jsx:230 #: src/components/shortcuts-settings.jsx:583 #: src/components/shortcuts-settings.jsx:783 -#: src/components/status.jsx:2983 -#: src/components/status.jsx:3195 +#: src/components/status.jsx:3014 +#: src/components/status.jsx:3226 #: src/components/translated-bio-sheet.jsx:21 #: src/pages/accounts.jsx:45 #: src/pages/catchup.jsx:1582 @@ -494,7 +494,7 @@ msgid "Attachment #{i} failed" msgstr "Attachment #{i} failed" #: src/components/compose.jsx:1305 -#: src/components/status.jsx:2279 +#: src/components/status.jsx:2310 #: src/components/timeline.jsx:1016 msgid "Content warning" msgstr "" @@ -572,7 +572,7 @@ msgid "Quiet public" msgstr "Quiet public" #: src/components/compose.jsx:1762 -#: src/components/status.jsx:2159 +#: src/components/status.jsx:2190 #: src/utils/visibility-text.jsx:8 msgid "Private mention" msgstr "" @@ -584,9 +584,9 @@ msgstr "Schedule" #: src/components/compose.jsx:1816 #: src/components/keyboard-shortcuts-help.jsx:155 #: src/components/status.jsx:1038 -#: src/components/status.jsx:1922 -#: src/components/status.jsx:1923 -#: src/components/status.jsx:2623 +#: src/components/status.jsx:1953 +#: src/components/status.jsx:1954 +#: src/components/status.jsx:2654 msgid "Reply" msgstr "" @@ -696,6 +696,7 @@ msgid "Media" msgstr "" #: src/components/drafts.jsx:255 +#: src/components/keyboard-shortcuts-help.jsx:184 #: src/components/status.jsx:706 msgid "Quote" msgstr "" @@ -970,9 +971,9 @@ msgstr "" #: src/components/keyboard-shortcuts-help.jsx:176 #: src/components/status.jsx:1046 -#: src/components/status.jsx:2650 -#: src/components/status.jsx:2701 -#: src/components/status.jsx:2702 +#: src/components/status.jsx:2681 +#: src/components/status.jsx:2732 +#: src/components/status.jsx:2733 msgid "Boost" msgstr "" @@ -980,18 +981,18 @@ msgstr "" msgid "<0>Shift + <1>b" msgstr "" -#: src/components/keyboard-shortcuts-help.jsx:184 +#: src/components/keyboard-shortcuts-help.jsx:188 #: src/components/status.jsx:1139 -#: src/components/status.jsx:2727 -#: src/components/status.jsx:2728 +#: src/components/status.jsx:2758 +#: src/components/status.jsx:2759 msgid "Bookmark" msgstr "" -#: src/components/keyboard-shortcuts-help.jsx:188 +#: src/components/keyboard-shortcuts-help.jsx:192 msgid "Toggle Cloak mode" msgstr "" -#: src/components/keyboard-shortcuts-help.jsx:190 +#: src/components/keyboard-shortcuts-help.jsx:194 msgid "<0>Shift + <1>Alt + <2>k" msgstr "" @@ -1200,8 +1201,8 @@ msgstr "" #: src/components/media-post.jsx:133 #: src/components/status-compact.jsx:70 -#: src/components/status.jsx:3121 -#: src/components/status.jsx:3199 +#: src/components/status.jsx:3152 +#: src/components/status.jsx:3230 #: src/components/timeline.jsx:1005 #: src/pages/catchup.jsx:74 #: src/pages/catchup.jsx:1878 @@ -2472,13 +2473,13 @@ msgstr "" #: src/components/status.jsx:1046 #: src/components/status.jsx:1116 -#: src/components/status.jsx:2650 -#: src/components/status.jsx:2701 +#: src/components/status.jsx:2681 +#: src/components/status.jsx:2732 msgid "Unboost" msgstr "" #: src/components/status.jsx:1085 -#: src/components/status.jsx:2688 +#: src/components/status.jsx:2719 msgid "Quote with link" msgstr "Quote with link" @@ -2499,21 +2500,21 @@ msgid "Boost…" msgstr "" #: src/components/status.jsx:1129 -#: src/components/status.jsx:1932 -#: src/components/status.jsx:2715 +#: src/components/status.jsx:1963 +#: src/components/status.jsx:2746 msgid "Unlike" msgstr "" #: src/components/status.jsx:1130 -#: src/components/status.jsx:1932 -#: src/components/status.jsx:1933 -#: src/components/status.jsx:2715 -#: src/components/status.jsx:2716 +#: src/components/status.jsx:1963 +#: src/components/status.jsx:1964 +#: src/components/status.jsx:2746 +#: src/components/status.jsx:2747 msgid "Like" msgstr "" #: src/components/status.jsx:1139 -#: src/components/status.jsx:2727 +#: src/components/status.jsx:2758 msgid "Unbookmark" msgstr "" @@ -2632,98 +2633,98 @@ msgstr "Remove quote…" msgid "Report post…" msgstr "" -#: src/components/status.jsx:1933 -#: src/components/status.jsx:1969 -#: src/components/status.jsx:2716 +#: src/components/status.jsx:1964 +#: src/components/status.jsx:2000 +#: src/components/status.jsx:2747 msgid "Liked" msgstr "" -#: src/components/status.jsx:1966 -#: src/components/status.jsx:2702 +#: src/components/status.jsx:1997 +#: src/components/status.jsx:2733 msgid "Boosted" msgstr "" -#: src/components/status.jsx:1976 -#: src/components/status.jsx:2728 +#: src/components/status.jsx:2007 +#: src/components/status.jsx:2759 msgid "Bookmarked" msgstr "" -#: src/components/status.jsx:1980 +#: src/components/status.jsx:2011 msgid "Pinned" msgstr "" -#: src/components/status.jsx:2037 -#: src/components/status.jsx:2512 +#: src/components/status.jsx:2068 +#: src/components/status.jsx:2543 msgid "Deleted" msgstr "" -#: src/components/status.jsx:2078 +#: src/components/status.jsx:2109 msgid "{repliesCount, plural, one {# reply} other {# replies}}" msgstr "" -#: src/components/status.jsx:2242 -#: src/components/status.jsx:2304 -#: src/components/status.jsx:2407 +#: src/components/status.jsx:2273 +#: src/components/status.jsx:2335 +#: src/components/status.jsx:2438 msgid "Show less" msgstr "" -#: src/components/status.jsx:2242 -#: src/components/status.jsx:2304 +#: src/components/status.jsx:2273 +#: src/components/status.jsx:2335 msgid "Show content" msgstr "" #. placeholder {0}: filterInfo.titlesStr #. placeholder {0}: filterInfo?.titlesStr -#: src/components/status.jsx:2403 +#: src/components/status.jsx:2434 #: src/pages/catchup.jsx:1877 msgid "Filtered: {0}" msgstr "Filtered: {0}" -#: src/components/status.jsx:2407 +#: src/components/status.jsx:2438 msgid "Show media" msgstr "" -#: src/components/status.jsx:2547 +#: src/components/status.jsx:2578 msgid "Edited" msgstr "" -#: src/components/status.jsx:2624 +#: src/components/status.jsx:2655 msgid "Comments" msgstr "" -#: src/components/status.jsx:2868 +#: src/components/status.jsx:2899 msgid "Post hidden by your filters" msgstr "Post hidden by your filters" -#: src/components/status.jsx:2869 +#: src/components/status.jsx:2900 msgid "Post pending" msgstr "Post pending" -#: src/components/status.jsx:2870 -#: src/components/status.jsx:2871 -#: src/components/status.jsx:2872 +#: src/components/status.jsx:2901 +#: src/components/status.jsx:2902 +#: src/components/status.jsx:2903 msgid "Post unavailable" msgstr "Post unavailable" -#: src/components/status.jsx:2873 +#: src/components/status.jsx:2904 msgid "Post removed by author" msgstr "Post removed by author" -#: src/components/status.jsx:2988 +#: src/components/status.jsx:3019 msgid "Edit History" msgstr "" -#: src/components/status.jsx:2992 +#: src/components/status.jsx:3023 msgid "Failed to load history" msgstr "" -#: src/components/status.jsx:2997 +#: src/components/status.jsx:3028 #: src/pages/annual-report.jsx:45 msgid "Loading…" msgstr "" #. [Name] [Visibility icon] boosted -#: src/components/status.jsx:3129 +#: src/components/status.jsx:3160 msgid "<0/> <1/> boosted" msgstr "<0/> <1/> boosted"