-
Notifications
You must be signed in to change notification settings - Fork 24.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
allow custom attributedTextWithBaseTextAttributes in RCTBaseTextShadowView subclasses #25283
allow custom attributedTextWithBaseTextAttributes in RCTBaseTextShadowView subclasses #25283
Conversation
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cpojer is landing this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
This pull request was successfully merged by @vonovak in 23df1b0. When will my fix make it into a release? | Upcoming Releases |
…wView subclasses (facebook#25283) Summary: This is similar to facebook#24995 but for iOS. Motivation: when building a custom Text or TextInput (eg with rich text support), one needs custom text processing logic (turning the JS text value to a `NSAttributedString`). RCTBaseTextShadowView contains `- (NSAttributedString *)attributedTextWithBaseTextAttributes:(nullable RCTTextAttributes *)baseTextAttributes;` https://github.com/facebook/react-native/blob/853c667eb5a66612c33e0786ab6c458dcaee6133/Libraries/Text/BaseText/RCTBaseTextShadowView.m#L78 This method, given `self.reactSubviews` creates and returns an instance of [NSMutableAttributedString](https://developer.apple.com/documentation/foundation/nsmutableattributedstring?language=objc). It's currently possible to override this method in subclasses, but the original implementation reads and writes two cache fields which are private. This PR just changes the access modifiers so that subclasses of `RCTBaseTextShadowView` can also access the caching fields. ## Changelog Not needed I guess. Pull Request resolved: facebook#25283 Test Plan: This will work just the same - works locally, CI should pass. Differential Revision: D15873741 Pulled By: cpojer fbshipit-source-id: dd26a4241f2ac6c0870b6c302939e2f3b0ecc8ff
Summary
This is similar to #24995 but for iOS.
Motivation: when building a custom Text or TextInput (eg with rich text support), one needs custom text processing logic (turning the JS text value to a
NSAttributedString
).RCTBaseTextShadowView contains
- (NSAttributedString *)attributedTextWithBaseTextAttributes:(nullable RCTTextAttributes *)baseTextAttributes;
react-native/Libraries/Text/BaseText/RCTBaseTextShadowView.m
Line 78 in 853c667
This method, given
self.reactSubviews
creates and returns an instance of NSMutableAttributedString. It's currently possible to override this method in subclasses, but the original implementation reads and writes two cache fields which are private. This PR just changes the access modifiers so that subclasses ofRCTBaseTextShadowView
can also access the caching fields.Changelog
Not needed I guess.
Test Plan
This will work just the same - works locally, CI should pass.