Skip to content

Commit b0ab993

Browse files
authored
feat: unify lists' gaps with Android implementation (#130)
1 parent c08d3f8 commit b0ab993

5 files changed

Lines changed: 7 additions & 18 deletions

File tree

ios/config/EditorConfig.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@
5050
- (UIColor *)orderedListMarkerColor;
5151
- (void)setOrderedListMarkerColor:(UIColor *)newValue;
5252
- (UIFont *)orderedListMarkerFont;
53-
- (CGFloat)orderedListMarkerWidth;
5453
- (UIColor *)unorderedListBulletColor;
5554
- (void)setUnorderedListBulletColor:(UIColor *)newValue;
5655
- (CGFloat)unorderedListBulletSize;

ios/config/EditorConfig.mm

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -313,15 +313,6 @@ - (UIFont *)orderedListMarkerFont {
313313
return _orderedListMarkerFont;
314314
}
315315

316-
- (CGFloat)orderedListMarkerWidth {
317-
NSDictionary *markerAttributes = @{
318-
NSFontAttributeName: [self primaryFont],
319-
NSForegroundColorAttributeName: [self primaryColor]
320-
};
321-
// TODO: marker widths could be dynamic, for now we settle with (usually) the widest 2-digit marker
322-
return [@"88." sizeWithAttributes:markerAttributes].width;
323-
}
324-
325316
- (UIColor *)unorderedListBulletColor {
326317
return _unorderedListBulletColor;
327318
}

ios/styles/OrderedListStyle.mm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ + (StyleType)getStyleType { return OrderedList; }
1313

1414
- (CGFloat)getHeadIndent {
1515
// lists are drawn manually
16-
// margin before marker + marker width + gap between marker and paragraph
17-
return [_editor->config orderedListMarginLeft] + [_editor->config orderedListMarkerWidth] + [_editor->config orderedListGapWidth];
16+
// margin before marker + gap between marker and paragraph
17+
return [_editor->config orderedListMarginLeft] + [_editor->config orderedListGapWidth];
1818
}
1919

2020
- (instancetype)initWithEditor:(id)editor {

ios/styles/UnorderedListStyle.mm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ + (StyleType)getStyleType { return UnorderedList; }
1313

1414
- (CGFloat)getHeadIndent {
1515
// lists are drawn manually
16-
// margin before bullet + bullet size + gap between bullet and paragraph
17-
return [_editor->config unorderedListMarginLeft] + [_editor->config unorderedListBulletSize] + [_editor->config unorderedListGapWidth];
16+
// margin before bullet + gap between bullet and paragraph
17+
return [_editor->config unorderedListMarginLeft] + [_editor->config unorderedListGapWidth];
1818
}
1919

2020
- (instancetype)initWithEditor:(id)editor {

ios/utils/LayoutManagerExtension.mm

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,14 +107,13 @@ - (void)my_drawBackgroundForGlyphRange:(NSRange)glyphRange atPoint:(CGPoint)orig
107107
if(pStyle.textLists.firstObject.markerFormat == NSTextListMarkerDecimal) {
108108
CGFloat gapWidth = [typedEditor->config orderedListGapWidth];
109109
CGFloat markerWidth = [marker sizeWithAttributes:markerAttributes].width;
110-
CGFloat rightEdge = usedRect.origin.x - gapWidth;
111-
CGFloat numberX = rightEdge - markerWidth;
110+
CGFloat markerX = usedRect.origin.x - gapWidth - markerWidth/2;
112111

113-
[marker drawAtPoint:CGPointMake(numberX, usedRect.origin.y + origin.y) withAttributes:markerAttributes];
112+
[marker drawAtPoint:CGPointMake(markerX, usedRect.origin.y + origin.y) withAttributes:markerAttributes];
114113
} else {
115114
CGFloat gapWidth = [typedEditor->config unorderedListGapWidth];
116115
CGFloat bulletSize = [typedEditor->config unorderedListBulletSize];
117-
CGFloat bulletX = usedRect.origin.x - gapWidth - bulletSize;
116+
CGFloat bulletX = usedRect.origin.x - gapWidth - bulletSize/2;
118117
CGFloat centerY = CGRectGetMidY(usedRect);
119118

120119
CGContextRef context = UIGraphicsGetCurrentContext();

0 commit comments

Comments
 (0)