From f4b34f71c55c8006a48c2aa62a097f05627caad0 Mon Sep 17 00:00:00 2001 From: Roland Tannous Date: Thu, 28 May 2026 14:59:52 +0400 Subject: [PATCH] Studio: render embedded images in DOCX preview docx-preview defaults to blob: URLs for embedded images, which DOMPurify strips from img src (blob: isn't in its default allowed-URI list), so figures vanished after sanitize. Switch docx-preview to useBase64URL so images inline as data: URIs, and add ADD_DATA_URI_TAGS: ['img'] to the DOMPurify config so those data: URIs survive sanitization. Script / handler / javascript: stripping is unchanged. --- .../src/features/rag/components/preview-docx-view.tsx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/studio/frontend/src/features/rag/components/preview-docx-view.tsx b/studio/frontend/src/features/rag/components/preview-docx-view.tsx index e039c90cf5..ab3abbc930 100644 --- a/studio/frontend/src/features/rag/components/preview-docx-view.tsx +++ b/studio/frontend/src/features/rag/components/preview-docx-view.tsx @@ -26,14 +26,20 @@ export const PreviewDocxView: FC<{ target: PreviewTarget; blob: Blob }> = ({ void renderAsync(blob, offscreen, undefined, { inWrapper: true, ignoreLastRenderedPageBreak: true, + // Inline images as base64 data: URIs rather than blob: URLs. + // DOMPurify drops blob: from img src, so blob-backed images would + // vanish after sanitize; data: URIs survive (see ADD_DATA_URI_TAGS). + useBase64URL: true, }) .then(() => { if (cancelled || !ref.current) return; // Keep