refactor(painters/dom): unify textbox shape rendering (SD-2838)#3401
Conversation
Extract WordArt and fallback shape-text rendering from renderDrawingContent.ts and svg-utils.ts into a shared textbox/renderTextboxContent module so vector shapes, shape groups, and table-cell shapes go through one code path. Adds tests covering the shared renderer from both the drawing and table-cell entry points.
Relocate isHeaderWordArtWatermark out of renderDrawingFragment.ts into textbox/wordArtWatermark.ts as isWordArtTextboxWatermarkBlock, with direct tests for the predicate. The header-suppression logic in renderer.ts now imports from the new module.
💡 Codex ReviewThis helper now routes every table drawing through ℹ️ About Codex in GitHubCodex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
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". |
Route image drawing blocks through the shared renderer even when a renderDrawingContent callback is supplied, so table-specific image styling and hyperlink anchoring are preserved. The callback now only applies to non-image drawings (vector shapes, shape groups).
Summary
Continues the SD-2838 effort to unify rendering paths in
painters/dom. This branch consolidates the two pre-existing textbox text renderers — the WordArt SVG path and the HTML fallback path — into a single shared module so vector shapes, shape groups, and table-cell shapes all go through one code path.textbox/renderTextboxContent.tscentralizes WordArt (SVG+<text>/<tspan>) and fallback HTML rendering for shape text. Both branches share line-break handling, field resolution (PAGE/NUMPAGES), hex-color validation, and formatting application.drawings/renderDrawingContent.ts) now delegates torenderTextboxContent, dropping ~270 lines of duplicated WordArt/fallback logic.createTextElementinsvg-utils.tsis removed; it was the olderforeignObject-based renderer that diverged from the drawing path.renderDrawingFragment.tsintotextbox/wordArtWatermark.tsasisWordArtTextboxWatermarkBlock, with its own focused tests.renderer.tsimports from the new module for the header-watermark suppression rule.