Skip to content

Commit 1a901dd

Browse files
committed
fix: apply between border space below to match Word paragraph spacing
The between border was flush against the next paragraph's text. Now: - First paragraph reduces gap extension by between.space, positioning the between border higher in the spacing gap - Second paragraph extends upward by between.space to maintain continuous left/right borders through the gap
1 parent 9d518a8 commit 1a901dd

1 file changed

Lines changed: 17 additions & 2 deletions

File tree

  • packages/layout-engine/painters/dom/src/features/paragraph-borders

packages/layout-engine/painters/dom/src/features/paragraph-borders/border-layer.ts

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,15 @@ export const computeBorderSpaceExpansion = (
6161
const showBetween = betweenInfo?.showBetweenBorder ?? false;
6262

6363
return {
64-
top: !suppressTop && borders.top?.space ? borders.top.space * PX_PER_PT : 0,
64+
// When top is suppressed (non-first group member), use the between border's space
65+
// to extend upward and fill the gap left by the previous paragraph's reduced extension.
66+
top: suppressTop
67+
? borders.between?.space
68+
? borders.between.space * PX_PER_PT
69+
: 0
70+
: borders.top?.space
71+
? borders.top.space * PX_PER_PT
72+
: 0,
6573
bottom: !suppressBottom && !showBetween && borders.bottom?.space ? borders.bottom.space * PX_PER_PT : 0,
6674
left: borders.left?.space ? borders.left.space * PX_PER_PT : 0,
6775
right: borders.right?.space ? borders.right.space * PX_PER_PT : 0,
@@ -97,7 +105,14 @@ export const createParagraphDecorationLayers = (
97105
// Extend layers into the spacing gap for continuous group borders.
98106
// Both real between (showBetweenBorder) and nil/none between (suppressBottomBorder)
99107
// need gap extension to keep left/right borders continuous through the spacing gap.
100-
const gapExtension = betweenInfo?.showBetweenBorder || betweenInfo?.suppressBottomBorder ? betweenInfo!.gapBelow : 0;
108+
//
109+
// For showBetweenBorder: reduce extension by between.space so the between border
110+
// (drawn as CSS bottom border) sits higher in the gap, creating padding to the next
111+
// paragraph. The next paragraph's top expansion fills the remaining gap portion.
112+
const betweenSpaceBelow =
113+
betweenInfo?.showBetweenBorder && attrs.borders?.between?.space ? attrs.borders.between.space * PX_PER_PT : 0;
114+
const rawGap = betweenInfo?.showBetweenBorder || betweenInfo?.suppressBottomBorder ? betweenInfo!.gapBelow : 0;
115+
const gapExtension = Math.max(0, rawGap - betweenSpaceBelow);
101116

102117
// Border widths for each rendered side. With box-sizing: border-box, CSS borders are
103118
// drawn INSIDE the element. To position the border's inner edge at `space` distance

0 commit comments

Comments
 (0)