Add accessibilityRole to RCTAttributedTextUtils
Summary: Changelog: [Internal] - Add `accessibilityRole` to `RCTAttributedTextUtils`. AccessibilityRole was in `TextAttributes` which is a Fabric's abstraction so cannot be detected when enumerating attributedString. Mapping accessibilityRole from `TextAttributes` to `NSAttributedString` could provide the attributeName when iterating over attributedString and then successfully find the range of the fragment whose `accessibilityRole` has value @"link". Reviewed By: shergin Differential Revision: D22286747 fbshipit-source-id: eb039d6a35e77d1860f86ba287391ccb56fbe7b5
This commit is contained in:
Родитель
96708d58e4
Коммит
c4c6204029
|
@ -15,6 +15,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
|
||||
NSString *const RCTAttributedStringIsHighlightedAttributeName = @"IsHighlighted";
|
||||
NSString *const RCTAttributedStringEventEmitterKey = @"EventEmitter";
|
||||
NSString *const RCTTextAttributesAccessibilityRoleAttributeName = @"AccessibilityRole";
|
||||
|
||||
/*
|
||||
* Creates `NSTextAttributes` from given `facebook::react::TextAttributes`
|
||||
|
|
|
@ -212,6 +212,11 @@ NSDictionary<NSAttributedStringKey, id> *RCTNSTextAttributesFromTextAttributes(T
|
|||
attributes[RCTAttributedStringIsHighlightedAttributeName] = @YES;
|
||||
}
|
||||
|
||||
if (!textAttributes.accessibilityRole.empty()) {
|
||||
attributes[RCTTextAttributesAccessibilityRoleAttributeName] =
|
||||
[NSString stringWithCString:textAttributes.accessibilityRole.c_str() encoding:NSUTF8StringEncoding];
|
||||
}
|
||||
|
||||
return [attributes copy];
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче