Skip to content

Commit 8e45337

Browse files
committed
refactor: update onPaste patch to return early when pasting file
1 parent 277110d commit 8e45337

1 file changed

Lines changed: 129 additions & 13 deletions

File tree

patches/react-native+0.77.1+011+Add-onPaste-to-TextInput.patch

Lines changed: 129 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,37 @@
1+
diff --git a/node_modules/react-native/.project b/node_modules/react-native/.project
2+
new file mode 100644
3+
index 0000000..7c5b305
4+
--- /dev/null
5+
+++ b/node_modules/react-native/.project
6+
@@ -0,0 +1,28 @@
7+
+<?xml version="1.0" encoding="UTF-8"?>
8+
+<projectDescription>
9+
+ <name>react-native-build-from-source-react-native</name>
10+
+ <comment>Project react-native-build-from-source-react-native created by Buildship.</comment>
11+
+ <projects>
12+
+ </projects>
13+
+ <buildSpec>
14+
+ <buildCommand>
15+
+ <name>org.eclipse.buildship.core.gradleprojectbuilder</name>
16+
+ <arguments>
17+
+ </arguments>
18+
+ </buildCommand>
19+
+ </buildSpec>
20+
+ <natures>
21+
+ <nature>org.eclipse.buildship.core.gradleprojectnature</nature>
22+
+ </natures>
23+
+ <filteredResources>
24+
+ <filter>
25+
+ <id>1745005165151</id>
26+
+ <name></name>
27+
+ <type>30</type>
28+
+ <matcher>
29+
+ <id>org.eclipse.core.resources.regexFilterMatcher</id>
30+
+ <arguments>node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
31+
+ </matcher>
32+
+ </filter>
33+
+ </filteredResources>
34+
+</projectDescription>
135
diff --git a/node_modules/react-native/Libraries/Components/TextInput/AndroidTextInputNativeComponent.js b/node_modules/react-native/Libraries/Components/TextInput/AndroidTextInputNativeComponent.js
236
index 6c4bbb2..770dfee 100644
337
--- a/node_modules/react-native/Libraries/Components/TextInput/AndroidTextInputNativeComponent.js
@@ -184,7 +218,7 @@ index d5e2e22..065a819 100644
184218
@implementation RCTUITextView {
185219
UILabel *_placeholderView;
186220
UITextView *_detachedTextView;
187-
@@ -172,7 +176,31 @@ - (void)scrollRangeToVisible:(NSRange)range
221+
@@ -172,7 +176,31 @@ static UIColor *defaultPlaceholderColor(void)
188222
- (void)paste:(id)sender
189223
{
190224
_textWasPasted = YES;
@@ -217,7 +251,7 @@ index d5e2e22..065a819 100644
217251
}
218252

219253
// Turn off scroll animation to fix flaky scrolling.
220-
@@ -264,6 +292,10 @@ - (BOOL)canPerformAction:(SEL)action withSender:(id)sender
254+
@@ -264,6 +292,10 @@ static UIColor *defaultPlaceholderColor(void)
221255
return NO;
222256
}
223257

@@ -265,7 +299,7 @@ diff --git a/node_modules/react-native/Libraries/Text/TextInput/RCTBackedTextInp
265299
index ac8e464..2b91802 100644
266300
--- a/node_modules/react-native/Libraries/Text/TextInput/RCTBackedTextInputDelegateAdapter.mm
267301
+++ b/node_modules/react-native/Libraries/Text/TextInput/RCTBackedTextInputDelegateAdapter.mm
268-
@@ -147,6 +147,11 @@ - (void)selectedTextRangeWasSet
302+
@@ -147,6 +147,11 @@ static void *TextFieldSelectionObservingContext = &TextFieldSelectionObservingCo
269303
[self textFieldProbablyDidChangeSelection];
270304
}
271305

@@ -277,7 +311,7 @@ index ac8e464..2b91802 100644
277311
#pragma mark - Generalization
278312

279313
- (void)textFieldProbablyDidChangeSelection
280-
@@ -292,6 +297,11 @@ - (void)skipNextTextInputDidChangeSelectionEventWithTextRange:(UITextRange *)tex
314+
@@ -292,6 +297,11 @@ static void *TextFieldSelectionObservingContext = &TextFieldSelectionObservingCo
281315
_previousSelectedTextRange = textRange;
282316
}
283317

