diff --git a/patches/react-native+0.63.4.patch b/patches/react-native+0.63.4.patch index 2c3eca2c5..5571e18ea 100644 --- a/patches/react-native+0.63.4.patch +++ b/patches/react-native+0.63.4.patch @@ -1,75 +1,123 @@ diff --git a/node_modules/react-native/Libraries/Components/Touchable/TouchableNativeFeedback.js b/node_modules/react-native/Libraries/Components/Touchable/TouchableNativeFeedback.js index 5dc03df..e526092 100644 --- a/node_modules/react-native/Libraries/Components/Touchable/TouchableNativeFeedback.js +++ b/node_modules/react-native/Libraries/Components/Touchable/TouchableNativeFeedback.js @@ -338,7 +338,7 @@ class TouchableNativeFeedback extends React.Component { } const getBackgroundProp = - Platform.OS === 'android' + Platform.OS === 'android' && Platform.Version >= 21 ? (background, useForeground) => useForeground && TouchableNativeFeedback.canUseNativeForeground() ? {nativeForegroundAndroid: background} +diff --git a/node_modules/react-native/Libraries/Text/TextInput/Multiline/RCTUITextView.h b/node_modules/react-native/Libraries/Text/TextInput/Multiline/RCTUITextView.h +index 7e12add..f6c9e40 100644 +--- a/node_modules/react-native/Libraries/Text/TextInput/Multiline/RCTUITextView.h ++++ b/node_modules/react-native/Libraries/Text/TextInput/Multiline/RCTUITextView.h +@@ -36,6 +36,7 @@ NS_ASSUME_NONNULL_BEGIN + // The `caretHidden` property actually is not supported yet; + // it's declared here only to conform to the interface. + @property (nonatomic, assign) BOOL caretHidden; ++@property (nonatomic, assign) BOOL allowImagePaste; + + @end + +diff --git a/node_modules/react-native/Libraries/Text/TextInput/Multiline/RCTUITextView.m b/node_modules/react-native/Libraries/Text/TextInput/Multiline/RCTUITextView.m +index 88d3183..79185de 100644 +--- a/node_modules/react-native/Libraries/Text/TextInput/Multiline/RCTUITextView.m ++++ b/node_modules/react-native/Libraries/Text/TextInput/Multiline/RCTUITextView.m +@@ -173,6 +173,9 @@ - (void)setSelectedTextRange:(UITextRange *)selectedTextRange notifyDelegate:(BO + + - (void)paste:(id)sender + { ++ if ([UIPasteboard generalPasteboard].hasImages && _allowImagePaste) { ++ [_textInputDelegate textInputImagePasted]; ++ } + [super paste:sender]; + _textWasPasted = YES; + } +@@ -261,6 +264,9 @@ - (BOOL)canPerformAction:(SEL)action withSender:(id)sender + return NO; + } + ++ if (action == @selector(paste:) && [UIPasteboard generalPasteboard].hasImages) { ++ return _allowImagePaste; ++ } + return [super canPerformAction:action withSender:sender]; + } + diff --git a/node_modules/react-native/Libraries/Text/TextInput/RCTBackedTextInputDelegate.h b/node_modules/react-native/Libraries/Text/TextInput/RCTBackedTextInputDelegate.h index 3e1839b..2df81fb 100644 --- a/node_modules/react-native/Libraries/Text/TextInput/RCTBackedTextInputDelegate.h +++ b/node_modules/react-native/Libraries/Text/TextInput/RCTBackedTextInputDelegate.h @@ -32,6 +32,7 @@ NS_ASSUME_NONNULL_BEGIN - (void)textInputDidChange; - (void)textInputDidChangeSelection; +- (void)textInputImagePasted; @optional diff --git a/node_modules/react-native/Libraries/Text/TextInput/RCTBaseTextInputView.m b/node_modules/react-native/Libraries/Text/TextInput/RCTBaseTextInputView.m index aa69593..8366cf2 100644 --- a/node_modules/react-native/Libraries/Text/TextInput/RCTBaseTextInputView.m +++ b/node_modules/react-native/Libraries/Text/TextInput/RCTBaseTextInputView.m @@ -19,6 +19,8 @@ #import #import +#import + @implementation RCTBaseTextInputView { __weak RCTBridge *_bridge; __weak RCTEventDispatcher *_eventDispatcher; @@ -479,6 +481,36 @@ - (void)textInputDidChangeSelection }); } +- (void)textInputImagePasted +{ + NSFileManager *fileManager = [NSFileManager defaultManager]; + UIPasteboard *clipboard = [UIPasteboard generalPasteboard]; + NSData *imageData = [clipboard dataForPasteboardType:(NSString*)kUTTypeImage]; + + if (!imageData) { + RCTLog(@"Failed to get image from UIPasteboard."); + return; + } + + NSString *fileName = [@([imageData hash]) stringValue]; + NSString *fileDest = [NSTemporaryDirectory() stringByAppendingPathComponent:fileName]; + + if (![fileManager fileExistsAtPath:fileDest]) { + BOOL fileWritten = [imageData writeToFile:fileDest atomically:true]; + if (!fileWritten) { + RCTLog(@"Failed to save image to temporary directory."); + return; + } + } + + NSDictionary *eventBody = @{ + @"fileName": fileName, + @"filePath": fileDest, + }; + + [_eventDispatcher sendAppEventWithName:@"imagePasted" body:eventBody]; +} + - (void)updateLocalData { [self enforceTextAttributesIfNeeded]; +diff --git a/node_modules/react-native/Libraries/Text/TextInput/RCTBaseTextInputViewManager.m b/node_modules/react-native/Libraries/Text/TextInput/RCTBaseTextInputViewManager.m +index dca1437..5af6457 100644 +--- a/node_modules/react-native/Libraries/Text/TextInput/RCTBaseTextInputViewManager.m ++++ b/node_modules/react-native/Libraries/Text/TextInput/RCTBaseTextInputViewManager.m +@@ -33,6 +33,7 @@ @implementation RCTBaseTextInputViewManager + + #pragma mark - Unified properties + ++RCT_REMAP_VIEW_PROPERTY(allowImagePaste, backedTextInputView.allowImagePaste, BOOL) + RCT_REMAP_VIEW_PROPERTY(autoCapitalize, backedTextInputView.autocapitalizationType, UITextAutocapitalizationType) + RCT_REMAP_VIEW_PROPERTY(autoCorrect, backedTextInputView.autocorrectionType, UITextAutocorrectionType) + RCT_REMAP_VIEW_PROPERTY(contextMenuHidden, backedTextInputView.contextMenuHidden, BOOL)