-
Notifications
You must be signed in to change notification settings - Fork 118
feat: support rendering of line between columns #2743
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2227,6 +2227,45 @@ export class DomPainter { | |
| ); | ||
| }); | ||
| this.renderDecorationsForPage(el, page, pageIndex); | ||
|
|
||
| // Render vertical separator lines between columns when lineBetween is enabled | ||
| if (page.columns?.lineBetween && page.columns.count > 1 && page.margins && this.doc) { | ||
| const cols = page.columns; | ||
|
Comment on lines
+2231
to
+2233
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
This separator logic was added only to Useful? React with 👍 / 👎. |
||
| const margins = page.margins; | ||
| const pageHeight = page.size?.h ?? height; | ||
| const contentTop = margins.top; | ||
| const contentBottom = pageHeight - margins.bottom; | ||
| const lineHeight = contentBottom - contentTop; | ||
|
|
||
| if (lineHeight > 0) { | ||
| const colWidths = Array.isArray(cols.widths) && cols.widths.length > 0 ? cols.widths : null; | ||
| for (let c = 0; c < cols.count - 1; c++) { | ||
| let lineX: number; | ||
| if (colWidths) { | ||
| let x = margins.left; | ||
| for (let j = 0; j <= c; j++) { | ||
| x += colWidths[j] ?? 0; | ||
| if (j < c) x += cols.gap; | ||
| } | ||
| lineX = x + cols.gap / 2; | ||
| } else { | ||
| const colWidth = (width - margins.left - margins.right - (cols.count - 1) * cols.gap) / cols.count; | ||
| lineX = margins.left + (c + 1) * colWidth + (c + 0.5) * cols.gap; | ||
| } | ||
|
|
||
| const line = this.doc.createElement('div'); | ||
| line.style.position = 'absolute'; | ||
| line.style.left = `${lineX}px`; | ||
| line.style.top = `${contentTop}px`; | ||
| line.style.width = '0px'; | ||
| line.style.height = `${lineHeight}px`; | ||
| line.style.borderLeft = '1px solid #000'; | ||
| line.style.pointerEvents = 'none'; | ||
| el.appendChild(line); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| return el; | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
page.columns = activeColumnsassumes the newlineBetweenflag survives section-state cloning, butcloneColumnLayoutcurrently drops that field (packages/layout-engine/contracts/src/column-layout.ts, functioncloneColumnLayout). As a result,page.columns.lineBetweenis typicallyundefinedeven when<w:cols w:sep="1">is parsed, so the separator rendering path never activates. Please propagatelineBetweenthrough the column clone/state pipeline before assigning it to the page.Useful? React with 👍 / 👎.