Skip to content

feat: support wide tables rendering outside of margins#2823

Merged
harbournick merged 5 commits into
mainfrom
sd-2544-2545_wide-table-prep
Apr 30, 2026
Merged

feat: support wide tables rendering outside of margins#2823
harbournick merged 5 commits into
mainfrom
sd-2544-2545_wide-table-prep

Conversation

@VladaHarbour
Copy link
Copy Markdown
Contributor

@VladaHarbour VladaHarbour commented Apr 15, 2026

Summary

Adds support for rendering tables wider than the content column (SD-2544 / SD-2545). Tables with explicit OOXML widths now overflow into page margins instead of being clamped to column width.

Key changes

  • Width resolution centralized: New resolveTableWidthAttr (contracts) validates table width attrs (rejects NaN/Infinity/non-positive). Used by both measuring and layout sides.
  • Wide-table layout: New resolveTableFrame / resolveRenderedTableWidth (layout-engine) resolve final rendered width and x-offset. Allows negative x for centered/right-aligned wide tables; preserves indent for left-aligned, ignores it for justified.
  • Measuring: Explicit OOXML widths (px/pct/dxa) now pass through unclamped — only auto-sized tables fall back to column width.
  • Fragments: Table fragments record an optional columnIndex (logical column owner). Used by position-hit and footnote placement so click-resolution and footnote anchoring use logical ownership instead of visual x for wide overflow tables.
  • Tests: ~600 new test cases — width-attr validation, wide-table overflow, alignment, indent edge cases, click-to-position with columnIndex, footnote placement on overflow tables, multi-column scenarios.

Test plan

  • Unit tests pass (layout-engine, contracts, layout-bridge)
  • Layout comparison vs published baseline (pnpm test:layout)
  • Visual diff on wide-table corpus docs (pnpm test:visual)

@linear
Copy link
Copy Markdown

