Skip to content

fix(image): render stretch/fillRect images with object-fit fill, not cover#5

Open
dawidbudaszewski wants to merge 1 commit into
mainfrom
fix/header-image-stretch-fill
Open

fix(image): render stretch/fillRect images with object-fit fill, not cover#5
dawidbudaszewski wants to merge 1 commit into
mainfrom
fix/header-image-stretch-fill

Conversation

@dawidbudaszewski

Copy link
Copy Markdown
Owner

Summary

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 authored at 3.61 vs a 3.43 image), cover scaled the image up and clipped it. Mapping shouldCover to fill:

  • matches Word,
  • is a no-op for the common aspect-matched case,
  • removes the header-logo clipping (reproduced on a Qatar MoFA template whose logo was cut off, while a second template with a matching-aspect logo was unaffected).

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.

Test plan

  • layout-adapter/converters/image.test.ts + encode-image-node-helpers.test.js green (143 tests)
  • Verify the clipped header logo (template A) renders fully in the paginated view
  • Verify aspect-matched logos (template B) are visually unchanged

Part of the @scale fork release (SCALE_BRANCHES).

Made with Cursor

…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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant