@@ -65,12 +65,17 @@ - (void)my_drawBackgroundForGlyphRange:(NSRange)glyphRange atPoint:(CGPoint)orig
6565 NSRange paragraphGlyphRange = [self glyphRangeForCharacterRange: paragraphRange actualCharacterRange: nullptr ];
6666 [self enumerateLineFragmentsForGlyphRange: paragraphGlyphRange
6767 usingBlock: ^(CGRect rect, CGRect usedRect, NSTextContainer * _Nonnull textContainer, NSRange glyphRange, BOOL * _Nonnull stop) {
68- CGFloat paddingLeft = origin.x ;
69- CGFloat paddingTop = origin.y ;
70- CGFloat x = paddingLeft;
71- CGFloat y = paddingTop + rect.origin .y ;
68+ BOOL isRTL = [[RCTI18nUtil sharedInstance ] isRTL ];
7269 CGFloat width = [typedInput->config blockquoteBorderWidth ];
7370 CGFloat height = rect.size .height ;
71+
72+ CGFloat x = 0 ;
73+ if (isRTL) {
74+ x = origin.x + rect.size .width - width;
75+ } else {
76+ x = origin.x ;
77+ }
78+ CGFloat y = origin.y + rect.origin .y ;
7479
7580 CGRect lineRect = CGRectMake (x, y, width, height);
7681 [[typedInput->config blockquoteBorderColor ] setFill ];
@@ -103,18 +108,34 @@ - (void)my_drawBackgroundForGlyphRange:(NSRange)glyphRange atPoint:(CGPoint)orig
103108 [self enumerateLineFragmentsForGlyphRange: paragraphGlyphRange
104109 usingBlock: ^(CGRect rect, CGRect usedRect, NSTextContainer *container, NSRange lineGlyphRange, BOOL *stop) {
105110 NSString *marker = [self markerForList: pStyle.textLists.firstObject charIndex: [self characterIndexForGlyphAtIndex: lineGlyphRange.location] input: typedInput];
111+ BOOL isRTL = [[RCTI18nUtil sharedInstance ] isRTL ];
112+
113+ CGFloat textStartLeft = usedRect.origin .x ;
114+ CGFloat textEndRight = usedRect.origin .x + usedRect.size .width ;
106115
107116 if (pStyle.textLists .firstObject .markerFormat == NSTextListMarkerDecimal ) {
108117 CGFloat gapWidth = [typedInput->config orderedListGapWidth ];
109118 CGFloat markerWidth = [marker sizeWithAttributes: markerAttributes].width ;
110- CGFloat markerX = usedRect.origin .x - gapWidth - markerWidth/2 ;
119+ CGFloat markerX = 0 ;
120+
121+ if (isRTL) {
122+ markerX = textEndRight + gapWidth;
123+ } else {
124+ markerX = textStartLeft - gapWidth - markerWidth / 2 ;
125+ }
111126
112127 [marker drawAtPoint: CGPointMake (markerX, usedRect.origin.y + origin.y) withAttributes: markerAttributes];
113128 } else {
114129 CGFloat gapWidth = [typedInput->config unorderedListGapWidth ];
115130 CGFloat bulletSize = [typedInput->config unorderedListBulletSize ];
116- CGFloat bulletX = usedRect.origin .x - gapWidth - bulletSize/2 ;
117131 CGFloat centerY = CGRectGetMidY (usedRect);
132+ CGFloat bulletX = 0 ;
133+
134+ if (isRTL) {
135+ bulletX = textEndRight + gapWidth + (bulletSize / 2.0 );
136+ } else {
137+ bulletX = textStartLeft - gapWidth - (bulletSize / 2.0 );
138+ }
118139
119140 CGContextRef context = UIGraphicsGetCurrentContext ();
120141 CGContextSaveGState (context); {
@@ -161,8 +182,13 @@ - (NSString *)markerForList:(NSTextList *)list charIndex:(NSUInteger)index input
161182
162183 itemNumber = prevParagraphsCount + 1 ;
163184 }
185+ BOOL isRTL = [[RCTI18nUtil sharedInstance ] isRTL ];
164186
165- return [NSString stringWithFormat: @" %ld ." , (long )(itemNumber)];
187+ if (isRTL) {
188+ return [NSString stringWithFormat: @" .%ld " , (long )(itemNumber)];
189+ } else {
190+ return [NSString stringWithFormat: @" %ld ." , (long )(itemNumber)];
191+ }
166192 } else {
167193 return @" •" ;
168194 }
0 commit comments