refactor: centralize anchored graphic placement#3757
Conversation
VladaHarbour
commented
Jun 18, 2026
- Added a shared resolveGraphicPlacement() in layout-engine to centralize anchored graphic placement for images, drawings, and tables.
- The resolver now produces one placement result for paint coordinates, text-wrap exclusion coordinates, layer data (behindDoc, zIndex), and measurement impact flags.
- Refactored paragraph anchoring, pre-registered/page-relative anchors, paragraphless anchored fallback, and float registration to consume the same resolved placement instead of recomputing X/Y separately.
- Removed duplicated table anchor X logic from the floating object manager.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 91054858eb
ℹ️ 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".
| typeof anchoredBlock.zIndex === 'number' | ||
| ? anchoredBlock.zIndex | ||
| : (normalizeZIndex(anchoredBlock.attrs?.originalAttributes) ?? (behindDoc ? -1 : 1)); | ||
| const zIndex = getFragmentZIndex(anchoredBlock); |
There was a problem hiding this comment.
Preserve wrap-only behindDoc z-index in cells
When a table-cell anchored block uses the legacy/wrap-only behind-doc form (wrap.type === 'None' with wrap.behindDoc, but no anchor.behindDoc or zIndex), the behindDoc variable above is true and wrap exclusions are skipped, but getFragmentZIndex() only consults anchor.behindDoc/block.zIndex, so the wrapper falls back to z-index 1 and is appended after the text instead of behind it. Please feed the computed behindDoc state into the z-index fallback (or preserve the old behind-doc fallback) so these supported blocks still render behind cell content.
Useful? React with 👍 / 👎.