Skip to content

fix(core): preserve fixed table width during resize#426

Draft
leandrotcawork wants to merge 1 commit into
eigenpal:mainfrom
leandrotcawork:codex/pr-b-fixed-table-resize-clean
Draft

fix(core): preserve fixed table width during resize#426
leandrotcawork wants to merge 1 commit into
eigenpal:mainfrom
leandrotcawork:codex/pr-b-fixed-table-resize-clean

Conversation

@leandrotcawork

Copy link
Copy Markdown
Contributor

Summary

Preserve the total width of fixed-width (dxa) tables when resizing columns in the ProseMirror editor.

This PR keeps imported fixed-width Word tables stable during interactive column resize by materializing deterministic colwidth metadata, tracking fixed-width table intent through toProseDoc, and normalizing edited widths back to the original table total.

Problem

Imported fixed-width tables could drift after column resize in the editor:

  • dragging one column divider changed the resized cell width
  • but the table total was no longer preserved
  • the remaining columns were not rebalanced back to the original fixed table width
  • exported DOCX could therefore diverge from the original fixed-width layout authored in Word

This was especially visible on imported tables whose width was defined in dxa and should behave as a fixed total-width grid.

Root Cause

The editor had enough information to resize columns visually, but not enough persisted structure to normalize the table back to a fixed total width after the transaction:

  • imported fixed-width cells were not consistently carrying ProseMirror colwidth metadata
  • the resize path did not distinguish fixed-width (dxa) tables from percentage/auto tables
  • after a resize, the transaction preserved the edited pixel widths but did not redistribute them back into a stable fixed-width table model for serialization/export

What Changed

  • materialize colwidth metadata for imported fixed-width table cells in toProseDoc
  • thread table width intent (dxa vs non-fixed modes) through table conversion
  • persist data-colwidth on table cell DOM parse/render so PM resize state round-trips correctly
  • add focused fixed-resize utilities to:
    • read first-row column widths
    • compute the target fixed table total
    • normalize edited widths while preserving the total
    • distribute twips proportionally for table grid serialization
  • add a fixedResizeNormalizerPlugin that post-processes resized fixed-width tables and rewrites cell/table widths back into a stable fixed-width state
  • suppress active-cell decoration while a column resize handle is active, avoiding conflicting resize/editor visuals

Scope

This PR is intentionally limited to fixed-width table resize behavior.

It does not change header/footer layout logic from #425, although both PRs touch some shared ProseMirror table conversion files.

Validation

Ran:

bun test packages/core/src/prosemirror/extensions/nodes/tableFixedResizeUtils.test.ts packages/core/src/prosemirror/conversion/toProseDoc.test.ts
bun x tsc --noEmit -p packages/core/tsconfig.json
git diff --check origin/main...

Result:

  • tests passing
  • core typecheck passing
  • no diff whitespace issues

Notes For Maintainer

I kept this as a separate review slice from the header/footer work in #425 so the resize behavior can be reviewed on its own.

Functionally this patch applies cleanly on top of main; the connection to #425 is organizational rather than runtime-coupled.

@vercel

vercel Bot commented May 8, 2026

Copy link
Copy Markdown

Someone is attempting to deploy a commit to the EigenPal Team on Vercel.

A member of the Team first needs to authorize it.

@leandrotcawork leandrotcawork force-pushed the codex/pr-b-fixed-table-resize-clean branch from 2506775 to 802ebb4 Compare May 8, 2026 15:38
@jedrazb jedrazb self-requested a review May 8, 2026 19:17
@jedrazb

jedrazb commented May 28, 2026

Copy link
Copy Markdown
Contributor

Hey @leandrotcawork ! are you planning to pick up the work?

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.

2 participants