fix(layout-engine): honor tblpPr anchor frames for floating tables (SD-2562)#2877
Open
caio-pizzol wants to merge 1 commit intomainfrom
Open
fix(layout-engine): honor tblpPr anchor frames for floating tables (SD-2562)#2877caio-pizzol wants to merge 1 commit intomainfrom
caio-pizzol wants to merge 1 commit intomainfrom
Conversation
…D-2562) Resolve floating-table placement through vRelativeFrom/hRelativeFrom/alignH/alignV instead of treating every anchor as paragraph-relative. Extract position math into computeTableAnchorX and a new computeTableAnchorY in floating-objects.ts and call them from both the paragraph-anchored and paragraphless code paths. Also: - Drop the single-column special case in computeTableAnchorX so page-anchored tblpX measures from page edge 0 regardless of column count (fixes GH#2800 reporter XML). - Stop double-counting offsetV in registerTable — computeTableAnchorY already applies it. - Clarify JSDoc: alignV picks the reference edge/center, offsetV is additive from there (matches Word's actual behavior). Validated against Microsoft Word's COM-reported positions for 13 tblpPr fixtures covering all horzAnchor x vertAnchor x tblpX/tblpXSpec x tblpY/tblpYSpec combinations. All 626 unit tests pass (+11 new).
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 56afb81669
ℹ️ 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".
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Floating tables with `w:tblpPr` now honor `horzAnchor`/`vertAnchor` when SuperDoc resolves their position. Previously every anchor was treated as paragraph-relative, so `vertAnchor="page"` tables rendered near the anchor paragraph instead of at the page-relative position Word shows.
Validated against Microsoft Word's COM-reported positions for 13 `tblpPr` fixtures covering every `horzAnchor × vertAnchor × tblpX/tblpXSpec × tblpY/tblpYSpec` combination. The SD-2562 core case (`vertAnchor="page" tblpY=2880`) now renders at `(288, 192)`, matching Word exactly; previously rendered at `(288, 380)`.
Rejected: symptom-fix that special-cased `vertAnchor="page"` only (would leave horizontal axis, `margin` anchors, and tblpXSpec still broken — they share the same 30-line code block).
Must stay the same: paragraph-anchored legacy clamp (`Math.max(paragraphStartY, cursorY)`) preserved to avoid overlapping already-laid paragraph content on multi-page spans. Strict OOXML paragraph behavior (allow overlap) is follow-up work.
Review: correctness of the new `computeTableAnchorY` helper and whether the fragment rendering X math changed under any existing integration-test fixture.
Verified: `pnpm --filter @superdoc/layout-engine test` → 626 pass (+11 new). Dev-app verification on 13 fixtures matches Word ground truth.