Skip to content

refactor(painters/dom): unify textbox shape rendering (SD-2838)#3401

Open
luccas-harbour wants to merge 3 commits into
luccas/sd-2838-unify-footnotes-endnotes-renderingfrom
luccas/sd-2838-unify-textbox-shape-rendering
Open

refactor(painters/dom): unify textbox shape rendering (SD-2838)#3401
luccas-harbour wants to merge 3 commits into
luccas/sd-2838-unify-footnotes-endnotes-renderingfrom
luccas/sd-2838-unify-textbox-shape-rendering

Conversation

@luccas-harbour
Copy link
Copy Markdown
Contributor

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.

  • New module textbox/renderTextboxContent.ts centralizes 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.
  • Drawing content path (drawings/renderDrawingContent.ts) now delegates to renderTextboxContent, dropping ~270 lines of duplicated WordArt/fallback logic.
  • Legacy createTextElement in svg-utils.ts is removed; it was the older foreignObject-based renderer that diverged from the drawing path.
  • WordArt watermark predicate moves out of renderDrawingFragment.ts into textbox/wordArtWatermark.ts as isWordArtTextboxWatermarkBlock, with its own focused tests. renderer.ts imports from the new module for the header-watermark suppression rule.

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.
@luccas-harbour luccas-harbour requested a review from a team as a code owner May 19, 2026 20:21
@linear-code
Copy link
Copy Markdown

linear-code Bot commented May 19, 2026

SD-2838

@luccas-harbour luccas-harbour changed the base branch from main to luccas/sd-2838-unify-footnotes-endnotes-rendering May 19, 2026 20:21
@chatgpt-codex-connector
Copy link
Copy Markdown

💡 Codex Review

const drawingContent =
renderDrawingContent?.(block, { clipContainer: drawingInner }) ?? createDrawingPlaceholder(doc);

P2 Badge Keep image drawings on built-in table rendering path

This helper now routes every table drawing through renderDrawingContent, including drawingKind: 'image'. In the previous behavior, image drawings were rendered by the built-in image path (object-fit, clip-path, hyperlink handling) and the callback was only for non-image drawing kinds; callers that provide a callback for vector/group shapes can now unintentionally replace image drawings with custom placeholders or lose image-specific styling. Guard image drawings before invoking the callback so custom renderers don't break table images.

ℹ️ 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".

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).
@luccas-harbour
Copy link
Copy Markdown
Contributor Author

💡 Codex Review

const drawingContent =
renderDrawingContent?.(block, { clipContainer: drawingInner }) ?? createDrawingPlaceholder(doc);

P2 Badge Keep image drawings on built-in table rendering path
This helper now routes every table drawing through renderDrawingContent, including drawingKind: 'image'. In the previous behavior, image drawings were rendered by the built-in image path (object-fit, clip-path, hyperlink handling) and the callback was only for non-image drawing kinds; callers that provide a callback for vector/group shapes can now unintentionally replace image drawings with custom placeholders or lose image-specific styling. Guard image drawings before invoking the callback so custom renderers don't break table images.

ℹ️ About Codex in GitHub

Fixed.

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.

1 participant