From 9bf2cf8b359890626500edfa76066078ace174a3 Mon Sep 17 00:00:00 2001 From: Cyril Date: Tue, 28 Oct 2025 12:59:55 +0100 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8(docx)=20fix=20image=20overflow=20by?= =?UTF-8?q?=20limiting=20width=20to=20600px=20during=20export?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ensures all images keep proportions and stay within page bounds in docx export Signed-off-by: Cyril --- CHANGELOG.md | 1 + .../docs/doc-export/blocks-mapping/imageDocx.tsx | 10 +++++----- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a08acaa2d7..09009c7207 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,7 @@ and this project adheres to - 🐛(frontend) fix duplicate document entries in grid #1479 - 🐛(frontend) show full nested doc names with ajustable bar #1456 - 🐛(backend) fix trashbin list +- 🐛(docx) fix image overflow by limiting width to 600px during export #1525 - ♿(frontend) improve accessibility: - ♿(frontend) remove empty alt on logo due to Axe a11y error #1516 diff --git a/src/frontend/apps/impress/src/features/docs/doc-export/blocks-mapping/imageDocx.tsx b/src/frontend/apps/impress/src/features/docs/doc-export/blocks-mapping/imageDocx.tsx index c53a5e1da6..868ba0cf5d 100644 --- a/src/frontend/apps/impress/src/features/docs/doc-export/blocks-mapping/imageDocx.tsx +++ b/src/frontend/apps/impress/src/features/docs/doc-export/blocks-mapping/imageDocx.tsx @@ -50,9 +50,9 @@ export const blockMappingImageDocx: DocsExporterDocx['mappings']['blockMapping'] const { width, height } = dimensions; - if (previewWidth && previewWidth > MAX_WIDTH) { - previewWidth = MAX_WIDTH; - } + // Ensure the final width never exceeds MAX_WIDTH to prevent images + // from overflowing the page width in the exported document + const finalWidth = Math.min(previewWidth || width, MAX_WIDTH); return [ new Paragraph({ @@ -71,8 +71,8 @@ export const blockMappingImageDocx: DocsExporterDocx['mappings']['blockMapping'] } : undefined, transformation: { - width: previewWidth || width, - height: ((previewWidth || width) / width) * height, + width: finalWidth, + height: (finalWidth / width) * height, }, }), ],