refactor(painters/dom): unify drawing block rendering (SD-2838)#3334
Open
luccas-harbour wants to merge 7 commits into
Open
Conversation
… and table cells Move renderDrawingContent (vectorShape, chart, shapeGroup, shapeText paths) out of renderer.ts into drawings/renderDrawingContent.ts so the main renderer and table cells share a single rendering implementation. Extract the table-cell drawing wrapper into drawings/tableDrawingFrame.ts to deduplicate the in-flow and anchored drawing scaffolding, and thread the renderDrawingContent callback through renderTableCell so non-image drawings render via the shared path. Add unit coverage for the new renderDrawingContent module and the table cell frame builder.
Move renderDrawingFragment and isHeaderWordArtWatermark from DomPainter into a standalone drawings/renderDrawingFragment.ts module, drop the redundant renderDrawingContent wrapper method, and pass the painter's frame/anchor helpers in via parameters.
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.
Summary
Builds on the image-block unification (parent branch
luccas/sd-2838-unify-image-block-rendering) by collapsing the remaining drawing-rendering duplication betweenDomPainterandrenderTableCellonto a single implementation. Non-image drawings (vector shapes, shape groups, charts, shape text) now render through the same code path in body content and table cells, and the table-cell drawing wrapper is no longer reinvented for in-flow vs. anchored cases.What changed
New modules in
painters/dom/src/drawings/:renderDrawingContent.ts— extracts ~890 lines of vector-shape / chart / shape-group / shape-text rendering (preset + custom geometry, gradient/alpha fills, line ends, fallback styles, shape text layout) out ofDomPainterinto a pure function. Acceptsdoc,block, optionalgeometry, optionalclipContainer, and abuildImageHyperlinkAnchorcallback — no painter coupling.renderDrawingFragment.ts— movesrenderDrawingFragmentandisHeaderWordArtWatermarkout ofDomPainter; the painter now passes its frame/anchor helpers (applyResolvedFragmentFrame,applyFragmentFrame,applyFragmentWrapperZIndex,createErrorPlaceholder) in as parameters.tableDrawingFrame.ts— single helper that builds the table-cell drawing wrapper for bothposition: relative(in-flow) andposition: absolute(anchored) drawings, deduplicating the wrapper/inner/SDT-dataset scaffolding that previously existed twice inrenderTableCell.placeholder.ts— small shared factory for the diagonal-stripe drawing placeholder.renderer.tsshrinks by ~1000 lines. Drawing-related private methods (renderDrawingFragment,renderDrawingContent,createVectorShapeElement,createShapeGroupElement,createChartElement,createDrawingPlaceholder,isHeaderWordArtWatermark, plus their effect-extent / SVG / transform helpers) all delegate to the new modules. SVG/WordArt constants and local types (LineEnd,EffectExtent,VectorShapeDrawingWithEffects) move with them.renderTableCell.tsis slimmed by ~95 lines:renderTableDrawingFrameinstead of building the wrapper inline.renderDrawingContentcallback signature gains an optional{ clipContainer }so image clipping can flow through the shared path.renderDrawingContentdirectly withbuildSharedImageHyperlinkAnchor— non-image drawings in tables no longer disappear.images/drawing-image.ts—createDrawingImageElementaccepts an optionalclipContainerforwarded tocreateBlockImageContent, so the shared renderer can pipe the table cell's inner wrapper through for image clipping.Tests
renderDrawingContent.test.tscovers vector shapes, shape groups, charts, fallback placeholders, and image hyperlink/clip-container behavior through the shared path.renderTableCell.test.tsgains ~260 lines of new coverage: image drawings rendering through the shared renderer, placeholder for image without source, callback override behavior, fallback to the shared renderer when no callback is supplied, clip-container threading, and SDT metadata sourced fromattrs.sdt.