mirror of
https://github.com/cheeaun/phanpy.git
synced 2025-01-22 08:36:21 +01:00
Fix text expander not working correctly in lists
This commit is contained in:
parent
0f6e2b0946
commit
b4ecff6e46
2 changed files with 85 additions and 53 deletions
|
@ -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);
|
||||
|
|
102
src/locales/en.po
generated
102
src/locales/en.po
generated
|
@ -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:2624
|
||||
#: 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:2580
|
||||
#: src/components/compose.jsx:3054
|
||||
#: src/components/compose.jsx:3263
|
||||
#: src/components/compose.jsx:3493
|
||||
#: 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:3112
|
||||
#: 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:1884
|
||||
#: src/components/compose.jsx:1961
|
||||
#: src/components/nav-menu.jsx:239
|
||||
msgid "More…"
|
||||
msgstr ""
|
||||
|
||||
#: src/components/compose.jsx:2361
|
||||
#: src/components/compose.jsx:2393
|
||||
msgid "Uploaded"
|
||||
msgstr ""
|
||||
|
||||
#: src/components/compose.jsx:2374
|
||||
#: src/components/compose.jsx:2406
|
||||
msgid "Image description"
|
||||
msgstr "Image description"
|
||||
|
||||
#: src/components/compose.jsx:2375
|
||||
#: src/components/compose.jsx:2407
|
||||
msgid "Video description"
|
||||
msgstr "Video description"
|
||||
|
||||
#: src/components/compose.jsx:2376
|
||||
#: src/components/compose.jsx:2408
|
||||
msgid "Audio description"
|
||||
msgstr "Audio description"
|
||||
|
||||
#. placeholder {0}: prettyBytes( imageSize, )
|
||||
#. placeholder {1}: prettyBytes(imageSizeLimit)
|
||||
#: src/components/compose.jsx:2412
|
||||
#: src/components/compose.jsx:2444
|
||||
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:2456
|
||||
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:2464
|
||||
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:2476
|
||||
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:2484
|
||||
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:2544
|
||||
#: src/components/compose.jsx:2794
|
||||
#: 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:2561
|
||||
#: src/compose.jsx:84
|
||||
msgid "Error"
|
||||
msgstr ""
|
||||
|
||||
#: src/components/compose.jsx:2554
|
||||
#: src/components/compose.jsx:2586
|
||||
msgid "Edit image description"
|
||||
msgstr "Edit image description"
|
||||
|
||||
#: src/components/compose.jsx:2555
|
||||
#: src/components/compose.jsx:2587
|
||||
msgid "Edit video description"
|
||||
msgstr "Edit video description"
|
||||
|
||||
#: src/components/compose.jsx:2556
|
||||
#: src/components/compose.jsx:2588
|
||||
msgid "Edit audio description"
|
||||
msgstr "Edit audio description"
|
||||
|
||||
#: src/components/compose.jsx:2601
|
||||
#: src/components/compose.jsx:2650
|
||||
#: src/components/compose.jsx:2633
|
||||
#: src/components/compose.jsx:2682
|
||||
msgid "Generating description. Please wait…"
|
||||
msgstr "Generating description. Please wait…"
|
||||
|
||||
#. placeholder {12}: e.message
|
||||
#: src/components/compose.jsx:2621
|
||||
#: src/components/compose.jsx:2653
|
||||
msgid "Failed to generate description: {12}"
|
||||
msgstr "Failed to generate description: {12}"
|
||||
|
||||
#: src/components/compose.jsx:2622
|
||||
#: src/components/compose.jsx:2654
|
||||
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:2666
|
||||
#: src/components/compose.jsx:2672
|
||||
#: src/components/compose.jsx:2718
|
||||
msgid "Generate description…"
|
||||
msgstr ""
|
||||
|
||||
#. placeholder {13}: e?.message ? `: ${e.message}` : ''
|
||||
#: src/components/compose.jsx:2673
|
||||
#: src/components/compose.jsx:2705
|
||||
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:2720
|
||||
msgid "({0}) <0>— experimental</0>"
|
||||
msgstr ""
|
||||
|
||||
#: src/components/compose.jsx:2707
|
||||
#: src/components/compose.jsx:2739
|
||||
msgid "Done"
|
||||
msgstr ""
|
||||
|
||||
#. placeholder {0}: i + 1
|
||||
#: src/components/compose.jsx:2743
|
||||
#: src/components/compose.jsx:2775
|
||||
msgid "Choice {0}"
|
||||
msgstr "Choice {0}"
|
||||
|
||||
#: src/components/compose.jsx:2790
|
||||
#: src/components/compose.jsx:2822
|
||||
msgid "Multiple choices"
|
||||
msgstr ""
|
||||
|
||||
#: src/components/compose.jsx:2793
|
||||
#: src/components/compose.jsx:2825
|
||||
msgid "Duration"
|
||||
msgstr ""
|
||||
|
||||
#: src/components/compose.jsx:2824
|
||||
#: src/components/compose.jsx:2856
|
||||
msgid "Remove poll"
|
||||
msgstr ""
|
||||
|
||||
#: src/components/compose.jsx:3039
|
||||
#: src/components/compose.jsx:3071
|
||||
msgid "Search accounts"
|
||||
msgstr "Search accounts"
|
||||
|
||||
#: src/components/compose.jsx:3093
|
||||
#: src/components/compose.jsx:3125
|
||||
#: src/components/generic-accounts.jsx:228
|
||||
msgid "Error loading accounts"
|
||||
msgstr ""
|
||||
|
||||
#: src/components/compose.jsx:3237
|
||||
#: src/components/compose.jsx:3269
|
||||
msgid "Custom emojis"
|
||||
msgstr ""
|
||||
|
||||
#: src/components/compose.jsx:3257
|
||||
#: src/components/compose.jsx:3289
|
||||
msgid "Search emoji"
|
||||
msgstr "Search emoji"
|
||||
|
||||
#: src/components/compose.jsx:3288
|
||||
#: src/components/compose.jsx:3320
|
||||
msgid "Error loading custom emojis"
|
||||
msgstr ""
|
||||
|
||||
#: src/components/compose.jsx:3299
|
||||
#: src/components/compose.jsx:3331
|
||||
msgid "Recently used"
|
||||
msgstr "Recently used"
|
||||
|
||||
#: src/components/compose.jsx:3300
|
||||
#: src/components/compose.jsx:3332
|
||||
msgid "Others"
|
||||
msgstr "Others"
|
||||
|
||||
#. placeholder {0}: i18n.number(emojis.length - max)
|
||||
#: src/components/compose.jsx:3338
|
||||
#: src/components/compose.jsx:3370
|
||||
msgid "{0} more…"
|
||||
msgstr ""
|
||||
|
||||
#: src/components/compose.jsx:3476
|
||||
#: src/components/compose.jsx:3508
|
||||
msgid "Search GIFs"
|
||||
msgstr "Search GIFs"
|
||||
|
||||
#: src/components/compose.jsx:3491
|
||||
#: src/components/compose.jsx:3523
|
||||
msgid "Powered by GIPHY"
|
||||
msgstr "Powered by GIPHY"
|
||||
|
||||
#: src/components/compose.jsx:3499
|
||||
#: src/components/compose.jsx:3531
|
||||
msgid "Type to search GIFs"
|
||||
msgstr ""
|
||||
|
||||
#: src/components/compose.jsx:3597
|
||||
#: src/components/compose.jsx:3629
|
||||
#: src/components/media-modal.jsx:462
|
||||
#: src/components/timeline.jsx:893
|
||||
msgid "Previous"
|
||||
msgstr ""
|
||||
|
||||
#: src/components/compose.jsx:3615
|
||||
#: src/components/compose.jsx:3647
|
||||
#: src/components/media-modal.jsx:481
|
||||
#: src/components/timeline.jsx:910
|
||||
msgid "Next"
|
||||
msgstr ""
|
||||
|
||||
#: src/components/compose.jsx:3632
|
||||
#: src/components/compose.jsx:3664
|
||||
msgid "Error loading GIFs"
|
||||
msgstr ""
|
||||
|
||||
|
|
Loading…
Reference in a new issue