Skip to content

Commit ac01a58

Browse files
committed
fixup! ✨(frontend) added accessible html export and moved download option
1 parent 30fce76 commit ac01a58

File tree

1 file changed

+24
-3
lines changed
  • src/frontend/apps/impress/src/features/docs/doc-export/components

1 file changed

+24
-3
lines changed

src/frontend/apps/impress/src/features/docs/doc-export/components/ModalExport.tsx

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,10 @@ import { Box, ButtonCloseModal, Text } from '@/components';
2222
import { useEditorStore } from '@/docs/doc-editor';
2323
import { Doc, useTrans } from '@/docs/doc-management';
2424

25-
import { exportCorsResolveFileUrl } from '../api/exportResolveFileUrl';
25+
import {
26+
exportCorsResolveFileUrl,
27+
exportResolveFileUrl,
28+
} from '../api/exportResolveFileUrl';
2629
import { TemplatesOrdering, useTemplates } from '../api/useTemplates';
2730
import { docxDocsSchemaMappings } from '../mappingDocx';
2831
import { 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

Comments
 (0)