Fabric: Propper support for `accessibilityLabel` in RCTParagraphComponentView
Summary: @public This approach is basically copying exising implementation that we have in RCTTextView (D5806097). Changes in `AttributedString` is quite trivial. Reviewed By: mdvacca Differential Revision: D8740000 fbshipit-source-id: 276afdf93d777f7ccb99ca8ee5a18a880de2acbf
This commit is contained in:
parent
c68c3a53d4
commit
732c3a4f4e
|
@ -68,4 +68,20 @@ using namespace facebook::react;
|
|||
frame:frame];
|
||||
}
|
||||
|
||||
#pragma mark - Accessibility
|
||||
|
||||
- (NSString *)accessibilityLabel
|
||||
{
|
||||
NSString *superAccessibilityLabel = [super accessibilityLabel];
|
||||
if (superAccessibilityLabel) {
|
||||
return superAccessibilityLabel;
|
||||
}
|
||||
|
||||
if (!_paragraphLocalData) {
|
||||
return nil;
|
||||
}
|
||||
|
||||
return RCTNSStringFromString(_paragraphLocalData->getAttributedString().getString());
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
@ -39,6 +39,14 @@ const std::vector<Fragment> &AttributedString::getFragments() const {
|
|||
return fragments_;
|
||||
}
|
||||
|
||||
std::string AttributedString::getString() const {
|
||||
std::string string;
|
||||
for (const auto &fragment : fragments_) {
|
||||
string += fragment.string;
|
||||
}
|
||||
return string;
|
||||
}
|
||||
|
||||
#pragma mark - DebugStringConvertible
|
||||
|
||||
SharedDebugStringConvertibleList AttributedString::getDebugChildren() const {
|
||||
|
|
|
@ -61,6 +61,11 @@ public:
|
|||
*/
|
||||
const Fragments &getFragments() const;
|
||||
|
||||
/*
|
||||
* Returns a string constructed from all strings in all fragments.
|
||||
*/
|
||||
std::string getString() const;
|
||||
|
||||
#pragma mark - DebugStringConvertible
|
||||
|
||||
SharedDebugStringConvertibleList getDebugChildren() const override;
|
||||
|
|
Loading…
Reference in New Issue