fix(image): render stretch/fillRect images with object-fit fill, not cover#5
Open
dawidbudaszewski wants to merge 1 commit into
Open
fix(image): render stretch/fillRect images with object-fit fill, not cover#5dawidbudaszewski wants to merge 1 commit into
dawidbudaszewski wants to merge 1 commit into
Conversation
…cover OOXML <a:stretch><a:fillRect/> with an empty srcRect means "stretch the source to fill the extent rectangle" — i.e. CSS object-fit: fill (Word distorts to the box and never crops). SuperDoc mapped it to object-fit: cover, which preserves aspect ratio and crops the overflow. When a drawing's authored w:ext aspect ratio differs from the image's natural aspect (e.g. a header logo), cover scaled the image up and clipped it. Mapping shouldCover to fill matches Word, is a no-op for the common aspect-matched case, and removes the header-logo clipping. Applied to both the paginated layout-adapter (converters/image.ts) and the editable extension (extensions/image/image.js). The shouldCover attribute keeps its name for import/export round-tripping. Co-authored-by: Cursor <cursoragent@cursor.com>
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
OOXML
<a:stretch><a:fillRect/>with an emptysrcRectmeans "stretch the source to fill the extent rectangle" — i.e. CSSobject-fit: fill(Word distorts to the box and never crops). SuperDoc mapped it toobject-fit: cover, which preserves aspect ratio and crops the overflow.When a drawing's authored
w:extaspect ratio differs from the image's natural aspect (e.g. a header logo authored at 3.61 vs a 3.43 image),coverscaled the image up and clipped it. MappingshouldCovertofill:Applied to both the paginated layout-adapter (
converters/image.ts) and the editable extension (extensions/image/image.js). TheshouldCoverattribute keeps its name for import/export round-tripping.Test plan
layout-adapter/converters/image.test.ts+encode-image-node-helpers.test.jsgreen (143 tests)Part of the
@scalefork release (SCALE_BRANCHES).Made with Cursor