From fac5b14ef4826ce53b5eb14374c286403f0de8bd Mon Sep 17 00:00:00 2001 From: Rohit Verma Date: Fri, 18 Apr 2025 20:44:39 +0530 Subject: [PATCH 1/5] fix: binary content appears in composer when pasting image --- ...1+025+fix-android-textinput-onPaste-binary.patch | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 patches/react-native+0.77.1+025+fix-android-textinput-onPaste-binary.patch diff --git a/patches/react-native+0.77.1+025+fix-android-textinput-onPaste-binary.patch b/patches/react-native+0.77.1+025+fix-android-textinput-onPaste-binary.patch new file mode 100644 index 0000000000000..0b14a528bc114 --- /dev/null +++ b/patches/react-native+0.77.1+025+fix-android-textinput-onPaste-binary.patch @@ -0,0 +1,13 @@ +diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactEditText.java b/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactEditText.java +index 840b5f5..a0afd83 100644 +--- a/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactEditText.java ++++ b/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactEditText.java +@@ -357,6 +357,8 @@ public class ReactEditText extends AppCompatEditText { + ContentResolver cr = getReactContext(this).getContentResolver(); + type = cr.getType(itemUri); + data = itemUri.toString(); ++ mPasteWatcher.onPaste(type, data); ++ return true; + } + } + if (type != null && data != null) { From 277110d459bc455208ac071b3a205664a3674f07 Mon Sep 17 00:00:00 2001 From: Rohit Verma Date: Sat, 19 Apr 2025 00:30:37 +0530 Subject: [PATCH 2/5] Revert "fix: binary content appears in composer when pasting image" This reverts commit fac5b14ef4826ce53b5eb14374c286403f0de8bd. --- ...1+025+fix-android-textinput-onPaste-binary.patch | 13 ------------- 1 file changed, 13 deletions(-) delete mode 100644 patches/react-native+0.77.1+025+fix-android-textinput-onPaste-binary.patch diff --git a/patches/react-native+0.77.1+025+fix-android-textinput-onPaste-binary.patch b/patches/react-native+0.77.1+025+fix-android-textinput-onPaste-binary.patch deleted file mode 100644 index 0b14a528bc114..0000000000000 --- a/patches/react-native+0.77.1+025+fix-android-textinput-onPaste-binary.patch +++ /dev/null @@ -1,13 +0,0 @@ -diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactEditText.java b/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactEditText.java -index 840b5f5..a0afd83 100644 ---- a/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactEditText.java -+++ b/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactEditText.java -@@ -357,6 +357,8 @@ public class ReactEditText extends AppCompatEditText { - ContentResolver cr = getReactContext(this).getContentResolver(); - type = cr.getType(itemUri); - data = itemUri.toString(); -+ mPasteWatcher.onPaste(type, data); -+ return true; - } - } - if (type != null && data != null) { From 8e45337d332df90e1da85f2becc850e06b9e3347 Mon Sep 17 00:00:00 2001 From: Rohit Verma Date: Sat, 19 Apr 2025 01:26:25 +0530 Subject: [PATCH 3/5] refactor: update onPaste patch to return early when pasting file --- ...+0.77.1+011+Add-onPaste-to-TextInput.patch | 142 ++++++++++++++++-- 1 file changed, 129 insertions(+), 13 deletions(-) diff --git a/patches/react-native+0.77.1+011+Add-onPaste-to-TextInput.patch b/patches/react-native+0.77.1+011+Add-onPaste-to-TextInput.patch index 0c95505a606ff..bc2e41370a5ab 100644 --- a/patches/react-native+0.77.1+011+Add-onPaste-to-TextInput.patch +++ b/patches/react-native+0.77.1+011+Add-onPaste-to-TextInput.patch @@ -1,3 +1,37 @@ +diff --git a/node_modules/react-native/.project b/node_modules/react-native/.project +new file mode 100644 +index 0000000..7c5b305 +--- /dev/null ++++ b/node_modules/react-native/.project +@@ -0,0 +1,28 @@ ++ ++ ++ react-native-build-from-source-react-native ++ Project react-native-build-from-source-react-native created by Buildship. ++ ++ ++ ++ ++ org.eclipse.buildship.core.gradleprojectbuilder ++ ++ ++ ++ ++ ++ org.eclipse.buildship.core.gradleprojectnature ++ ++ ++ ++ 1745005165151 ++ ++ 30 ++ ++ org.eclipse.core.resources.regexFilterMatcher ++ node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__ ++ ++ ++ ++ diff --git a/node_modules/react-native/Libraries/Components/TextInput/AndroidTextInputNativeComponent.js b/node_modules/react-native/Libraries/Components/TextInput/AndroidTextInputNativeComponent.js index 6c4bbb2..770dfee 100644 --- a/node_modules/react-native/Libraries/Components/TextInput/AndroidTextInputNativeComponent.js @@ -184,7 +218,7 @@ index d5e2e22..065a819 100644 @implementation RCTUITextView { UILabel *_placeholderView; UITextView *_detachedTextView; -@@ -172,7 +176,31 @@ - (void)scrollRangeToVisible:(NSRange)range +@@ -172,7 +176,31 @@ static UIColor *defaultPlaceholderColor(void) - (void)paste:(id)sender { _textWasPasted = YES; @@ -217,7 +251,7 @@ index d5e2e22..065a819 100644 } // Turn off scroll animation to fix flaky scrolling. -@@ -264,6 +292,10 @@ - (BOOL)canPerformAction:(SEL)action withSender:(id)sender +@@ -264,6 +292,10 @@ static UIColor *defaultPlaceholderColor(void) return NO; } @@ -265,7 +299,7 @@ diff --git a/node_modules/react-native/Libraries/Text/TextInput/RCTBackedTextInp index ac8e464..2b91802 100644 --- a/node_modules/react-native/Libraries/Text/TextInput/RCTBackedTextInputDelegateAdapter.mm +++ b/node_modules/react-native/Libraries/Text/TextInput/RCTBackedTextInputDelegateAdapter.mm -@@ -147,6 +147,11 @@ - (void)selectedTextRangeWasSet +@@ -147,6 +147,11 @@ static void *TextFieldSelectionObservingContext = &TextFieldSelectionObservingCo [self textFieldProbablyDidChangeSelection]; } @@ -277,7 +311,7 @@ index ac8e464..2b91802 100644 #pragma mark - Generalization - (void)textFieldProbablyDidChangeSelection -@@ -292,6 +297,11 @@ - (void)skipNextTextInputDidChangeSelectionEventWithTextRange:(UITextRange *)tex +@@ -292,6 +297,11 @@ static void *TextFieldSelectionObservingContext = &TextFieldSelectionObservingCo _previousSelectedTextRange = textRange; } @@ -302,10 +336,10 @@ index 4804624..90b7081 100644 @property (nonatomic, assign) NSInteger mostRecentEventCount; @property (nonatomic, assign, readonly) NSInteger nativeEventCount; diff --git a/node_modules/react-native/Libraries/Text/TextInput/RCTBaseTextInputView.mm b/node_modules/react-native/Libraries/Text/TextInput/RCTBaseTextInputView.mm -index 95edfd5..5111bda 100644 +index 6deea73..4d82c72 100644 --- a/node_modules/react-native/Libraries/Text/TextInput/RCTBaseTextInputView.mm +++ b/node_modules/react-native/Libraries/Text/TextInput/RCTBaseTextInputView.mm -@@ -574,6 +574,26 @@ - (void)textInputDidChangeSelection +@@ -574,6 +574,26 @@ RCT_NOT_IMPLEMENTED(-(instancetype)initWithFrame : (CGRect)frame) }); } @@ -336,7 +370,7 @@ diff --git a/node_modules/react-native/Libraries/Text/TextInput/RCTBaseTextInput index db7c519..ec05595 100644 --- a/node_modules/react-native/Libraries/Text/TextInput/RCTBaseTextInputViewManager.mm +++ b/node_modules/react-native/Libraries/Text/TextInput/RCTBaseTextInputViewManager.mm -@@ -67,6 +67,7 @@ @implementation RCTBaseTextInputViewManager { +@@ -67,6 +67,7 @@ RCT_EXPORT_VIEW_PROPERTY(onClear, RCTDirectEventBlock) RCT_EXPORT_VIEW_PROPERTY(onChangeSync, RCTDirectEventBlock) RCT_EXPORT_VIEW_PROPERTY(onSelectionChange, RCTDirectEventBlock) RCT_EXPORT_VIEW_PROPERTY(onScroll, RCTDirectEventBlock) @@ -359,7 +393,7 @@ index 0318671..667e646 100644 @implementation RCTUITextField { RCTBackedTextFieldDelegateAdapter *_textInputDelegateAdapter; NSDictionary *_defaultTextAttributes; -@@ -139,6 +143,10 @@ - (BOOL)canPerformAction:(SEL)action withSender:(id)sender +@@ -139,6 +143,10 @@ return NO; } @@ -370,7 +404,7 @@ index 0318671..667e646 100644 return [super canPerformAction:action withSender:sender]; } -@@ -222,7 +230,31 @@ - (void)scrollRangeToVisible:(NSRange)range +@@ -222,7 +230,31 @@ - (void)paste:(id)sender { _textWasPasted = YES; @@ -407,7 +441,7 @@ diff --git a/node_modules/react-native/React/Fabric/Mounting/ComponentViews/Text index f8358ed..91aff1a 100644 --- a/node_modules/react-native/React/Fabric/Mounting/ComponentViews/TextInput/RCTTextInputComponentView.mm +++ b/node_modules/react-native/React/Fabric/Mounting/ComponentViews/TextInput/RCTTextInputComponentView.mm -@@ -481,6 +481,13 @@ - (void)textInputDidChangeSelection +@@ -481,6 +481,13 @@ static NSSet *returnKeyTypesSet; } } @@ -421,6 +455,86 @@ index f8358ed..91aff1a 100644 #pragma mark - RCTBackedTextInputDelegate (UIScrollViewDelegate) - (void)scrollViewDidScroll:(UIScrollView *)scrollView +diff --git a/node_modules/react-native/ReactAndroid/.project b/node_modules/react-native/ReactAndroid/.project +new file mode 100644 +index 0000000..533e383 +--- /dev/null ++++ b/node_modules/react-native/ReactAndroid/.project +@@ -0,0 +1,34 @@ ++ ++ ++ ReactAndroid ++ Project ReactAndroid created by Buildship. ++ ++ ++ ++ ++ org.eclipse.jdt.core.javabuilder ++ ++ ++ ++ ++ org.eclipse.buildship.core.gradleprojectbuilder ++ ++ ++ ++ ++ ++ org.eclipse.jdt.core.javanature ++ org.eclipse.buildship.core.gradleprojectnature ++ ++ ++ ++ 1745005165095 ++ ++ 30 ++ ++ org.eclipse.core.resources.regexFilterMatcher ++ node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__ ++ ++ ++ ++ +diff --git a/node_modules/react-native/ReactAndroid/hermes-engine/.project b/node_modules/react-native/ReactAndroid/hermes-engine/.project +new file mode 100644 +index 0000000..f3e5c2d +--- /dev/null ++++ b/node_modules/react-native/ReactAndroid/hermes-engine/.project +@@ -0,0 +1,34 @@ ++ ++ ++ hermes-engine ++ Project hermes-engine created by Buildship. ++ ++ ++ ++ ++ org.eclipse.jdt.core.javabuilder ++ ++ ++ ++ ++ org.eclipse.buildship.core.gradleprojectbuilder ++ ++ ++ ++ ++ ++ org.eclipse.jdt.core.javanature ++ org.eclipse.buildship.core.gradleprojectnature ++ ++ ++ ++ 1745005165138 ++ ++ 30 ++ ++ org.eclipse.core.resources.regexFilterMatcher ++ node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__ ++ ++ ++ ++ diff --git a/node_modules/react-native/ReactAndroid/src/main/java/com/facebook/react/views/textinput/PasteWatcher.java b/node_modules/react-native/ReactAndroid/src/main/java/com/facebook/react/views/textinput/PasteWatcher.java new file mode 100644 index 0000000..bfb5819 @@ -445,7 +559,7 @@ index 0000000..bfb5819 + public void onPaste(String type, String data); +} diff --git a/node_modules/react-native/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactEditText.java b/node_modules/react-native/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactEditText.java -index 56a1069..272ea7d 100644 +index 56a1069..b3feb0a 100644 --- a/node_modules/react-native/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactEditText.java +++ b/node_modules/react-native/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactEditText.java @@ -9,6 +9,10 @@ package com.facebook.react.views.textinput; @@ -483,7 +597,7 @@ index 56a1069..272ea7d 100644 mTextAttributes = new TextAttributes(); applyTextAttributes(); -@@ -332,8 +339,29 @@ public class ReactEditText extends AppCompatEditText { +@@ -332,8 +339,31 @@ public class ReactEditText extends AppCompatEditText { */ @Override public boolean onTextContextMenuItem(int id) { @@ -505,6 +619,8 @@ index 56a1069..272ea7d 100644 + ContentResolver cr = getReactContext(this).getContentResolver(); + type = cr.getType(itemUri); + data = itemUri.toString(); ++ mPasteWatcher.onPaste(type, data); ++ return true; + } + } + if (type != null && data != null) { @@ -514,7 +630,7 @@ index 56a1069..272ea7d 100644 } return super.onTextContextMenuItem(id); } -@@ -395,6 +423,10 @@ public class ReactEditText extends AppCompatEditText { +@@ -395,6 +425,10 @@ public class ReactEditText extends AppCompatEditText { mScrollWatcher = scrollWatcher; } From 2c89910f09d36958b4eb83ee154dd9043ad1ce87 Mon Sep 17 00:00:00 2001 From: Rohit Verma Date: Sun, 20 Apr 2025 11:43:18 +0530 Subject: [PATCH 4/5] refactor: remove unwanted changes from the onPaste patch fix --- ...+0.77.1+011+Add-onPaste-to-TextInput.patch | 134 ++---------------- 1 file changed, 10 insertions(+), 124 deletions(-) diff --git a/patches/react-native+0.77.1+011+Add-onPaste-to-TextInput.patch b/patches/react-native+0.77.1+011+Add-onPaste-to-TextInput.patch index bc2e41370a5ab..0efa4db148e4d 100644 --- a/patches/react-native+0.77.1+011+Add-onPaste-to-TextInput.patch +++ b/patches/react-native+0.77.1+011+Add-onPaste-to-TextInput.patch @@ -1,37 +1,3 @@ -diff --git a/node_modules/react-native/.project b/node_modules/react-native/.project -new file mode 100644 -index 0000000..7c5b305 ---- /dev/null -+++ b/node_modules/react-native/.project -@@ -0,0 +1,28 @@ -+ -+ -+ react-native-build-from-source-react-native -+ Project react-native-build-from-source-react-native created by Buildship. -+ -+ -+ -+ -+ org.eclipse.buildship.core.gradleprojectbuilder -+ -+ -+ -+ -+ -+ org.eclipse.buildship.core.gradleprojectnature -+ -+ -+ -+ 1745005165151 -+ -+ 30 -+ -+ org.eclipse.core.resources.regexFilterMatcher -+ node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__ -+ -+ -+ -+ diff --git a/node_modules/react-native/Libraries/Components/TextInput/AndroidTextInputNativeComponent.js b/node_modules/react-native/Libraries/Components/TextInput/AndroidTextInputNativeComponent.js index 6c4bbb2..770dfee 100644 --- a/node_modules/react-native/Libraries/Components/TextInput/AndroidTextInputNativeComponent.js @@ -218,7 +184,7 @@ index d5e2e22..065a819 100644 @implementation RCTUITextView { UILabel *_placeholderView; UITextView *_detachedTextView; -@@ -172,7 +176,31 @@ static UIColor *defaultPlaceholderColor(void) +@@ -172,7 +176,31 @@ - (void)scrollRangeToVisible:(NSRange)range - (void)paste:(id)sender { _textWasPasted = YES; @@ -251,7 +217,7 @@ index d5e2e22..065a819 100644 } // Turn off scroll animation to fix flaky scrolling. -@@ -264,6 +292,10 @@ static UIColor *defaultPlaceholderColor(void) +@@ -264,6 +292,10 @@ - (BOOL)canPerformAction:(SEL)action withSender:(id)sender return NO; } @@ -299,7 +265,7 @@ diff --git a/node_modules/react-native/Libraries/Text/TextInput/RCTBackedTextInp index ac8e464..2b91802 100644 --- a/node_modules/react-native/Libraries/Text/TextInput/RCTBackedTextInputDelegateAdapter.mm +++ b/node_modules/react-native/Libraries/Text/TextInput/RCTBackedTextInputDelegateAdapter.mm -@@ -147,6 +147,11 @@ static void *TextFieldSelectionObservingContext = &TextFieldSelectionObservingCo +@@ -147,6 +147,11 @@ - (void)selectedTextRangeWasSet [self textFieldProbablyDidChangeSelection]; } @@ -311,7 +277,7 @@ index ac8e464..2b91802 100644 #pragma mark - Generalization - (void)textFieldProbablyDidChangeSelection -@@ -292,6 +297,11 @@ static void *TextFieldSelectionObservingContext = &TextFieldSelectionObservingCo +@@ -292,6 +297,11 @@ - (void)skipNextTextInputDidChangeSelectionEventWithTextRange:(UITextRange *)tex _previousSelectedTextRange = textRange; } @@ -336,10 +302,10 @@ index 4804624..90b7081 100644 @property (nonatomic, assign) NSInteger mostRecentEventCount; @property (nonatomic, assign, readonly) NSInteger nativeEventCount; diff --git a/node_modules/react-native/Libraries/Text/TextInput/RCTBaseTextInputView.mm b/node_modules/react-native/Libraries/Text/TextInput/RCTBaseTextInputView.mm -index 6deea73..4d82c72 100644 +index 95edfd5..5111bda 100644 --- a/node_modules/react-native/Libraries/Text/TextInput/RCTBaseTextInputView.mm +++ b/node_modules/react-native/Libraries/Text/TextInput/RCTBaseTextInputView.mm -@@ -574,6 +574,26 @@ RCT_NOT_IMPLEMENTED(-(instancetype)initWithFrame : (CGRect)frame) +@@ -574,6 +574,26 @@ - (void)textInputDidChangeSelection }); } @@ -370,7 +336,7 @@ diff --git a/node_modules/react-native/Libraries/Text/TextInput/RCTBaseTextInput index db7c519..ec05595 100644 --- a/node_modules/react-native/Libraries/Text/TextInput/RCTBaseTextInputViewManager.mm +++ b/node_modules/react-native/Libraries/Text/TextInput/RCTBaseTextInputViewManager.mm -@@ -67,6 +67,7 @@ RCT_EXPORT_VIEW_PROPERTY(onClear, RCTDirectEventBlock) +@@ -67,6 +67,7 @@ @implementation RCTBaseTextInputViewManager { RCT_EXPORT_VIEW_PROPERTY(onChangeSync, RCTDirectEventBlock) RCT_EXPORT_VIEW_PROPERTY(onSelectionChange, RCTDirectEventBlock) RCT_EXPORT_VIEW_PROPERTY(onScroll, RCTDirectEventBlock) @@ -393,7 +359,7 @@ index 0318671..667e646 100644 @implementation RCTUITextField { RCTBackedTextFieldDelegateAdapter *_textInputDelegateAdapter; NSDictionary *_defaultTextAttributes; -@@ -139,6 +143,10 @@ +@@ -139,6 +143,10 @@ - (BOOL)canPerformAction:(SEL)action withSender:(id)sender return NO; } @@ -404,7 +370,7 @@ index 0318671..667e646 100644 return [super canPerformAction:action withSender:sender]; } -@@ -222,7 +230,31 @@ +@@ -222,7 +230,31 @@ - (void)scrollRangeToVisible:(NSRange)range - (void)paste:(id)sender { _textWasPasted = YES; @@ -441,7 +407,7 @@ diff --git a/node_modules/react-native/React/Fabric/Mounting/ComponentViews/Text index f8358ed..91aff1a 100644 --- a/node_modules/react-native/React/Fabric/Mounting/ComponentViews/TextInput/RCTTextInputComponentView.mm +++ b/node_modules/react-native/React/Fabric/Mounting/ComponentViews/TextInput/RCTTextInputComponentView.mm -@@ -481,6 +481,13 @@ static NSSet *returnKeyTypesSet; +@@ -481,6 +481,13 @@ - (void)textInputDidChangeSelection } } @@ -455,86 +421,6 @@ index f8358ed..91aff1a 100644 #pragma mark - RCTBackedTextInputDelegate (UIScrollViewDelegate) - (void)scrollViewDidScroll:(UIScrollView *)scrollView -diff --git a/node_modules/react-native/ReactAndroid/.project b/node_modules/react-native/ReactAndroid/.project -new file mode 100644 -index 0000000..533e383 ---- /dev/null -+++ b/node_modules/react-native/ReactAndroid/.project -@@ -0,0 +1,34 @@ -+ -+ -+ ReactAndroid -+ Project ReactAndroid created by Buildship. -+ -+ -+ -+ -+ org.eclipse.jdt.core.javabuilder -+ -+ -+ -+ -+ org.eclipse.buildship.core.gradleprojectbuilder -+ -+ -+ -+ -+ -+ org.eclipse.jdt.core.javanature -+ org.eclipse.buildship.core.gradleprojectnature -+ -+ -+ -+ 1745005165095 -+ -+ 30 -+ -+ org.eclipse.core.resources.regexFilterMatcher -+ node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__ -+ -+ -+ -+ -diff --git a/node_modules/react-native/ReactAndroid/hermes-engine/.project b/node_modules/react-native/ReactAndroid/hermes-engine/.project -new file mode 100644 -index 0000000..f3e5c2d ---- /dev/null -+++ b/node_modules/react-native/ReactAndroid/hermes-engine/.project -@@ -0,0 +1,34 @@ -+ -+ -+ hermes-engine -+ Project hermes-engine created by Buildship. -+ -+ -+ -+ -+ org.eclipse.jdt.core.javabuilder -+ -+ -+ -+ -+ org.eclipse.buildship.core.gradleprojectbuilder -+ -+ -+ -+ -+ -+ org.eclipse.jdt.core.javanature -+ org.eclipse.buildship.core.gradleprojectnature -+ -+ -+ -+ 1745005165138 -+ -+ 30 -+ -+ org.eclipse.core.resources.regexFilterMatcher -+ node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__ -+ -+ -+ -+ diff --git a/node_modules/react-native/ReactAndroid/src/main/java/com/facebook/react/views/textinput/PasteWatcher.java b/node_modules/react-native/ReactAndroid/src/main/java/com/facebook/react/views/textinput/PasteWatcher.java new file mode 100644 index 0000000..bfb5819 From a80110aeb357a344159a7a800aa0dc3170f9196c Mon Sep 17 00:00:00 2001 From: Rohit Verma Date: Mon, 21 Apr 2025 13:21:27 +0530 Subject: [PATCH 5/5] refactor: rewrite to return early regardless of the paste watcher --- ...+0.77.1+011+Add-onPaste-to-TextInput.patch | 41 +++++++++++-------- 1 file changed, 24 insertions(+), 17 deletions(-) diff --git a/patches/react-native+0.77.1+011+Add-onPaste-to-TextInput.patch b/patches/react-native+0.77.1+011+Add-onPaste-to-TextInput.patch index 0efa4db148e4d..ba4a9f1b0cbcf 100644 --- a/patches/react-native+0.77.1+011+Add-onPaste-to-TextInput.patch +++ b/patches/react-native+0.77.1+011+Add-onPaste-to-TextInput.patch @@ -445,7 +445,7 @@ index 0000000..bfb5819 + public void onPaste(String type, String data); +} diff --git a/node_modules/react-native/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactEditText.java b/node_modules/react-native/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactEditText.java -index 56a1069..b3feb0a 100644 +index 56a1069..9f14425 100644 --- a/node_modules/react-native/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactEditText.java +++ b/node_modules/react-native/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactEditText.java @@ -9,6 +9,10 @@ package com.facebook.react.views.textinput; @@ -483,40 +483,47 @@ index 56a1069..b3feb0a 100644 mTextAttributes = new TextAttributes(); applyTextAttributes(); -@@ -332,8 +339,31 @@ public class ReactEditText extends AppCompatEditText { +@@ -332,8 +339,38 @@ public class ReactEditText extends AppCompatEditText { */ @Override public boolean onTextContextMenuItem(int id) { - if (id == android.R.id.paste) { + if (id == android.R.id.paste || id == android.R.id.pasteAsPlainText) { id = android.R.id.pasteAsPlainText; -+ if (mPasteWatcher != null) { -+ ClipboardManager clipboardManager = ++ ++ ClipboardManager clipboardManager = + (ClipboardManager) getContext().getSystemService(Context.CLIPBOARD_SERVICE); -+ ClipData clipData = clipboardManager.getPrimaryClip(); ++ ClipData clipData = clipboardManager.getPrimaryClip(); ++ if (clipData != null) { ++ ClipData.Item item = clipData.getItemAt(0); ++ Uri itemUri = item.getUri(); + String type = null; + String data = null; ++ ++ if (itemUri != null) { ++ ContentResolver cr = getReactContext(this).getContentResolver(); ++ type = cr.getType(itemUri); ++ data = itemUri.toString(); ++ if (mPasteWatcher != null) { ++ mPasteWatcher.onPaste(type, data); ++ } ++ // Prevents default behavior to avoid inserting raw binary data into the text field ++ return true; ++ } ++ + if (clipData.getDescription().hasMimeType(ClipDescription.MIMETYPE_TEXT_PLAIN)) { + type = ClipDescription.MIMETYPE_TEXT_PLAIN; -+ data = clipData.getItemAt(0).getText().toString(); -+ } else { -+ Uri itemUri = clipData.getItemAt(0).getUri(); -+ if (itemUri != null) { -+ ContentResolver cr = getReactContext(this).getContentResolver(); -+ type = cr.getType(itemUri); -+ data = itemUri.toString(); ++ data = item.getText().toString(); ++ if (mPasteWatcher != null) { + mPasteWatcher.onPaste(type, data); -+ return true; + } -+ } -+ if (type != null && data != null) { -+ mPasteWatcher.onPaste(type, data); ++ // Don't return - let the system proceed with default text pasting behavior + } + } } return super.onTextContextMenuItem(id); } -@@ -395,6 +425,10 @@ public class ReactEditText extends AppCompatEditText { +@@ -395,6 +432,10 @@ public class ReactEditText extends AppCompatEditText { mScrollWatcher = scrollWatcher; }