Tighten markdown list spacing around prose

Lists previously had a static marginVertical that stacked with
paragraph.marginBottom, producing 20px gaps and oversized whitespace
around paragraphs sandwiched between lists.

Spacing is now context-aware via the render rule: list -> list keeps
the normal paragraph gap (back-to-back lists read as continuous
content) while p <-> list transitions get a slightly larger gap (lists
read as their own section). Static margins can't satisfy both because
RN doesn't collapse margins, so the bullet_list / ordered_list rule
inspects the next sibling type and picks marginBottom accordingly.
This commit is contained in:
Mohamed Boudra
2026-05-15 14:03:14 +07:00
parent 2f13c83c0e
commit eed61d338c
3 changed files with 100 additions and 15 deletions
+16
View File
@@ -60,6 +60,22 @@ function parseOrderedListStart(node: MarkdownNode): number {
return 1;
}
export function getMarkdownNextSiblingType(
node: MarkdownNode,
parent: unknown,
): string | undefined {
const ancestors = toParentNodes(parent);
for (let i = ancestors.length - 1; i >= 0; i--) {
const ancestor = ancestors[i];
if (!Array.isArray(ancestor?.children)) continue;
const idx = ancestor.children.indexOf(node);
if (idx >= 0) {
return ancestor.children[idx + 1]?.type;
}
}
return undefined;
}
export function getMarkdownListMarker(
node: MarkdownNode,
parent: unknown,