diff --git a/src/components/compose.jsx b/src/components/compose.jsx index e3d6b19f8..2a4dca8fe 100644 --- a/src/components/compose.jsx +++ b/src/components/compose.jsx @@ -1840,8 +1840,13 @@ const Textarea = forwardRef((props, ref) => { const textExpanderRef = useRef(); const textExpanderTextRef = useRef(''); + const hasTextExpanderRef = useRef(false); useEffect(() => { - let handleChange, handleValue, handleCommited; + let handleChange, + handleValue, + handleCommited, + handleActivate, + handleDeactivate; if (textExpanderRef.current) { handleChange = (e) => { // console.log('text-expander-change', e); @@ -2022,6 +2027,24 @@ const Textarea = forwardRef((props, ref) => { 'text-expander-committed', handleCommited, ); + + handleActivate = () => { + hasTextExpanderRef.current = true; + }; + + textExpanderRef.current.addEventListener( + 'text-expander-activate', + handleActivate, + ); + + handleDeactivate = () => { + hasTextExpanderRef.current = false; + }; + + textExpanderRef.current.addEventListener( + 'text-expander-deactivate', + handleDeactivate, + ); } return () => { @@ -2038,6 +2061,14 @@ const Textarea = forwardRef((props, ref) => { 'text-expander-committed', handleCommited, ); + textExpanderRef.current.removeEventListener( + 'text-expander-activate', + handleActivate, + ); + textExpanderRef.current.removeEventListener( + 'text-expander-deactivate', + handleDeactivate, + ); } }; }, []); @@ -2127,7 +2158,8 @@ const Textarea = forwardRef((props, ref) => { onKeyDown={(e) => { // Get line before cursor position after pressing 'Enter' const { key, target } = e; - if (key === 'Enter' && !(e.ctrlKey || e.metaKey)) { + const hasTextExpander = hasTextExpanderRef.current; + if (key === 'Enter' && !(e.ctrlKey || e.metaKey || hasTextExpander)) { try { const { value, selectionStart } = target; const textBeforeCursor = value.slice(0, selectionStart); diff --git a/src/locales/en.po b/src/locales/en.po index afb6d9fb3..8f3072389 100644 --- a/src/locales/en.po +++ b/src/locales/en.po @@ -108,7 +108,7 @@ msgstr "" #: src/components/account-info.jsx:429 #: src/components/account-info.jsx:1120 -#: src/components/compose.jsx:2592 +#: src/components/compose.jsx:2620 #: src/components/media-alt-modal.jsx:46 #: src/components/media-modal.jsx:358 #: src/components/status.jsx:1737 @@ -419,10 +419,10 @@ msgstr "" #: src/components/account-info.jsx:2098 #: src/components/account-sheet.jsx:38 #: src/components/compose.jsx:859 -#: src/components/compose.jsx:2548 -#: src/components/compose.jsx:3022 -#: src/components/compose.jsx:3231 -#: src/components/compose.jsx:3461 +#: src/components/compose.jsx:2576 +#: src/components/compose.jsx:3050 +#: src/components/compose.jsx:3259 +#: src/components/compose.jsx:3489 #: src/components/drafts.jsx:59 #: src/components/embed-modal.jsx:13 #: src/components/generic-accounts.jsx:143 @@ -706,7 +706,7 @@ msgid "Mark media as sensitive" msgstr "" #: src/components/compose.jsx:1381 -#: src/components/compose.jsx:3080 +#: src/components/compose.jsx:3108 #: src/components/shortcuts-settings.jsx:715 #: src/pages/list.jsx:362 msgid "Add" @@ -738,31 +738,31 @@ msgstr "Downloading GIF…" msgid "Failed to download GIF" msgstr "Failed to download GIF" -#: src/components/compose.jsx:1879 -#: src/components/compose.jsx:1956 +#: src/components/compose.jsx:1880 +#: src/components/compose.jsx:1957 #: src/components/nav-menu.jsx:239 msgid "More…" msgstr "" -#: src/components/compose.jsx:2361 +#: src/components/compose.jsx:2389 msgid "Uploaded" msgstr "" -#: src/components/compose.jsx:2374 +#: src/components/compose.jsx:2402 msgid "Image description" msgstr "Image description" -#: src/components/compose.jsx:2375 +#: src/components/compose.jsx:2403 msgid "Video description" msgstr "Video description" -#: src/components/compose.jsx:2376 +#: src/components/compose.jsx:2404 msgid "Audio description" msgstr "Audio description" #. placeholder {0}: prettyBytes( imageSize, ) #. placeholder {1}: prettyBytes(imageSizeLimit) -#: src/components/compose.jsx:2412 +#: src/components/compose.jsx:2440 msgid "File size too large. Uploading might encounter issues. Try reduce the file size from {0} to {1} or lower." msgstr "File size too large. Uploading might encounter issues. Try reduce the file size from {0} to {1} or lower." @@ -770,13 +770,13 @@ msgstr "File size too large. Uploading might encounter issues. Try reduce the fi #. placeholder {3}: i18n.number(height) #. placeholder {4}: i18n.number(newWidth) #. placeholder {5}: i18n.number( newHeight, ) -#: src/components/compose.jsx:2424 +#: src/components/compose.jsx:2452 msgid "Dimension too large. Uploading might encounter issues. Try reduce dimension from {2}×{3}px to {4}×{5}px." msgstr "Dimension too large. Uploading might encounter issues. Try reduce dimension from {2}×{3}px to {4}×{5}px." #. placeholder {6}: prettyBytes( videoSize, ) #. placeholder {7}: prettyBytes(videoSizeLimit) -#: src/components/compose.jsx:2432 +#: src/components/compose.jsx:2460 msgid "File size too large. Uploading might encounter issues. Try reduce the file size from {6} to {7} or lower." msgstr "File size too large. Uploading might encounter issues. Try reduce the file size from {6} to {7} or lower." @@ -784,149 +784,149 @@ msgstr "File size too large. Uploading might encounter issues. Try reduce the fi #. placeholder {9}: i18n.number(height) #. placeholder {10}: i18n.number(newWidth) #. placeholder {11}: i18n.number( newHeight, ) -#: src/components/compose.jsx:2444 +#: src/components/compose.jsx:2472 msgid "Dimension too large. Uploading might encounter issues. Try reduce dimension from {8}×{9}px to {10}×{11}px." msgstr "Dimension too large. Uploading might encounter issues. Try reduce dimension from {8}×{9}px to {10}×{11}px." -#: src/components/compose.jsx:2452 +#: src/components/compose.jsx:2480 msgid "Frame rate too high. Uploading might encounter issues." msgstr "Frame rate too high. Uploading might encounter issues." -#: src/components/compose.jsx:2512 -#: src/components/compose.jsx:2762 +#: src/components/compose.jsx:2540 +#: src/components/compose.jsx:2790 #: src/components/shortcuts-settings.jsx:726 #: src/pages/catchup.jsx:1074 #: src/pages/filters.jsx:412 msgid "Remove" msgstr "" -#: src/components/compose.jsx:2529 +#: src/components/compose.jsx:2557 #: src/compose.jsx:84 msgid "Error" msgstr "" -#: src/components/compose.jsx:2554 +#: src/components/compose.jsx:2582 msgid "Edit image description" msgstr "Edit image description" -#: src/components/compose.jsx:2555 +#: src/components/compose.jsx:2583 msgid "Edit video description" msgstr "Edit video description" -#: src/components/compose.jsx:2556 +#: src/components/compose.jsx:2584 msgid "Edit audio description" msgstr "Edit audio description" -#: src/components/compose.jsx:2601 -#: src/components/compose.jsx:2650 +#: src/components/compose.jsx:2629 +#: src/components/compose.jsx:2678 msgid "Generating description. Please wait…" msgstr "Generating description. Please wait…" #. placeholder {12}: e.message -#: src/components/compose.jsx:2621 +#: src/components/compose.jsx:2649 msgid "Failed to generate description: {12}" msgstr "Failed to generate description: {12}" -#: src/components/compose.jsx:2622 +#: src/components/compose.jsx:2650 msgid "Failed to generate description" msgstr "Failed to generate description" -#: src/components/compose.jsx:2634 -#: src/components/compose.jsx:2640 -#: src/components/compose.jsx:2686 +#: src/components/compose.jsx:2662 +#: src/components/compose.jsx:2668 +#: src/components/compose.jsx:2714 msgid "Generate description…" msgstr "" #. placeholder {13}: e?.message ? `: ${e.message}` : '' -#: src/components/compose.jsx:2673 +#: src/components/compose.jsx:2701 msgid "Failed to generate description{13}" msgstr "Failed to generate description{13}" #. placeholder {0}: localeCode2Text(lang) -#: src/components/compose.jsx:2688 +#: src/components/compose.jsx:2716 msgid "({0}) <0>— experimental" msgstr "" -#: src/components/compose.jsx:2707 +#: src/components/compose.jsx:2735 msgid "Done" msgstr "" #. placeholder {0}: i + 1 -#: src/components/compose.jsx:2743 +#: src/components/compose.jsx:2771 msgid "Choice {0}" msgstr "Choice {0}" -#: src/components/compose.jsx:2790 +#: src/components/compose.jsx:2818 msgid "Multiple choices" msgstr "" -#: src/components/compose.jsx:2793 +#: src/components/compose.jsx:2821 msgid "Duration" msgstr "" -#: src/components/compose.jsx:2824 +#: src/components/compose.jsx:2852 msgid "Remove poll" msgstr "" -#: src/components/compose.jsx:3039 +#: src/components/compose.jsx:3067 msgid "Search accounts" msgstr "Search accounts" -#: src/components/compose.jsx:3093 +#: src/components/compose.jsx:3121 #: src/components/generic-accounts.jsx:228 msgid "Error loading accounts" msgstr "" -#: src/components/compose.jsx:3237 +#: src/components/compose.jsx:3265 msgid "Custom emojis" msgstr "" -#: src/components/compose.jsx:3257 +#: src/components/compose.jsx:3285 msgid "Search emoji" msgstr "Search emoji" -#: src/components/compose.jsx:3288 +#: src/components/compose.jsx:3316 msgid "Error loading custom emojis" msgstr "" -#: src/components/compose.jsx:3299 +#: src/components/compose.jsx:3327 msgid "Recently used" msgstr "Recently used" -#: src/components/compose.jsx:3300 +#: src/components/compose.jsx:3328 msgid "Others" msgstr "Others" #. placeholder {0}: i18n.number(emojis.length - max) -#: src/components/compose.jsx:3338 +#: src/components/compose.jsx:3366 msgid "{0} more…" msgstr "" -#: src/components/compose.jsx:3476 +#: src/components/compose.jsx:3504 msgid "Search GIFs" msgstr "Search GIFs" -#: src/components/compose.jsx:3491 +#: src/components/compose.jsx:3519 msgid "Powered by GIPHY" msgstr "Powered by GIPHY" -#: src/components/compose.jsx:3499 +#: src/components/compose.jsx:3527 msgid "Type to search GIFs" msgstr "" -#: src/components/compose.jsx:3597 +#: src/components/compose.jsx:3625 #: src/components/media-modal.jsx:462 #: src/components/timeline.jsx:893 msgid "Previous" msgstr "" -#: src/components/compose.jsx:3615 +#: src/components/compose.jsx:3643 #: src/components/media-modal.jsx:481 #: src/components/timeline.jsx:910 msgid "Next" msgstr "" -#: src/components/compose.jsx:3632 +#: src/components/compose.jsx:3660 msgid "Error loading GIFs" msgstr ""