@@ -22,7 +22,10 @@ import { Box, ButtonCloseModal, Text } from '@/components';
2222import { useEditorStore } from '@/docs/doc-editor' ;
2323import { Doc , useTrans } from '@/docs/doc-management' ;
2424
25- import { exportCorsResolveFileUrl } from '../api/exportResolveFileUrl' ;
25+ import {
26+ exportCorsResolveFileUrl ,
27+ exportResolveFileUrl ,
28+ } from '../api/exportResolveFileUrl' ;
2629import { TemplatesOrdering , useTemplates } from '../api/useTemplates' ;
2730import { docxDocsSchemaMappings } from '../mappingDocx' ;
2831import { odtDocsSchemaMappings } from '../mappingODT' ;
@@ -174,14 +177,32 @@ export const ModalExport = ({ onClose, doc }: ModalExportProps) => {
174177 return ;
175178 }
176179
177- const fetched = await exportCorsResolveFileUrl ( doc . id , src ) ;
180+ // data: URLs are already embedded and work offline; no need to create separate files.
181+ if ( src . startsWith ( 'data:' ) ) {
182+ return ;
183+ }
184+
185+ // Only download same-origin resources (internal media like /media/...).
186+ // External URLs keep their original src and are not included in the ZIP
187+ let url : URL | null = null ;
188+ try {
189+ url = new URL ( src , window . location . origin ) ;
190+ } catch {
191+ url = null ;
192+ }
193+
194+ if ( ! url || url . origin !== window . location . origin ) {
195+ return ;
196+ }
197+
198+ const fetched = await exportResolveFileUrl ( url . href ) ;
178199
179200 if ( ! ( fetched instanceof Blob ) ) {
180201 return ;
181202 }
182203
183204 const filename = deriveMediaFilename ( {
184- src,
205+ src : url . href ,
185206 index,
186207 blob : fetched ,
187208 } ) ;
0 commit comments