Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/layout-engine/contracts/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1168,6 +1168,7 @@ export type ParagraphBorders = {
bottom?: ParagraphBorder;
left?: ParagraphBorder;
between?: ParagraphBorder;
bar?: ParagraphBorder;
};

export type ParagraphShading = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,11 @@ export const applyParagraphBorderStyles = (
if (showBetweenBorder && borders.between) {
setBorderSideStyle(element, 'bottom', borders.between);
}

// Bar border: decorative vertical line on the left edge of the paragraph (OOXML §17.3.1.4)
if (borders.bar && borders.bar.style !== 'none') {
setBorderSideStyle(element, 'left', borders.bar);
Comment on lines +219 to +220
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Include bar border in left-side geometry calculations

Applying borders.bar directly to border-left here introduces a rendering mismatch: the layer box is still expanded from borders.left only (computeBorderSpaceExpansion and computeRenderedBorderWidths), so bar.width/bar.space are not reserved. In paragraphs with only w:bar (or with a wider bar than left), the new bar border is drawn into the content box and can overlap text instead of being offset outward like other paragraph borders.

Useful? React with 👍 / 👎.

}
};

const setBorderSideStyle = (element: HTMLElement, side: CssBorderSide, border: ParagraphBorder): void => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export const hashParagraphBorders = (borders: ParagraphBorders): string => {
if (borders.bottom) parts.push(`b:[${hashParagraphBorder(borders.bottom)}]`);
if (borders.left) parts.push(`l:[${hashParagraphBorder(borders.left)}]`);
if (borders.between) parts.push(`bw:[${hashParagraphBorder(borders.between)}]`);
if (borders.bar) parts.push(`bar:[${hashParagraphBorder(borders.bar)}]`);
return parts.join(';');
};

Expand Down
9 changes: 8 additions & 1 deletion packages/layout-engine/pm-adapter/src/attributes/borders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,14 @@ export function extractCellPadding(cellAttrs: Record<string, unknown>): BoxSpaci
export const normalizeParagraphBorders = (value: unknown): ParagraphAttrs['borders'] | undefined => {
if (!value || typeof value !== 'object') return undefined;
const source = value as Record<string, unknown>;
const sides: Array<'top' | 'right' | 'bottom' | 'left' | 'between'> = ['top', 'right', 'bottom', 'left', 'between'];
const sides: Array<'top' | 'right' | 'bottom' | 'left' | 'between' | 'bar'> = [
'top',
'right',
'bottom',
'left',
'between',
'bar',
];
const borders: ParagraphAttrs['borders'] = {};

sides.forEach((side) => {
Expand Down
Loading