|
| 1 | +diff --git a/node_modules/@expensify/react-native-live-markdown/lib/module/MarkdownTextInput.web.js b/node_modules/@expensify/react-native-live-markdown/lib/module/MarkdownTextInput.web.js |
| 2 | +index e36195f..3a3ae72 100644 |
| 3 | +--- a/node_modules/@expensify/react-native-live-markdown/lib/module/MarkdownTextInput.web.js |
| 4 | ++++ b/node_modules/@expensify/react-native-live-markdown/lib/module/MarkdownTextInput.web.js |
| 5 | +@@ -21,6 +21,7 @@ const MarkdownTextInput = /*#__PURE__*/React.forwardRef(({ |
| 6 | + autoCapitalize = 'sentences', |
| 7 | + autoCorrect = true, |
| 8 | + blurOnSubmit = false, |
| 9 | ++ submitBehavior, |
| 10 | + caretHidden, |
| 11 | + clearTextOnFocus, |
| 12 | + dir = 'auto', |
| 13 | +@@ -359,8 +360,19 @@ const MarkdownTextInput = /*#__PURE__*/React.forwardRef(({ |
| 14 | + handleOnChangeText(e); |
| 15 | + return; |
| 16 | + } |
| 17 | +- const blurOnSubmitDefault = !multiline; |
| 18 | +- const shouldBlurOnSubmit = blurOnSubmit === null ? blurOnSubmitDefault : blurOnSubmit; |
| 19 | ++ // Support submitBehavior prop (React Native 0.73+), fallback to blurOnSubmit for backwards compatibility |
| 20 | ++ let shouldBlurOnSubmit; |
| 21 | ++ let shouldSubmit; |
| 22 | ++ if (submitBehavior != null) { |
| 23 | ++ // submitBehavior takes precedence over blurOnSubmit |
| 24 | ++ shouldSubmit = submitBehavior === 'submit' || submitBehavior === 'blurAndSubmit'; |
| 25 | ++ shouldBlurOnSubmit = submitBehavior === 'blurAndSubmit'; |
| 26 | ++ } else { |
| 27 | ++ // Fallback to blurOnSubmit logic for backwards compatibility |
| 28 | ++ const blurOnSubmitDefault = !multiline; |
| 29 | ++ shouldBlurOnSubmit = blurOnSubmit === null ? blurOnSubmitDefault : blurOnSubmit; |
| 30 | ++ shouldSubmit = blurOnSubmit || !multiline; |
| 31 | ++ } |
| 32 | + const nativeEvent = e.nativeEvent; |
| 33 | + const isComposing = isEventComposing(nativeEvent); |
| 34 | + const event = e; |
| 35 | +@@ -373,18 +385,19 @@ const MarkdownTextInput = /*#__PURE__*/React.forwardRef(({ |
| 36 | + !isComposing && !e.isDefaultPrevented()) { |
| 37 | + // prevent "Enter" from inserting a newline or submitting a form |
| 38 | + e.preventDefault(); |
| 39 | +- if (!e.shiftKey && (blurOnSubmit || !multiline) && onSubmitEditing) { |
| 40 | ++ // submitBehavior === 'newline' means don't submit, just insert newline (default behavior) |
| 41 | ++ if (!e.shiftKey && shouldSubmit && onSubmitEditing) { |
| 42 | + onSubmitEditing(event); |
| 43 | +- } else if (multiline) { |
| 44 | ++ } else if (multiline && (!shouldSubmit || e.shiftKey)) { |
| 45 | + // We need to change normal behavior of "Enter" key to insert a line breaks, to prevent wrapping contentEditable text in <div> tags. |
| 46 | + // Thanks to that in every situation we have proper amount of new lines in our parsed text. Without it pressing enter in empty lines will add 2 more new lines. |
| 47 | + insertText(e, '\n'); |
| 48 | + } |
| 49 | +- if (!e.shiftKey && (shouldBlurOnSubmit && hostNode !== null || !multiline)) { |
| 50 | ++ if (!e.shiftKey && shouldBlurOnSubmit && hostNode !== null) { |
| 51 | + setTimeout(() => divRef.current && divRef.current.blur(), 0); |
| 52 | + } |
| 53 | + } |
| 54 | +- }, [multiline, blurOnSubmit, setEventProps, onKeyPress, handleOnChangeText, onSubmitEditing, insertText]); |
| 55 | ++ }, [multiline, blurOnSubmit, submitBehavior, setEventProps, onKeyPress, handleOnChangeText, onSubmitEditing, insertText]); |
| 56 | + const handleFocus = useCallback(event => { |
| 57 | + hasJustBeenFocused.current = true; |
| 58 | + const e = event; |
| 59 | +diff --git a/node_modules/@expensify/react-native-live-markdown/src/MarkdownTextInput.web.tsx b/node_modules/@expensify/react-native-live-markdown/src/MarkdownTextInput.web.tsx |
| 60 | +index fa3283d..59f02c6 100644 |
| 61 | +--- a/node_modules/@expensify/react-native-live-markdown/src/MarkdownTextInput.web.tsx |
| 62 | ++++ b/node_modules/@expensify/react-native-live-markdown/src/MarkdownTextInput.web.tsx |
| 63 | +@@ -87,6 +87,7 @@ const MarkdownTextInput = React.forwardRef<MarkdownTextInput, MarkdownTextInputP |
| 64 | + autoCapitalize = 'sentences', |
| 65 | + autoCorrect = true, |
| 66 | + blurOnSubmit = false, |
| 67 | ++ submitBehavior, |
| 68 | + caretHidden, |
| 69 | + clearTextOnFocus, |
| 70 | + dir = 'auto', |
| 71 | +@@ -518,8 +519,20 @@ const MarkdownTextInput = React.forwardRef<MarkdownTextInput, MarkdownTextInputP |
| 72 | + return; |
| 73 | + } |
| 74 | + |
| 75 | +- const blurOnSubmitDefault = !multiline; |
| 76 | +- const shouldBlurOnSubmit = blurOnSubmit === null ? blurOnSubmitDefault : blurOnSubmit; |
| 77 | ++ // Support submitBehavior prop (React Native 0.73+), fallback to blurOnSubmit for backwards compatibility |
| 78 | ++ let shouldBlurOnSubmit: boolean; |
| 79 | ++ let shouldSubmit: boolean; |
| 80 | ++ |
| 81 | ++ if (submitBehavior != null) { |
| 82 | ++ // submitBehavior takes precedence over blurOnSubmit |
| 83 | ++ shouldSubmit = submitBehavior === 'submit' || submitBehavior === 'blurAndSubmit'; |
| 84 | ++ shouldBlurOnSubmit = submitBehavior === 'blurAndSubmit'; |
| 85 | ++ } else { |
| 86 | ++ // Fallback to blurOnSubmit logic for backwards compatibility |
| 87 | ++ const blurOnSubmitDefault = !multiline; |
| 88 | ++ shouldBlurOnSubmit = blurOnSubmit === null ? blurOnSubmitDefault : blurOnSubmit; |
| 89 | ++ shouldSubmit = blurOnSubmit || !multiline; |
| 90 | ++ } |
| 91 | + |
| 92 | + const nativeEvent = e.nativeEvent; |
| 93 | + const isComposing = isEventComposing(nativeEvent); |
| 94 | +@@ -538,19 +551,20 @@ const MarkdownTextInput = React.forwardRef<MarkdownTextInput, MarkdownTextInputP |
| 95 | + ) { |
| 96 | + // prevent "Enter" from inserting a newline or submitting a form |
| 97 | + e.preventDefault(); |
| 98 | +- if (!e.shiftKey && (blurOnSubmit || !multiline) && onSubmitEditing) { |
| 99 | ++ // submitBehavior === 'newline' means don't submit, just insert newline (default behavior) |
| 100 | ++ if (!e.shiftKey && shouldSubmit && onSubmitEditing) { |
| 101 | + onSubmitEditing(event as unknown as NativeSyntheticEvent<TextInputSubmitEditingEventData>); |
| 102 | +- } else if (multiline) { |
| 103 | ++ } else if (multiline && (!shouldSubmit || e.shiftKey)) { |
| 104 | + // We need to change normal behavior of "Enter" key to insert a line breaks, to prevent wrapping contentEditable text in <div> tags. |
| 105 | + // Thanks to that in every situation we have proper amount of new lines in our parsed text. Without it pressing enter in empty lines will add 2 more new lines. |
| 106 | + insertText(e, '\n'); |
| 107 | + } |
| 108 | +- if (!e.shiftKey && ((shouldBlurOnSubmit && hostNode !== null) || !multiline)) { |
| 109 | ++ if (!e.shiftKey && shouldBlurOnSubmit && hostNode !== null) { |
| 110 | + setTimeout(() => divRef.current && divRef.current.blur(), 0); |
| 111 | + } |
| 112 | + } |
| 113 | + }, |
| 114 | +- [multiline, blurOnSubmit, setEventProps, onKeyPress, handleOnChangeText, onSubmitEditing, insertText], |
| 115 | ++ [multiline, blurOnSubmit, submitBehavior, setEventProps, onKeyPress, handleOnChangeText, onSubmitEditing, insertText], |
| 116 | + ); |
| 117 | + |
| 118 | + const handleFocus: FocusEventHandler<HTMLDivElement> = useCallback( |
0 commit comments