From 3ced129c06e5e52f78aafb5fc871351735069e00 Mon Sep 17 00:00:00 2001 From: Tomek Zawadzki Date: Sun, 22 Dec 2024 10:13:10 +0100 Subject: [PATCH] Unify `NSMutableParagraphStyle` creation --- apple/MarkdownFormatter.mm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/apple/MarkdownFormatter.mm b/apple/MarkdownFormatter.mm index 5877e634..06917589 100644 --- a/apple/MarkdownFormatter.mm +++ b/apple/MarkdownFormatter.mm @@ -113,7 +113,8 @@ - (void)applyRangeToAttributedString:(NSMutableAttributedString *)attributedStri [attributedString addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:range]; [attributedString addAttribute:RCTLiveMarkdownBlockquoteDepthAttributeName value:@(depth) range:range]; } else if (type == "h1" && markdownStyle.h1LineHeight != -1) { - NSMutableParagraphStyle *paragraphStyle = [NSMutableParagraphStyle new]; + NSParagraphStyle *defaultParagraphStyle = defaultTextAttributes[NSParagraphStyleAttributeName]; + NSMutableParagraphStyle *paragraphStyle = defaultParagraphStyle != nil ? [defaultParagraphStyle mutableCopy] : [NSMutableParagraphStyle new]; paragraphStyle.lineHeightMultiple = markdownStyle.h1LineHeight / markdownStyle.h1FontSize; NSRange rangeWithHashAndSpace = NSMakeRange(range.location - 2, range.length + 2); [attributedString addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:rangeWithHashAndSpace];