diff --git a/React/Fabric/Mounting/ComponentViews/Text/RCTParagraphComponentAccessibilityProvider.h b/React/Fabric/Mounting/ComponentViews/Text/RCTParagraphComponentAccessibilityProvider.h new file mode 100644 index 00000000000..30ad700e02a --- /dev/null +++ b/React/Fabric/Mounting/ComponentViews/Text/RCTParagraphComponentAccessibilityProvider.h @@ -0,0 +1,23 @@ +/* + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +#import + +#import + +#import "RCTParagraphComponentView.h" + +@interface RCTParagraphComponentAccessibilityProvider : NSObject + +- (instancetype)initWithString:(facebook::react::AttributedString)attributedString view:(UIView *)view; + +/** + @abstract Array of accessibleElements for use in UIAccessibilityContainer implementation. +*/ +- (NSArray *)accessibilityElements; + +@end diff --git a/React/Fabric/Mounting/ComponentViews/Text/RCTParagraphComponentAccessibilityProvider.mm b/React/Fabric/Mounting/ComponentViews/Text/RCTParagraphComponentAccessibilityProvider.mm new file mode 100644 index 00000000000..248e5a437f3 --- /dev/null +++ b/React/Fabric/Mounting/ComponentViews/Text/RCTParagraphComponentAccessibilityProvider.mm @@ -0,0 +1,46 @@ +/* + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +#import "RCTParagraphComponentAccessibilityProvider.h" + +#import +#import +#import +#import + +#import "RCTConversions.h" +#import "RCTFabricComponentsPlugins.h" + +using namespace facebook::react; + +@implementation RCTParagraphComponentAccessibilityProvider { + NSMutableArray *_accessibilityElements; + AttributedString _attributedString; + __weak UIView *_view; +} + +- (instancetype)initWithString:(AttributedString)attributedString view:(UIView *)view +{ + if (self = [super init]) { + _attributedString = attributedString; + _view = view; + } + return self; +} + +- (NSArray *)accessibilityElements +{ + // verify if accessibleElements are exist + // build an array of the accessibleElements + // add first element has the text for the whole textview in order to read out the whole text + // add additional elements for those parts of text with embedded link so VoiceOver could specially recognize links + // add accessible element for truncation attributed string for automation purposes only + _accessibilityElements = [NSMutableArray new]; + return _accessibilityElements; +} + +@end