@@ -302,10 +336,10 @@ index 4804624..90b7081 100644
302336
@property (nonatomic, assign) NSInteger mostRecentEventCount;
303337
@property (nonatomic, assign, readonly) NSInteger nativeEventCount;
304338
diff --git a/node_modules/react-native/Libraries/Text/TextInput/RCTBaseTextInputView.mm b/node_modules/react-native/Libraries/Text/TextInput/RCTBaseTextInputView.mm
305-
index 95edfd5..5111bda 100644
339+
index 6deea73..4d82c72 100644
306340
--- a/node_modules/react-native/Libraries/Text/TextInput/RCTBaseTextInputView.mm
307341
+++ b/node_modules/react-native/Libraries/Text/TextInput/RCTBaseTextInputView.mm
308-
@@ -574,6 +574,26 @@ - (void)textInputDidChangeSelection
342+
@@ -574,6 +574,26 @@ RCT_NOT_IMPLEMENTED(-(instancetype)initWithFrame : (CGRect)frame)
309343
});
310344
}
311345

@@ -336,7 +370,7 @@ diff --git a/node_modules/react-native/Libraries/Text/TextInput/RCTBaseTextInput
336370
index db7c519..ec05595 100644
337371
--- a/node_modules/react-native/Libraries/Text/TextInput/RCTBaseTextInputViewManager.mm
338372
+++ b/node_modules/react-native/Libraries/Text/TextInput/RCTBaseTextInputViewManager.mm
339-
@@ -67,6 +67,7 @@ @implementation RCTBaseTextInputViewManager {
373+
@@ -67,6 +67,7 @@ RCT_EXPORT_VIEW_PROPERTY(onClear, RCTDirectEventBlock)
340374
RCT_EXPORT_VIEW_PROPERTY(onChangeSync, RCTDirectEventBlock)
341375
RCT_EXPORT_VIEW_PROPERTY(onSelectionChange, RCTDirectEventBlock)
342376
RCT_EXPORT_VIEW_PROPERTY(onScroll, RCTDirectEventBlock)
@@ -359,7 +393,7 @@ index 0318671..667e646 100644
359393
@implementation RCTUITextField {
360394
RCTBackedTextFieldDelegateAdapter *_textInputDelegateAdapter;
361395
NSDictionary<NSAttributedStringKey, id> *_defaultTextAttributes;
362-
@@ -139,6 +143,10 @@ - (BOOL)canPerformAction:(SEL)action withSender:(id)sender
396+
@@ -139,6 +143,10 @@
363397
return NO;
364398
}
365399

@@ -370,7 +404,7 @@ index 0318671..667e646 100644
370404
return [super canPerformAction:action withSender:sender];
371405
}
372406

373-
@@ -222,7 +230,31 @@ - (void)scrollRangeToVisible:(NSRange)range
407+
@@ -222,7 +230,31 @@
374408
- (void)paste:(id)sender
375409
{
376410
_textWasPasted = YES;
@@ -407,7 +441,7 @@ diff --git a/node_modules/react-native/React/Fabric/Mounting/ComponentViews/Text
407441
index f8358ed..91aff1a 100644
408442
--- a/node_modules/react-native/React/Fabric/Mounting/ComponentViews/TextInput/RCTTextInputComponentView.mm
409443
+++ b/node_modules/react-native/React/Fabric/Mounting/ComponentViews/TextInput/RCTTextInputComponentView.mm
410-
@@ -481,6 +481,13 @@ - (void)textInputDidChangeSelection
444+
@@ -481,6 +481,13 @@ static NSSet<NSNumber *> *returnKeyTypesSet;
411445
}
412446
}
413447

@@ -421,6 +455,86 @@ index f8358ed..91aff1a 100644
421455
#pragma mark - RCTBackedTextInputDelegate (UIScrollViewDelegate)
422456

