Skip to content

Commit 9bf2cf8

Browse files
committed
✨(docx) fix image overflow by limiting width to 600px during export
ensures all images keep proportions and stay within page bounds in docx export Signed-off-by: Cyril <c.gromoff@gmail.com>
1 parent 2f010cf commit 9bf2cf8

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ and this project adheres to
2121
- 🐛(frontend) fix duplicate document entries in grid #1479
2222
- 🐛(frontend) show full nested doc names with ajustable bar #1456
2323
- 🐛(backend) fix trashbin list
24+
- 🐛(docx) fix image overflow by limiting width to 600px during export #1525
2425
- ♿(frontend) improve accessibility:
2526
- ♿(frontend) remove empty alt on logo due to Axe a11y error #1516
2627

src/frontend/apps/impress/src/features/docs/doc-export/blocks-mapping/imageDocx.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@ export const blockMappingImageDocx: DocsExporterDocx['mappings']['blockMapping']
5050

5151
const { width, height } = dimensions;
5252

53-
if (previewWidth && previewWidth > MAX_WIDTH) {
54-
previewWidth = MAX_WIDTH;
55-
}
53+
// Ensure the final width never exceeds MAX_WIDTH to prevent images
54+
// from overflowing the page width in the exported document
55+
const finalWidth = Math.min(previewWidth || width, MAX_WIDTH);
5656

5757
return [
5858
new Paragraph({
@@ -71,8 +71,8 @@ export const blockMappingImageDocx: DocsExporterDocx['mappings']['blockMapping']
7171
}
7272
: undefined,
7373
transformation: {
74-
width: previewWidth || width,
75-
height: ((previewWidth || width) / width) * height,
74+
width: finalWidth,
75+
height: (finalWidth / width) * height,
7676
},
7777
}),
7878
],

0 commit comments

Comments
 (0)