Skip to content

fix(layout): respect section and table metrics#320

Open
juanmendez-git wants to merge 6 commits intoeigenpal:mainfrom
juanmendez-git:fix/docx-layout-sections-tables
Open

fix(layout): respect section and table metrics#320
juanmendez-git wants to merge 6 commits intoeigenpal:mainfrom
juanmendez-git:fix/docx-layout-sections-tables

Conversation

@juanmendez-git
Copy link
Copy Markdown
Contributor

@juanmendez-git juanmendez-git commented Apr 28, 2026

Summary

Fixes DOCX pagination/layout mismatches where rendered output diverged from Word for documents with mixed sections, rendered page-break markers, and auto-fit tables.

The main issue was that layout treated page geometry too globally. Documents with multiple sections could render portrait/landscape pages, margins, and columns using the wrong section properties, which shifted content across pages. The fix applies each section’s own page size, margins, columns, and section start behavior during measurement and pagination.

Also preserves Word-rendered page-break markers through the parser, ProseMirror conversion, and flow layout. Paragraphs that Word places after w:lastRenderedPageBreak or a leading hard page break now start on the expected page instead of being laid out on the previous page or overlapping footers.

Improves auto-fit table rendering by normalizing incomplete or zero-width table grids, preserving cell width metadata, inferring full-row spans for single-cell rows, and accounting for paragraph spacing inside table cells during measurement/rendering.

Fixes #319

Why this is its own PR

These changes all target the same rendering correctness problem: matching Word’s document metrics during pagination. Keeping them together makes the behavior easier to validate against the affected DOCX because section geometry, page breaks, and table metrics all affect final page flow.

Test plan

bun run typecheck clean
bun test clean
bun run build clean

Evidence

image

Use each DOCX section's page geometry during layout and preserve table/cell metrics so paged rendering better matches Word.

Made-with: Cursor
@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 28, 2026

@juanmendez-git is attempting to deploy a commit to the EigenPal Team on Vercel.

A member of the Team first needs to authorize it.

@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 29, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
docx-editor Ready Ready Preview, Comment Apr 29, 2026 8:37am

Request Review

@jedrazb jedrazb self-requested a review April 30, 2026 17:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DOCX layout does not respect section geometry, rendered page breaks, and table metrics

2 participants