linear Bot commented Apr 15, 2026

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: eb148ad488

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines 199 to +203
if (justification === 'center') {
return { x: baseX + Math.max(0, (columnWidth - width) / 2), width };
return { x: baseX + (columnWidth - width) / 2, width };
}
if (justification === 'right' || justification === 'end') {
return { x: baseX + Math.max(0, columnWidth - width), width };
return { x: baseX + (columnWidth - width), width };
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve column ownership when aligning overwide tables

Removing the Math.max(0, …) clamp for centered/right tables lets fragment.x move left of the table’s actual flow column when width > columnWidth (e.g., a table laid out in column 2 can start inside column 1). Several layout-bridge paths infer column index from fragment.x (notably assignFootnotesToColumns in layout-bridge/src/incrementalLayout.ts and determineColumn in layout-bridge/src/position-hit.ts), so this change can misclassify the table as belonging to the wrong column in multi-column documents, which breaks footnote placement and column-aware hit testing for those tables.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

@VladaHarbour VladaHarbour Apr 16, 2026

Choose a reason for hiding this comment

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

Here for any table with width > columnWidth:

  1. centered tables would no longer shift left into the margin
  2. right/end-aligned tables would no longer overflow leftward from the content area

Adding fix to support multi-column layout together with wide tables overflow.

@codecov-commenter
Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Comment thread packages/layout-engine/layout-engine/src/layout-table.ts Outdated
Comment thread packages/layout-engine/layout-engine/src/layout-table.test.ts
Comment thread packages/layout-engine/layout-engine/src/layout-table.test.ts
Copy link
Copy Markdown
Contributor

@tupizz tupizz left a comment

Choose a reason for hiding this comment

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

no blocker, just suggestions
lgtm!

@VladaHarbour VladaHarbour force-pushed the sd-2544-2545_wide-table-prep branch from 8f16bcf to b7ccd7d Compare April 27, 2026 14:06
- direct unit tests for resolveTableWidthAttr (contracts) - the new public
  helper had no test of its own; covers width/value field, type passthrough,
  zero/negative/non-finite/null rejection.
- direct unit tests for resolveTableFrame and resolveRenderedTableWidth
  (layout-engine) - these are now exported and used by incrementalLayout, so
  worth testing in isolation: pct calculation, px/dxa fallback to measured,
  negative x for centered/right wide tables, indent + wide.
- pin the quiet behavior change for tableLayout: 'fixed' without an explicit
  tableWidth (measuring/dom) - grid widths wider than the column now pass
  through; previously they were scaled to fit.
- two click-to-position cases: legacy fragments without columnIndex fall back
  to visual x via determineColumn, and a fragment claiming a columnIndex past
  the document column count is clamped to the last valid column.
Copy link
Copy Markdown
Contributor

@caio-pizzol caio-pizzol left a comment

Choose a reason for hiding this comment

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

hey @VladaHarbour, the column ownership fix looks great.

tried a 10" wide table on a 6.5" page - the last column still gets cut off at the page edge. is the rendering fix coming separately, or should it land here?

pushed a commit with tests for the new helpers and pinned a quiet behavior change. three smaller things still inline.

needs work.

Comment thread packages/layout-engine/measuring/dom/src/index.ts
Comment thread packages/layout-engine/layout-engine/src/layout-table.ts
Comment thread packages/layout-engine/layout-bridge/src/incrementalLayout.ts Outdated
@VladaHarbour VladaHarbour requested a review from a team as a code owner April 30, 2026 13:59
Copy link
Copy Markdown
Contributor

@luccas-harbour luccas-harbour left a comment

Choose a reason for hiding this comment

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

LGTM

@harbournick harbournick merged commit 38a1785 into main Apr 30, 2026
58 checks passed
@harbournick harbournick deleted the sd-2544-2545_wide-table-prep branch April 30, 2026 17:04
@superdoc-bot
Copy link
Copy Markdown
Contributor

superdoc-bot Bot commented Apr 30, 2026

🎉 This PR is included in @superdoc-dev/react v1.2.0-next.60

The release is available on GitHub release

@superdoc-bot
Copy link
Copy Markdown
Contributor

superdoc-bot Bot commented Apr 30, 2026

🎉 This PR is included in @superdoc-dev/mcp v0.3.0-next.17

The release is available on GitHub release

@superdoc-bot
Copy link
Copy Markdown
Contributor

superdoc-bot Bot commented Apr 30, 2026

🎉 This PR is included in vscode-ext v2.3.0-next.62

@superdoc-bot
Copy link
Copy Markdown
Contributor

superdoc-bot Bot commented Apr 30, 2026

🎉 This PR is included in superdoc v1.30.0-next.19

The release is available on GitHub release

@superdoc-bot
Copy link
Copy Markdown
Contributor

superdoc-bot Bot commented Apr 30, 2026

🎉 This PR is included in superdoc-cli v0.8.0-next.35

The release is available on GitHub release

@superdoc-bot
Copy link
Copy Markdown
Contributor

superdoc-bot Bot commented Apr 30, 2026

🎉 This PR is included in superdoc-sdk v1.8.0-next.21

@superdoc-bot
Copy link
Copy Markdown
Contributor

superdoc-bot Bot commented May 1, 2026

🎉 This PR is included in superdoc-cli v0.8.0

The release is available on GitHub release

@superdoc-bot
Copy link
Copy Markdown
Contributor

superdoc-bot Bot commented May 1, 2026

🎉 This PR is included in superdoc-sdk v1.8.0

@superdoc-bot
Copy link
Copy Markdown
Contributor

superdoc-bot Bot commented May 1, 2026

🎉 This PR is included in @superdoc-dev/mcp v0.3.0

The release is available on GitHub release

@superdoc-bot
Copy link
Copy Markdown
Contributor

superdoc-bot Bot commented May 1, 2026

🎉 This PR is included in superdoc v1.31.0

The release is available on GitHub release

@superdoc-bot
Copy link
Copy Markdown
Contributor

superdoc-bot Bot commented May 5, 2026

🎉 This PR is included in vscode-ext v2.3.0

@superdoc-bot
Copy link
Copy Markdown
Contributor

superdoc-bot Bot commented May 7, 2026

🎉 This PR is included in @superdoc-dev/react v1.3.0

The release is available on GitHub release

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants