diff --git a/patches/react-native+0.66.5.patch b/patches/react-native+0.70.6.patch similarity index 65% rename from patches/react-native+0.66.5.patch rename to patches/react-native+0.70.6.patch index 42d30722d..53e0748d8 100644 --- a/patches/react-native+0.66.5.patch +++ b/patches/react-native+0.70.6.patch @@ -1,193 +1,146 @@ diff --git a/node_modules/react-native/Libraries/Components/TextInput/TextInput.js b/node_modules/react-native/Libraries/Components/TextInput/TextInput.js -index f61d266..b4ca15e 100644 +index 8fa1171..316b482 100644 --- a/node_modules/react-native/Libraries/Components/TextInput/TextInput.js +++ b/node_modules/react-native/Libraries/Components/TextInput/TextInput.js -@@ -211,6 +211,13 @@ export type TextContentType = +@@ -208,6 +208,13 @@ export type TextContentType = type PasswordRules = string; type IOSProps = $ReadOnly<{| + /** + * If set, allows pasting of images for given threadID. + * The default value is NULL. + * @platform ios + */ + allowImagePasteForThreadID?: ?string, + /** * When the clear button should appear on the right side of the text view. * This property is supported only for single-line TextInput component. 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 5cb03ee..8e92c21 100644 +index 5ccb6b6..1f326d4 100644 --- a/node_modules/react-native/Libraries/Text/TextInput/Multiline/RCTUITextView.h +++ b/node_modules/react-native/Libraries/Text/TextInput/Multiline/RCTUITextView.h @@ -35,6 +35,8 @@ NS_ASSUME_NONNULL_BEGIN @property (nonatomic, assign) BOOL caretHidden; +@property (nonatomic, copy, nullable) NSString *allowImagePasteForThreadID; + @property (nonatomic, strong, nullable) NSString *inputAccessoryViewID; @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 2f72cb8..b7b7d4e 100644 +index 92371bc..e991835 100644 --- a/node_modules/react-native/Libraries/Text/TextInput/Multiline/RCTUITextView.m +++ b/node_modules/react-native/Libraries/Text/TextInput/Multiline/RCTUITextView.m -@@ -178,8 +178,12 @@ - (void)setSelectedTextRange:(UITextRange *)selectedTextRange notifyDelegate:(BO +@@ -164,8 +164,12 @@ - (void)setSelectedTextRange:(UITextRange *)selectedTextRange notifyDelegate:(BO - (void)paste:(id)sender { - [super paste:sender]; - _textWasPasted = YES; + if ([UIPasteboard generalPasteboard].hasImages && _allowImagePasteForThreadID) { + [_textInputDelegate textInputImagePasted:_allowImagePasteForThreadID]; + } else { + [super paste:sender]; + _textWasPasted = YES; + } } - - (void)setContentOffset:(CGPoint)contentOffset animated:(__unused BOOL)animated -@@ -266,6 +270,10 @@ - (BOOL)canPerformAction:(SEL)action withSender:(id)sender + // Turn off scroll animation to fix flaky scrolling. +@@ -254,6 +258,10 @@ - (BOOL)canPerformAction:(SEL)action withSender:(id)sender return NO; } + if (action == @selector(paste:) && [UIPasteboard generalPasteboard].hasImages) { + return (_allowImagePasteForThreadID != NULL); + } + 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..c9f33d2 100644 +index c2a4362..90f8583 100644 --- a/node_modules/react-native/Libraries/Text/TextInput/RCTBackedTextInputDelegate.h +++ b/node_modules/react-native/Libraries/Text/TextInput/RCTBackedTextInputDelegate.h @@ -33,6 +33,8 @@ NS_ASSUME_NONNULL_BEGIN - (void)textInputDidChangeSelection; +- (void)textInputImagePasted:(NSString *)threadID; + @optional - (void)scrollViewDidScroll:(UIScrollView *)scrollView; diff --git a/node_modules/react-native/Libraries/Text/TextInput/RCTBaseTextInputView.m b/node_modules/react-native/Libraries/Text/TextInput/RCTBaseTextInputView.m -index 9965f9c..22c12be 100644 +index a492492..e3b38cb 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 id _eventDispatcher; -@@ -499,6 +501,46 @@ - (void)textInputDidChangeSelection +@@ -491,6 +493,46 @@ - (void)textInputDidChangeSelection }); } +- (void)textInputImagePasted:(NSString *)threadID +{ + NSFileManager *fileManager = [NSFileManager defaultManager]; + UIPasteboard *clipboard = [UIPasteboard generalPasteboard]; + NSData *imageData = [clipboard dataForPasteboardType:(NSString*)kUTTypeImage]; + + UIImage *uiImage = [UIImage imageWithData:imageData]; + + if (!imageData) { + RCTLog(@"Failed to get image from UIPasteboard."); + return; + } + + NSString *fileName = [@([imageData hash]) stringValue]; + NSURL *tmpDirURL = [NSURL fileURLWithPath:NSTemporaryDirectory() isDirectory:YES]; + + // We add the PNG file extension because EXImageLoader fails without it. + // Our code ignores file extensions and looks at magic numbers directly. + NSURL *fileURL = [[tmpDirURL URLByAppendingPathComponent:fileName] URLByAppendingPathExtension:@"png"]; + NSString *fileDest = [fileURL path]; + + 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, + @"height": @(uiImage.size.height), + @"width": @(uiImage.size.width), + @"threadID": threadID, + }; + + [_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 34994ca..cd8322e 100644 +index b1ecf85..3462f98 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(allowImagePasteForThreadID, backedTextInputView.allowImagePasteForThreadID, NSString) RCT_REMAP_VIEW_PROPERTY(autoCapitalize, backedTextInputView.autocapitalizationType, UITextAutocapitalizationType) RCT_REMAP_VIEW_PROPERTY(autoCorrect, backedTextInputView.autocorrectionType, UITextAutocorrectionType) RCT_REMAP_VIEW_PROPERTY(contextMenuHidden, backedTextInputView.contextMenuHidden, BOOL) -diff --git a/node_modules/react-native/scripts/react_native_pods.rb b/node_modules/react-native/scripts/react_native_pods.rb -index df31139..e3db02f 100644 ---- a/node_modules/react-native/scripts/react_native_pods.rb -+++ b/node_modules/react-native/scripts/react_native_pods.rb -@@ -132,11 +132,7 @@ def exclude_architectures(installer) - - projects.each do |project| - project.build_configurations.each do |config| -- if arm_value == 1 then -- config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = excluded_archs_default -- else -- config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64 " + excluded_archs_default -- end -+ config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = excluded_archs_default - end - - project.save() -diff --git a/node_modules/react-native/third-party-podspecs/RCT-Folly.podspec b/node_modules/react-native/third-party-podspecs/RCT-Folly.podspec -index f5dc212..b439680 100644 ---- a/node_modules/react-native/third-party-podspecs/RCT-Folly.podspec -+++ b/node_modules/react-native/third-party-podspecs/RCT-Folly.podspec -@@ -35,6 +35,7 @@ Pod::Spec.new do |spec| - 'folly/json.cpp', - 'folly/json_pointer.cpp', - 'folly/container/detail/F14Table.cpp', -+ 'folly/detail/Futex.cpp', - 'folly/detail/Demangle.cpp', - 'folly/detail/UniqueInstance.cpp', - 'folly/hash/SpookyHashV2.cpp', -@@ -44,6 +45,7 @@ Pod::Spec.new do |spec| - 'folly/memory/detail/MallocImpl.cpp', - 'folly/net/NetOps.cpp', - 'folly/portability/SysUio.cpp', -+ 'folly/synchronization/ParkingLot.cpp', - 'folly/system/ThreadId.h', - 'folly/system/ThreadId.cpp', - 'folly/*.h', -@@ -71,7 +73,8 @@ Pod::Spec.new do |spec| - 'folly/memory/detail/*.h', - 'folly/net/*.h', - 'folly/net/detail/*.h', -- 'folly/portability/*.h' -+ 'folly/portability/*.h', -+ 'folly/synchronization/*.h' - spec.libraries = "stdc++", "c++abi" # NOTE Apple-only: Keep c++abi here due to https://github.com/react-native-community/releases/issues/251 - spec.pod_target_xcconfig = { "USE_HEADERMAP" => "NO", - "CLANG_CXX_LANGUAGE_STANDARD" => "c++17",