Bluesky app fork with some witchin' additions 💫

Fix double text input in composer (#7381)

* upgrade paste input

* override how backing uitextinput is created

* different approach

authored by samuel.fm and committed by

GitHub fe8d3b08 615bbc35

+170 -33
+1 -1
package.json
··· 72 72 "@haileyok/bluesky-video": "0.2.6", 73 73 "@ipld/dag-cbor": "^9.2.0", 74 74 "@lingui/react": "^4.14.1", 75 - "@mattermost/react-native-paste-input": "^0.7.1", 75 + "@mattermost/react-native-paste-input": "^0.8.1", 76 76 "@miblanchard/react-native-slider": "^2.3.1", 77 77 "@mozzius/expo-dynamic-app-icon": "^1.5.0", 78 78 "@radix-ui/react-dismissable-layer": "^1.1.1",
-16
patches/@mattermost+react-native-paste-input+0.7.1.patch
··· 1 - diff --git a/node_modules/@mattermost/react-native-paste-input/ios/PasteInputView.m b/node_modules/@mattermost/react-native-paste-input/ios/PasteInputView.m 2 - index e916023..0564d97 100644 3 - --- a/node_modules/@mattermost/react-native-paste-input/ios/PasteInputView.m 4 - +++ b/node_modules/@mattermost/react-native-paste-input/ios/PasteInputView.m 5 - @@ -22,6 +22,11 @@ - (instancetype)initWithBridge:(RCTBridge *)bridge 6 - _backedTextInputView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; 7 - _backedTextInputView.textInputDelegate = self; 8 - 9 - + // Disable inline predictions to prevent jank in the composer 10 - + if (@available(iOS 17.0, *)) { 11 - + _backedTextInputView.inlinePredictionType = UITextInlinePredictionTypeNo; 12 - + } 13 - + 14 - [self addSubview:_backedTextInputView]; 15 - } 16 -
+160
patches/@mattermost+react-native-paste-input+0.8.1.patch
··· 1 + diff --git a/node_modules/@mattermost/react-native-paste-input/ios/PasteInputView.m b/node_modules/@mattermost/react-native-paste-input/ios/PasteInputView.m 2 + index e916023..9968f3c 100644 3 + --- a/node_modules/@mattermost/react-native-paste-input/ios/PasteInputView.m 4 + +++ b/node_modules/@mattermost/react-native-paste-input/ios/PasteInputView.m 5 + @@ -3,58 +3,87 @@ 6 + // PasteInput 7 + // 8 + // Created by Elias Nahum on 04-11-20. 9 + -// Copyright © 2020 Facebook. All rights reserved. 10 + +// Updated to remove parent’s default text view 11 + // 12 + 13 + #import "PasteInputView.h" 14 + #import "PasteInputTextView.h" 15 + -#import <React/RCTUtils.h> 16 + +#import <React/RCTUtils.h> // for RCTDirectEventBlock, etc. 17 + 18 + @implementation PasteInputView 19 + { 20 + - PasteInputTextView *_backedTextInputView; 21 + + // We'll store the custom text view in this ivar 22 + + PasteInputTextView *_customBackedTextView; 23 + } 24 + 25 + - (instancetype)initWithBridge:(RCTBridge *)bridge 26 + { 27 + + // Must call the super’s designated initializer 28 + if (self = [super initWithBridge:bridge]) { 29 + - _backedTextInputView = [[PasteInputTextView alloc] initWithFrame:self.bounds]; 30 + - _backedTextInputView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; 31 + - _backedTextInputView.textInputDelegate = self; 32 + + // 1. The parent (RCTMultilineTextInputView) has already created 33 + + // its own _backedTextInputView = [RCTUITextView new] in super init. 34 + + // We can remove that subview: 35 + 36 + - [self addSubview:_backedTextInputView]; 37 + - } 38 + + id<RCTBackedTextInputViewProtocol> parentInputView = super.backedTextInputView; 39 + + if ([parentInputView isKindOfClass:[UIView class]]) { 40 + + UIView *parentSubview = (UIView *)parentInputView; 41 + + if (parentSubview.superview == self) { 42 + + [parentSubview removeFromSuperview]; 43 + + } 44 + + } 45 + 46 + + // 2. Now create our custom PasteInputTextView 47 + + _customBackedTextView = [[PasteInputTextView alloc] initWithFrame:self.bounds]; 48 + + _customBackedTextView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; 49 + + _customBackedTextView.textInputDelegate = self; 50 + + 51 + + // Optional: disable inline predictions for iOS 17+ 52 + + if (@available(iOS 17.0, *)) { 53 + + _customBackedTextView.inlinePredictionType = UITextInlinePredictionTypeNo; 54 + + } 55 + + 56 + + // 3. Add your custom text view as the only subview 57 + + [self addSubview:_customBackedTextView]; 58 + + } 59 + return self; 60 + } 61 + 62 + +/** 63 + + * Override the parent's accessor so that anywhere in RN that calls 64 + + * `self.backedTextInputView` will get the custom PasteInputTextView. 65 + + */ 66 + - (id<RCTBackedTextInputViewProtocol>)backedTextInputView 67 + { 68 + - return _backedTextInputView; 69 + + return _customBackedTextView; 70 + } 71 + 72 + -- (void)setDisableCopyPaste:(BOOL)disableCopyPaste { 73 + - _backedTextInputView.disableCopyPaste = disableCopyPaste; 74 + +#pragma mark - Setters for React Props 75 + + 76 + +- (void)setDisableCopyPaste:(BOOL)disableCopyPaste 77 + +{ 78 + + _customBackedTextView.disableCopyPaste = disableCopyPaste; 79 + } 80 + 81 + -- (void)setOnPaste:(RCTDirectEventBlock)onPaste { 82 + - _backedTextInputView.onPaste = onPaste; 83 + +- (void)setOnPaste:(RCTDirectEventBlock)onPaste 84 + +{ 85 + + _customBackedTextView.onPaste = onPaste; 86 + } 87 + 88 + -- (void)setSmartPunctuation:(NSString *)smartPunctuation { 89 + - if ([smartPunctuation isEqualToString:@"enable"]) { 90 + - [_backedTextInputView setSmartDashesType:UITextSmartDashesTypeYes]; 91 + - [_backedTextInputView setSmartQuotesType:UITextSmartQuotesTypeYes]; 92 + - [_backedTextInputView setSmartInsertDeleteType:UITextSmartInsertDeleteTypeYes]; 93 + - } else if ([smartPunctuation isEqualToString:@"disable"]) { 94 + - [_backedTextInputView setSmartDashesType:UITextSmartDashesTypeNo]; 95 + - [_backedTextInputView setSmartQuotesType:UITextSmartQuotesTypeNo]; 96 + - [_backedTextInputView setSmartInsertDeleteType:UITextSmartInsertDeleteTypeNo]; 97 + - } else { 98 + - [_backedTextInputView setSmartDashesType:UITextSmartDashesTypeDefault]; 99 + - [_backedTextInputView setSmartQuotesType:UITextSmartQuotesTypeDefault]; 100 + - [_backedTextInputView setSmartInsertDeleteType:UITextSmartInsertDeleteTypeDefault]; 101 + - } 102 + +- (void)setSmartPunctuation:(NSString *)smartPunctuation 103 + +{ 104 + + if ([smartPunctuation isEqualToString:@"enable"]) { 105 + + [_customBackedTextView setSmartDashesType:UITextSmartDashesTypeYes]; 106 + + [_customBackedTextView setSmartQuotesType:UITextSmartQuotesTypeYes]; 107 + + [_customBackedTextView setSmartInsertDeleteType:UITextSmartInsertDeleteTypeYes]; 108 + + } else if ([smartPunctuation isEqualToString:@"disable"]) { 109 + + [_customBackedTextView setSmartDashesType:UITextSmartDashesTypeNo]; 110 + + [_customBackedTextView setSmartQuotesType:UITextSmartQuotesTypeNo]; 111 + + [_customBackedTextView setSmartInsertDeleteType:UITextSmartInsertDeleteTypeNo]; 112 + + } else { 113 + + [_customBackedTextView setSmartDashesType:UITextSmartDashesTypeDefault]; 114 + + [_customBackedTextView setSmartQuotesType:UITextSmartQuotesTypeDefault]; 115 + + [_customBackedTextView setSmartInsertDeleteType:UITextSmartInsertDeleteTypeDefault]; 116 + + } 117 + } 118 + 119 + #pragma mark - UIScrollViewDelegate 120 + @@ -62,7 +91,6 @@ 121 + - (void)scrollViewDidScroll:(UIScrollView *)scrollView 122 + { 123 + RCTDirectEventBlock onScroll = self.onScroll; 124 + - 125 + if (onScroll) { 126 + CGPoint contentOffset = scrollView.contentOffset; 127 + CGSize contentSize = scrollView.contentSize; 128 + @@ -71,22 +99,22 @@ 129 + 130 + onScroll(@{ 131 + @"contentOffset": @{ 132 + - @"x": @(contentOffset.x), 133 + - @"y": @(contentOffset.y) 134 + + @"x": @(contentOffset.x), 135 + + @"y": @(contentOffset.y) 136 + }, 137 + @"contentInset": @{ 138 + - @"top": @(contentInset.top), 139 + - @"left": @(contentInset.left), 140 + - @"bottom": @(contentInset.bottom), 141 + - @"right": @(contentInset.right) 142 + + @"top": @(contentInset.top), 143 + + @"left": @(contentInset.left), 144 + + @"bottom": @(contentInset.bottom), 145 + + @"right": @(contentInset.right) 146 + }, 147 + @"contentSize": @{ 148 + - @"width": @(contentSize.width), 149 + - @"height": @(contentSize.height) 150 + + @"width": @(contentSize.width), 151 + + @"height": @(contentSize.height) 152 + }, 153 + @"layoutMeasurement": @{ 154 + - @"width": @(size.width), 155 + - @"height": @(size.height) 156 + + @"width": @(size.width), 157 + + @"height": @(size.height) 158 + }, 159 + @"zoomScale": @(scrollView.zoomScale ?: 1), 160 + });
+9 -16
yarn.lock
··· 4990 4990 "@babel/runtime" "^7.20.13" 4991 4991 "@lingui/core" "4.14.1" 4992 4992 4993 - "@mattermost/react-native-paste-input@^0.7.1": 4994 - version "0.7.1" 4995 - resolved "https://registry.yarnpkg.com/@mattermost/react-native-paste-input/-/react-native-paste-input-0.7.1.tgz#f14585030b992cf7c9bbd0921225eefa501756ba" 4996 - integrity sha512-kY8LKtqRX2T/rtn/HNrzTitijuATvyzd6yl5WNWOsszmyzNcssKStjjCTBup04CyMxfwutUU1CWrYUb3hQO7oA== 4993 + "@mattermost/react-native-paste-input@^0.8.1": 4994 + version "0.8.1" 4995 + resolved "https://registry.yarnpkg.com/@mattermost/react-native-paste-input/-/react-native-paste-input-0.8.1.tgz#944ec69d0c49c3607265a02ad04103cc5b556caf" 4996 + integrity sha512-QHpwWORPALmX5FczCewRlJkVqtltD84mlpMpto5IGLKdHMAoHeXMiG4VJVh2XkRQvTyUhYegtrUrJzf8dkJokA== 4997 4997 dependencies: 4998 - semver "7.6.0" 4998 + semver "7.6.3" 4999 4999 5000 5000 "@messageformat/parser@^5.0.0": 5001 5001 version "5.1.0" ··· 16903 16903 resolved "https://registry.yarnpkg.com/semver-compare/-/semver-compare-1.0.0.tgz#0dee216a1c941ab37e9efb1788f6afc5ff5537fc" 16904 16904 integrity sha512-YM3/ITh2MJ5MtzaM429anh+x2jiLVjqILF4m4oyQB18W7Ggea7BfqdH/wGMK7dDiMghv/6WG7znWMwUDzJiXow== 16905 16905 16906 - semver@7.6.0: 16907 - version "7.6.0" 16908 - resolved "https://registry.yarnpkg.com/semver/-/semver-7.6.0.tgz#1a46a4db4bffcccd97b743b5005c8325f23d4e2d" 16909 - integrity sha512-EnwXhrlwXMk9gKu5/flx5sv/an57AkRplG3hTK68W7FRDN+k+OWBj65M7719OkA82XLBxrcX0KSHj+X5COhOVg== 16910 - dependencies: 16911 - lru-cache "^6.0.0" 16906 + semver@7.6.3, semver@^7.1.3, semver@^7.6.3: 16907 + version "7.6.3" 16908 + resolved "https://registry.yarnpkg.com/semver/-/semver-7.6.3.tgz#980f7b5550bc175fb4dc09403085627f9eb33143" 16909 + integrity sha512-oVekP1cKtI+CTDvHWYFUcMtsK/00wmAEfyqKfNdARm8u1wNVhSgaX7A8d4UuIlUI5e84iEwOhs7ZPYRmzU9U6A== 16912 16910 16913 16911 semver@^5.5.0, semver@^5.6.0: 16914 16912 version "5.7.2" ··· 16919 16917 version "6.3.1" 16920 16918 resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.1.tgz#556d2ef8689146e46dcea4bfdd095f3434dffcb4" 16921 16919 integrity sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA== 16922 - 16923 - semver@^7.1.3, semver@^7.6.3: 16924 - version "7.6.3" 16925 - resolved "https://registry.yarnpkg.com/semver/-/semver-7.6.3.tgz#980f7b5550bc175fb4dc09403085627f9eb33143" 16926 - integrity sha512-oVekP1cKtI+CTDvHWYFUcMtsK/00wmAEfyqKfNdARm8u1wNVhSgaX7A8d4UuIlUI5e84iEwOhs7ZPYRmzU9U6A== 16927 16920 16928 16921 semver@^7.3.5, semver@^7.3.7, semver@^7.3.8, semver@^7.5.3, semver@^7.5.4: 16929 16922 version "7.5.4"