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:
Jiayan Zhuang 2020-07-06 14:58:38 -07:00 коммит произвёл Facebook GitHub Bot
Родитель 96708d58e4
Коммит c4c6204029
2 изменённых файлов: 6 добавлений и 0 удалений

Просмотреть файл

@ -15,6 +15,7 @@ NS_ASSUME_NONNULL_BEGIN
NSString *const RCTAttributedStringIsHighlightedAttributeName = @"IsHighlighted"; NSString *const RCTAttributedStringIsHighlightedAttributeName = @"IsHighlighted";
NSString *const RCTAttributedStringEventEmitterKey = @"EventEmitter"; NSString *const RCTAttributedStringEventEmitterKey = @"EventEmitter";
NSString *const RCTTextAttributesAccessibilityRoleAttributeName = @"AccessibilityRole";
/* /*
* Creates `NSTextAttributes` from given `facebook::react::TextAttributes` * Creates `NSTextAttributes` from given `facebook::react::TextAttributes`

Просмотреть файл

@ -212,6 +212,11 @@ NSDictionary<NSAttributedStringKey, id> *RCTNSTextAttributesFromTextAttributes(T
attributes[RCTAttributedStringIsHighlightedAttributeName] = @YES; attributes[RCTAttributedStringIsHighlightedAttributeName] = @YES;
} }
if (!textAttributes.accessibilityRole.empty()) {
attributes[RCTTextAttributesAccessibilityRoleAttributeName] =
[NSString stringWithCString:textAttributes.accessibilityRole.c_str() encoding:NSUTF8StringEncoding];
}
return [attributes copy]; return [attributes copy];
} }