Bluesky app fork with some witchin' additions 馃挮
at main 12 kB view raw
1diff --git a/node_modules/@mattermost/react-native-paste-input/ios/PasteInputView.m b/node_modules/@mattermost/react-native-paste-input/ios/PasteInputView.m 2index e916023..5049c33 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@@ -4,6 +4,7 @@ 6 // 7 // Created by Elias Nahum on 04-11-20. 8 // Copyright 漏 2020 Facebook. All rights reserved. 9+// Updated to remove parent鈥檚 default text view 10 // 11 12 #import "PasteInputView.h" 13@@ -12,49 +13,78 @@ 14 15 @implementation PasteInputView 16 { 17- PasteInputTextView *_backedTextInputView; 18+ // We'll store the custom text view in this ivar 19+ PasteInputTextView *_customBackedTextView; 20 } 21 22 - (instancetype)initWithBridge:(RCTBridge *)bridge 23 { 24+ // Must call the super鈥檚 designated initializer 25 if (self = [super initWithBridge:bridge]) { 26- _backedTextInputView = [[PasteInputTextView alloc] initWithFrame:self.bounds]; 27- _backedTextInputView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; 28- _backedTextInputView.textInputDelegate = self; 29+ // 1. The parent (RCTMultilineTextInputView) has already created 30+ // its own _backedTextInputView = [RCTUITextView new] in super init. 31+ // We can remove that subview: 32 33- [self addSubview:_backedTextInputView]; 34- } 35+ id<RCTBackedTextInputViewProtocol> parentInputView = super.backedTextInputView; 36+ if ([parentInputView isKindOfClass:[UIView class]]) { 37+ UIView *parentSubview = (UIView *)parentInputView; 38+ if (parentSubview.superview == self) { 39+ [parentSubview removeFromSuperview]; 40+ } 41+ } 42 43+ // 2. Now create our custom PasteInputTextView 44+ _customBackedTextView = [[PasteInputTextView alloc] initWithFrame:self.bounds]; 45+ _customBackedTextView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; 46+ _customBackedTextView.textInputDelegate = self; 47+ 48+ // Optional: disable inline predictions for iOS 17+ 49+ if (@available(iOS 17.0, *)) { 50+ _customBackedTextView.inlinePredictionType = UITextInlinePredictionTypeNo; 51+ } 52+ 53+ // 3. Add your custom text view as the only subview 54+ [self addSubview:_customBackedTextView]; 55+ } 56 return self; 57 } 58 59+/** 60+ * Override the parent's accessor so that anywhere in RN that calls 61+ * `self.backedTextInputView` will get the custom PasteInputTextView. 62+ */ 63 - (id<RCTBackedTextInputViewProtocol>)backedTextInputView 64 { 65- return _backedTextInputView; 66+ return _customBackedTextView; 67 } 68 69-- (void)setDisableCopyPaste:(BOOL)disableCopyPaste { 70- _backedTextInputView.disableCopyPaste = disableCopyPaste; 71+#pragma mark - Setters for React Props 72+ 73+- (void)setDisableCopyPaste:(BOOL)disableCopyPaste 74+{ 75+ _customBackedTextView.disableCopyPaste = disableCopyPaste; 76 } 77 78-- (void)setOnPaste:(RCTDirectEventBlock)onPaste { 79- _backedTextInputView.onPaste = onPaste; 80+- (void)setOnPaste:(RCTDirectEventBlock)onPaste 81+{ 82+ _customBackedTextView.onPaste = onPaste; 83 } 84 85-- (void)setSmartPunctuation:(NSString *)smartPunctuation { 86- if ([smartPunctuation isEqualToString:@"enable"]) { 87- [_backedTextInputView setSmartDashesType:UITextSmartDashesTypeYes]; 88- [_backedTextInputView setSmartQuotesType:UITextSmartQuotesTypeYes]; 89- [_backedTextInputView setSmartInsertDeleteType:UITextSmartInsertDeleteTypeYes]; 90- } else if ([smartPunctuation isEqualToString:@"disable"]) { 91- [_backedTextInputView setSmartDashesType:UITextSmartDashesTypeNo]; 92- [_backedTextInputView setSmartQuotesType:UITextSmartQuotesTypeNo]; 93- [_backedTextInputView setSmartInsertDeleteType:UITextSmartInsertDeleteTypeNo]; 94- } else { 95- [_backedTextInputView setSmartDashesType:UITextSmartDashesTypeDefault]; 96- [_backedTextInputView setSmartQuotesType:UITextSmartQuotesTypeDefault]; 97- [_backedTextInputView setSmartInsertDeleteType:UITextSmartInsertDeleteTypeDefault]; 98- } 99+- (void)setSmartPunctuation:(NSString *)smartPunctuation 100+{ 101+ if ([smartPunctuation isEqualToString:@"enable"]) { 102+ [_customBackedTextView setSmartDashesType:UITextSmartDashesTypeYes]; 103+ [_customBackedTextView setSmartQuotesType:UITextSmartQuotesTypeYes]; 104+ [_customBackedTextView setSmartInsertDeleteType:UITextSmartInsertDeleteTypeYes]; 105+ } else if ([smartPunctuation isEqualToString:@"disable"]) { 106+ [_customBackedTextView setSmartDashesType:UITextSmartDashesTypeNo]; 107+ [_customBackedTextView setSmartQuotesType:UITextSmartQuotesTypeNo]; 108+ [_customBackedTextView setSmartInsertDeleteType:UITextSmartInsertDeleteTypeNo]; 109+ } else { 110+ [_customBackedTextView setSmartDashesType:UITextSmartDashesTypeDefault]; 111+ [_customBackedTextView setSmartQuotesType:UITextSmartQuotesTypeDefault]; 112+ [_customBackedTextView setSmartInsertDeleteType:UITextSmartInsertDeleteTypeDefault]; 113+ } 114 } 115 116 #pragma mark - UIScrollViewDelegate 117@@ -62,7 +92,6 @@ - (void)setSmartPunctuation:(NSString *)smartPunctuation { 118 - (void)scrollViewDidScroll:(UIScrollView *)scrollView 119 { 120 RCTDirectEventBlock onScroll = self.onScroll; 121- 122 if (onScroll) { 123 CGPoint contentOffset = scrollView.contentOffset; 124 CGSize contentSize = scrollView.contentSize; 125@@ -71,22 +100,22 @@ - (void)scrollViewDidScroll:(UIScrollView *)scrollView 126 127 onScroll(@{ 128 @"contentOffset": @{ 129- @"x": @(contentOffset.x), 130- @"y": @(contentOffset.y) 131+ @"x": @(contentOffset.x), 132+ @"y": @(contentOffset.y) 133 }, 134 @"contentInset": @{ 135- @"top": @(contentInset.top), 136- @"left": @(contentInset.left), 137- @"bottom": @(contentInset.bottom), 138- @"right": @(contentInset.right) 139+ @"top": @(contentInset.top), 140+ @"left": @(contentInset.left), 141+ @"bottom": @(contentInset.bottom), 142+ @"right": @(contentInset.right) 143 }, 144 @"contentSize": @{ 145- @"width": @(contentSize.width), 146- @"height": @(contentSize.height) 147+ @"width": @(contentSize.width), 148+ @"height": @(contentSize.height) 149 }, 150 @"layoutMeasurement": @{ 151- @"width": @(size.width), 152- @"height": @(size.height) 153+ @"width": @(size.width), 154+ @"height": @(size.height) 155 }, 156 @"zoomScale": @(scrollView.zoomScale ?: 1), 157 }); 158diff --git a/node_modules/@mattermost/react-native-paste-input/ios/PasteTextInput.mm b/node_modules/@mattermost/react-native-paste-input/ios/PasteTextInput.mm 159index dd50053..2ed7017 100644 160--- a/node_modules/@mattermost/react-native-paste-input/ios/PasteTextInput.mm 161+++ b/node_modules/@mattermost/react-native-paste-input/ios/PasteTextInput.mm 162@@ -122,8 +122,8 @@ - (void)updateProps:(const Props::Shared &)props oldProps:(const Props::Shared & 163 const auto &newTextInputProps = static_cast<const PasteTextInputProps &>(*props); 164 165 // Traits: 166- if (newTextInputProps.traits.multiline != oldTextInputProps.traits.multiline) { 167- [self _setMultiline:newTextInputProps.traits.multiline]; 168+ if (newTextInputProps.multiline != oldTextInputProps.multiline) { 169+ [self _setMultiline:newTextInputProps.multiline]; 170 } 171 172 if (newTextInputProps.traits.autocapitalizationType != oldTextInputProps.traits.autocapitalizationType) { 173@@ -421,7 +421,7 @@ - (void)textInputDidChangeSelection 174 return; 175 } 176 const auto &props = static_cast<const PasteTextInputProps &>(*_props); 177- if (props.traits.multiline && ![_lastStringStateWasUpdatedWith isEqual:_backedTextInputView.attributedText]) { 178+ if (props.multiline && ![_lastStringStateWasUpdatedWith isEqual:_backedTextInputView.attributedText]) { 179 [self textInputDidChange]; 180 _ignoreNextTextInputCall = YES; 181 } 182@@ -708,11 +708,11 @@ - (BOOL)_textOf:(NSAttributedString *)newText equals:(NSAttributedString *)oldTe 183 - (SubmitBehavior)getSubmitBehavior 184 { 185 const auto &props = static_cast<const PasteTextInputProps &>(*_props); 186- const SubmitBehavior submitBehaviorDefaultable = props.traits.submitBehavior; 187+ const SubmitBehavior submitBehaviorDefaultable = props.submitBehavior; 188 189 // We should always have a non-default `submitBehavior`, but in case we don't, set it based on multiline. 190 if (submitBehaviorDefaultable == SubmitBehavior::Default) { 191- return props.traits.multiline ? SubmitBehavior::Newline : SubmitBehavior::BlurAndSubmit; 192+ return props.multiline ? SubmitBehavior::Newline : SubmitBehavior::BlurAndSubmit; 193 } 194 195 return submitBehaviorDefaultable; 196diff --git a/node_modules/@mattermost/react-native-paste-input/ios/PasteTextInputSpecs/Props.cpp b/node_modules/@mattermost/react-native-paste-input/ios/PasteTextInputSpecs/Props.cpp 197index 29e094f..7ef519a 100644 198--- a/node_modules/@mattermost/react-native-paste-input/ios/PasteTextInputSpecs/Props.cpp 199+++ b/node_modules/@mattermost/react-native-paste-input/ios/PasteTextInputSpecs/Props.cpp 200@@ -22,8 +22,7 @@ PasteTextInputProps::PasteTextInputProps( 201 const PropsParserContext &context, 202 const PasteTextInputProps &sourceProps, 203 const RawProps& rawProps) 204- : ViewProps(context, sourceProps, rawProps), 205- BaseTextProps(context, sourceProps, rawProps), 206+ : BaseTextInputProps(context, sourceProps, rawProps), 207 traits(convertRawProp(context, rawProps, sourceProps.traits, {})), 208 smartPunctuation(convertRawProp(context, rawProps, "smartPunctuation", sourceProps.smartPunctuation, {})), 209 disableCopyPaste(convertRawProp(context, rawProps, "disableCopyPaste", sourceProps.disableCopyPaste, {false})), 210@@ -133,7 +132,7 @@ TextAttributes PasteTextInputProps::getEffectiveTextAttributes(Float fontSizeMul 211 ParagraphAttributes PasteTextInputProps::getEffectiveParagraphAttributes() const { 212 auto result = paragraphAttributes; 213 214- if (!traits.multiline) { 215+ if (!multiline) { 216 result.maximumNumberOfLines = 1; 217 } 218 219diff --git a/node_modules/@mattermost/react-native-paste-input/ios/PasteTextInputSpecs/Props.h b/node_modules/@mattermost/react-native-paste-input/ios/PasteTextInputSpecs/Props.h 220index 723d00c..31cfe66 100644 221--- a/node_modules/@mattermost/react-native-paste-input/ios/PasteTextInputSpecs/Props.h 222+++ b/node_modules/@mattermost/react-native-paste-input/ios/PasteTextInputSpecs/Props.h 223@@ -15,6 +15,7 @@ 224 #include <react/renderer/components/iostextinput/conversions.h> 225 #include <react/renderer/components/iostextinput/primitives.h> 226 #include <react/renderer/components/text/BaseTextProps.h> 227+#include <react/renderer/components/textinput/BaseTextInputProps.h> 228 #include <react/renderer/components/view/ViewProps.h> 229 #include <react/renderer/core/Props.h> 230 #include <react/renderer/core/PropsParserContext.h> 231@@ -25,7 +26,7 @@ 232 233 namespace facebook::react { 234 235-class PasteTextInputProps final : public ViewProps, public BaseTextProps { 236+class PasteTextInputProps final : public BaseTextInputProps { 237 public: 238 PasteTextInputProps() = default; 239 PasteTextInputProps(const PropsParserContext& context, const PasteTextInputProps& sourceProps, const RawProps& rawProps); 240diff --git a/node_modules/@mattermost/react-native-paste-input/ios/PasteTextInputSpecs/ShadowNodes.cpp b/node_modules/@mattermost/react-native-paste-input/ios/PasteTextInputSpecs/ShadowNodes.cpp 241index 31e07e3..7f0ebfb 100644 242--- a/node_modules/@mattermost/react-native-paste-input/ios/PasteTextInputSpecs/ShadowNodes.cpp 243+++ b/node_modules/@mattermost/react-native-paste-input/ios/PasteTextInputSpecs/ShadowNodes.cpp 244@@ -91,20 +91,11 @@ void PasteTextInputShadowNode::updateStateIfNeeded( 245 const auto& state = getStateData(); 246 247 react_native_assert(textLayoutManager_); 248- react_native_assert( 249- (!state.layoutManager || state.layoutManager == textLayoutManager_) && 250- "`StateData` refers to a different `TextLayoutManager`"); 251- 252- if (state.reactTreeAttributedString == reactTreeAttributedString && 253- state.layoutManager == textLayoutManager_) { 254- return; 255- } 256 257 auto newState = TextInputState{}; 258 newState.attributedStringBox = AttributedStringBox{reactTreeAttributedString}; 259 newState.paragraphAttributes = getConcreteProps().paragraphAttributes; 260 newState.reactTreeAttributedString = reactTreeAttributedString; 261- newState.layoutManager = textLayoutManager_; 262 newState.mostRecentEventCount = getConcreteProps().mostRecentEventCount; 263 setStateData(std::move(newState)); 264 }