Skip to content

Commit afca9cd

Browse files
ErionTpclaude
andcommitted
feat(ios): add paragraphSpacing support to checkbox list
Add a `paragraphSpacing` property to `ulCheckbox` in `HtmlStyle` to control vertical spacing between checkbox list items on iOS. Uses `NSMutableParagraphStyle.paragraphSpacing` which was already available but not wired up. Defaults to 0 (no change in existing behavior). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent eab0c2e commit afca9cd

7 files changed

Lines changed: 25 additions & 0 deletions

File tree

ios/EnrichedTextInputView.mm

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -652,6 +652,12 @@ - (void)updateProps:(Props::Shared const &)props
652652
}
653653
}
654654

655+
if (newViewProps.htmlStyle.ulCheckbox.paragraphSpacing !=
656+
oldViewProps.htmlStyle.ulCheckbox.paragraphSpacing) {
657+
[newConfig setCheckboxListParagraphSpacing:newViewProps.htmlStyle.ulCheckbox.paragraphSpacing];
658+
stylePropChanged = YES;
659+
}
660+
655661
if (newViewProps.htmlStyle.a.textDecorationLine !=
656662
oldViewProps.htmlStyle.a.textDecorationLine) {
657663
NSString *objcString =

ios/config/InputConfig.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,8 @@
9999
- (void)setCheckboxListMarginLeft:(CGFloat)newValue;
100100
- (UIColor *)checkboxListBoxColor;
101101
- (void)setCheckboxListBoxColor:(UIColor *)newValue;
102+
- (CGFloat)checkboxListParagraphSpacing;
103+
- (void)setCheckboxListParagraphSpacing:(CGFloat)newValue;
102104
- (UIImage *)checkboxCheckedImage;
103105
- (UIImage *)checkboxUncheckedImage;
104106
@end

ios/config/InputConfig.mm

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ @implementation InputConfig {
5252
CGFloat _checkboxListGapWidth;
5353
CGFloat _checkboxListMarginLeft;
5454
UIColor *_checkboxListBoxColor;
55+
CGFloat _checkboxListParagraphSpacing;
5556
UIImage *_checkboxCheckedImage;
5657
UIImage *_checkboxUncheckedImage;
5758
}
@@ -113,6 +114,7 @@ - (id)copyWithZone:(NSZone *)zone {
113114
copy->_checkboxListGapWidth = _checkboxListGapWidth;
114115
copy->_checkboxListMarginLeft = _checkboxListMarginLeft;
115116
copy->_checkboxListBoxColor = [_checkboxListBoxColor copy];
117+
copy->_checkboxListParagraphSpacing = _checkboxListParagraphSpacing;
116118
copy->_checkboxCheckedImage = _checkboxCheckedImage;
117119
copy->_checkboxUncheckedImage = _checkboxUncheckedImage;
118120
return copy;
@@ -596,6 +598,14 @@ - (void)setCheckboxListBoxColor:(UIColor *)newValue {
596598
}
597599
}
598600

601+
- (CGFloat)checkboxListParagraphSpacing {
602+
return _checkboxListParagraphSpacing;
603+
}
604+
605+
- (void)setCheckboxListParagraphSpacing:(CGFloat)newValue {
606+
_checkboxListParagraphSpacing = newValue;
607+
}
608+
599609
- (UIImage *)checkboxCheckedImage {
600610
if (!_checkboxCheckedImage) {
601611
_checkboxCheckedImage = [self generateCheckboxImage:YES];

ios/styles/CheckboxListStyle.mm

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ - (void)removeAttributes:(NSRange)range {
8181
pStyle.textLists = @[];
8282
pStyle.headIndent = 0;
8383
pStyle.firstLineHeadIndent = 0;
84+
pStyle.paragraphSpacing = 0;
8485
[_input->textView.textStorage
8586
addAttribute:NSParagraphStyleAttributeName
8687
value:pStyle
@@ -98,6 +99,7 @@ - (void)removeAttributes:(NSRange)range {
9899
pStyle.textLists = @[];
99100
pStyle.headIndent = 0;
100101
pStyle.firstLineHeadIndent = 0;
102+
pStyle.paragraphSpacing = 0;
101103
typingAttrs[NSParagraphStyleAttributeName] = pStyle;
102104
_input->textView.typingAttributes = typingAttrs;
103105
}
@@ -220,6 +222,7 @@ - (void)addAttributesWithCheckedValue:(BOOL)checked
220222
pStyle.textLists = @[ checkboxMarker ];
221223
pStyle.headIndent = [self getHeadIndent];
222224
pStyle.firstLineHeadIndent = [self getHeadIndent];
225+
pStyle.paragraphSpacing = [_input->config checkboxListParagraphSpacing];
223226
[_input->textView.textStorage
224227
addAttribute:NSParagraphStyleAttributeName
225228
value:pStyle
@@ -249,6 +252,7 @@ - (void)addAttributesWithCheckedValue:(BOOL)checked
249252
pStyle.textLists = @[ checkboxMarker ];
250253
pStyle.headIndent = [self getHeadIndent];
251254
pStyle.firstLineHeadIndent = [self getHeadIndent];
255+
pStyle.paragraphSpacing = [_input->config checkboxListParagraphSpacing];
252256
typingAttrs[NSParagraphStyleAttributeName] = pStyle;
253257
_input->textView.typingAttributes = typingAttrs;
254258
}

src/spec/EnrichedTextInputNativeComponent.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,7 @@ export interface HtmlStyleInternal {
342342
boxSize?: Float;
343343
marginLeft?: Float;
344344
boxColor?: ColorValue;
345+
paragraphSpacing?: Float;
345346
};
346347
}
347348

src/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,5 +55,6 @@ export interface HtmlStyle {
5555
gapWidth?: number;
5656
marginLeft?: number;
5757
boxColor?: ColorValue;
58+
paragraphSpacing?: number;
5859
};
5960
}

src/utils/normalizeHtmlStyle.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ const defaultStyle: Required<HtmlStyle> = {
6868
gapWidth: 16,
6969
marginLeft: 16,
7070
boxColor: 'blue',
71+
paragraphSpacing: 0,
7172
},
7273
};
7374

0 commit comments

Comments
 (0)