Skip to content
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

Conversation

vonovak
Copy link
Collaborator

@vonovak vonovak commented Jun 17, 2019

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;

- (NSAttributedString *)attributedTextWithBaseTextAttributes:(nullable RCTTextAttributes *)baseTextAttributes

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 of RCTBaseTextShadowView can also access the caching fields.

Changelog

Not needed I guess.

Test Plan

This will work just the same - works locally, CI should pass.

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Jun 17, 2019
@pull-bot
Copy link

Messages
📖

📋 Verify Changelog Format - A changelog entry has the following format: [CATEGORY] [TYPE] - Message.

CATEGORY may be:
  • General
  • iOS
  • Android
  • JavaScript
  • Internal (for changes that do not need to be called out in the release notes)

TYPE may be:

  • Added, for new features.
  • Changed, for changes in existing functionality.
  • Deprecated, for soon-to-be removed features.
  • Removed, for now removed features.
  • Fixed, for any bug fixes.
  • Security, in case of vulnerabilities.

MESSAGE may answer "what and why" on a feature level. Use this to briefly tell React Native users about notable changes.

Generated by 🚫 dangerJS against 19f48fe

Copy link
Contributor

@cpojer cpojer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Copy link
Contributor

@facebook-github-bot facebook-github-bot left a 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.

@react-native-bot
Copy link
Collaborator

This pull request was successfully merged by @vonovak in 23df1b0.

When will my fix make it into a release? | Upcoming Releases

@react-native-bot react-native-bot added the Merged This PR has been merged. label Jun 18, 2019
@vonovak vonovak deleted the allowCustomAttributedTextWithBaseTextAttributes branch June 18, 2019 11:04
M-i-k-e-l pushed a commit to M-i-k-e-l/react-native that referenced this pull request Mar 10, 2020
…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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Merged This PR has been merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants