From dbf738c81d295e1c3089f34bbf0df04ab15da906 Mon Sep 17 00:00:00 2001 From: Amy Worrall Date: Fri, 1 Mar 2024 09:45:04 -0800 Subject: [PATCH] List bullet positioning and first line paragraph spacing before Summary: If something is the first line in the document, TextKit doesn't apply a paragraphSpacingBefore value. Our list bullet drawing code compensates for paragraphSpacingBefore. This was causing us to draw incorrectly positioned bullets if paragraphSpacingBefore was used and the list was the first thing in the document. Differential Revision: D54380971 fbshipit-source-id: 04156ede936686c74c1294ab612430570c55c596 --- Plugins/LexicalListPlugin/LexicalListPlugin/ListPlugin.swift | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Plugins/LexicalListPlugin/LexicalListPlugin/ListPlugin.swift b/Plugins/LexicalListPlugin/LexicalListPlugin/ListPlugin.swift index b5d70c5..2b7b3dc 100644 --- a/Plugins/LexicalListPlugin/LexicalListPlugin/ListPlugin.swift +++ b/Plugins/LexicalListPlugin/LexicalListPlugin/ListPlugin.swift @@ -52,6 +52,8 @@ open class ListPlugin: Plugin { return } + let isFirstLine = (glyphRange.location == 0) + var attributes = textStorage.attributes(at: characterRange.location, effectiveRange: nil) var spacingBefore = 0.0 @@ -59,7 +61,7 @@ open class ListPlugin: Plugin { mutableParagraphStyle.headIndent = 0 mutableParagraphStyle.firstLineHeadIndent = 0 mutableParagraphStyle.tailIndent = 0 - spacingBefore = paragraphStyle.paragraphSpacingBefore + spacingBefore = isFirstLine ? 0 : paragraphStyle.paragraphSpacingBefore mutableParagraphStyle.paragraphSpacingBefore = 0 attributes[.paragraphStyle] = mutableParagraphStyle }