423457
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
458+
diff --git a/node_modules/react-native/ReactAndroid/.project b/node_modules/react-native/ReactAndroid/.project
459+
new file mode 100644
460+
index 0000000..533e383
461+
--- /dev/null
462+
+++ b/node_modules/react-native/ReactAndroid/.project
463+
@@ -0,0 +1,34 @@
464+
+<?xml version="1.0" encoding="UTF-8"?>
465+
+<projectDescription>
466+
+ <name>ReactAndroid</name>
467+
+ <comment>Project ReactAndroid created by Buildship.</comment>
468+
+ <projects>
469+
+ </projects>
470+
+ <buildSpec>
471+
+ <buildCommand>
472+
+ <name>org.eclipse.jdt.core.javabuilder</name>
473+
+ <arguments>
474+
+ </arguments>
475+
+ </buildCommand>
476+
+ <buildCommand>
477+
+ <name>org.eclipse.buildship.core.gradleprojectbuilder</name>
478+
+ <arguments>
479+
+ </arguments>
480+
+ </buildCommand>
481+
+ </buildSpec>
482+
+ <natures>
483+
+ <nature>org.eclipse.jdt.core.javanature</nature>
484+
+ <nature>org.eclipse.buildship.core.gradleprojectnature</nature>
485+
+ </natures>
486+
+ <filteredResources>
487+
+ <filter>
488+
+ <id>1745005165095</id>
489+
+ <name></name>
490+
+ <type>30</type>
491+
+ <matcher>
492+
+ <id>org.eclipse.core.resources.regexFilterMatcher</id>
493+
+ <arguments>node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
494+
+ </matcher>
495+
+ </filter>
496+
+ </filteredResources>
497+
+</projectDescription>
498+
diff --git a/node_modules/react-native/ReactAndroid/hermes-engine/.project b/node_modules/react-native/ReactAndroid/hermes-engine/.project
499+
new file mode 100644
500+
index 0000000..f3e5c2d
501+
--- /dev/null
502+
+++ b/node_modules/react-native/ReactAndroid/hermes-engine/.project
503+
@@ -0,0 +1,34 @@
504+
+<?xml version="1.0" encoding="UTF-8"?>
505+
+<projectDescription>
506+
+ <name>hermes-engine</name>
507+
+ <comment>Project hermes-engine created by Buildship.</comment>
508+
+ <projects>
509+
+ </projects>
510+
+ <buildSpec>
511+
+ <buildCommand>
512+
+ <name>org.eclipse.jdt.core.javabuilder</name>
513+
+ <arguments>
514+
+ </arguments>
515+
+ </buildCommand>
516+
+ <buildCommand>
517+
+ <name>org.eclipse.buildship.core.gradleprojectbuilder</name>
518+
+ <arguments>
519+
+ </arguments>
520+
+ </buildCommand>
521+
+ </buildSpec>
522+
+ <natures>
523+
+ <nature>org.eclipse.jdt.core.javanature</nature>
524+
+ <nature>org.eclipse.buildship.core.gradleprojectnature</nature>
525+
+ </natures>
526+
+ <filteredResources>
527+
+ <filter>
528+
+ <id>1745005165138</id>
529+
+ <name></name>
530+
+ <type>30</type>
531+
+ <matcher>
532+
+ <id>org.eclipse.core.resources.regexFilterMatcher</id>
533+
+ <arguments>node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
534+
+ </matcher>
535+
+ </filter>
536+
+ </filteredResources>
537+
+</projectDescription>
424538
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
425539
new file mode 100644
426540
index 0000000..bfb5819
@@ -445,7 +559,7 @@ index 0000000..bfb5819
445559
+ public void onPaste(String type, String data);
446560
+}
447561
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
448-
index 56a1069..272ea7d 100644
562+
index 56a1069..b3feb0a 100644
449563
--- a/node_modules/react-native/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactEditText.java
450564
+++ b/node_modules/react-native/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactEditText.java
451565
@@ -9,6 +9,10 @@ package com.facebook.react.views.textinput;
@@ -483,7 +597,7 @@ index 56a1069..272ea7d 100644
483597
mTextAttributes = new TextAttributes();
484598

485599
applyTextAttributes();
486-
@@ -332,8 +339,29 @@ public class ReactEditText extends AppCompatEditText {
600+
@@ -332,8 +339,31 @@ public class ReactEditText extends AppCompatEditText {
487601
*/
488602
@Override
489603
public boolean onTextContextMenuItem(int id) {
@@ -505,6 +619,8 @@ index 56a1069..272ea7d 100644
505619
+ ContentResolver cr = getReactContext(this).getContentResolver();
506620
+ type = cr.getType(itemUri);
507621
+ data = itemUri.toString();
622+
+ mPasteWatcher.onPaste(type, data);
623+
+ return true;
508624
+ }
509625
+ }
510626
+ if (type != null && data != null) {
@@ -514,7 +630,7 @@ index 56a1069..272ea7d 100644
514630
}
515631
return super.onTextContextMenuItem(id);
516632
}
517-
@@ -395,6 +423,10 @@ public class ReactEditText extends AppCompatEditText {
633+
@@ -395,6 +425,10 @@ public class ReactEditText extends AppCompatEditText {
518634
mScrollWatcher = scrollWatcher;
519635
}
520636

0 commit comments

Comments
 (0)