Skip to content

Commit 24f8da0

Browse files
committed
fixup! ✨(frontend) move html option to downloads section
1 parent 516f446 commit 24f8da0

File tree

2 files changed

+37
-13
lines changed

2 files changed

+37
-13
lines changed

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

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,11 @@ import { TemplatesOrdering, useTemplates } from '../api/useTemplates';
2727
import { docxDocsSchemaMappings } from '../mappingDocx';
2828
import { odtDocsSchemaMappings } from '../mappingODT';
2929
import { pdfDocsSchemaMappings } from '../mappingPDF';
30-
import { deriveMediaFilename, downloadFile, escapeHtml } from '../utils';
30+
import {
31+
deriveMediaFilename,
32+
downloadFile,
33+
generateHtmlDocument,
34+
} from '../utils';
3135

3236
enum DocDownloadFormat {
3337
HTML = 'html',
@@ -189,18 +193,11 @@ export const ModalExport = ({ onClose, doc }: ModalExportProps) => {
189193
const lang = i18next.language || 'fr';
190194
const editorHtmlWithLocalMedia = parsedDocument.body.innerHTML;
191195

192-
const htmlContent = `<!DOCTYPE html>
193-
<html lang="${lang}">
194-
<head>
195-
<meta charset="utf-8" />
196-
<title>${escapeHtml(documentTitle)}</title>
197-
</head>
198-
<body>
199-
<main role="main">
200-
${editorHtmlWithLocalMedia}
201-
</main>
202-
</body>
203-
</html>`;
196+
const htmlContent = generateHtmlDocument(
197+
documentTitle,
198+
editorHtmlWithLocalMedia,
199+
lang,
200+
);
204201

205202
const zip = new JSZip();
206203
zip.file('index.html', htmlContent);

src/frontend/apps/impress/src/features/docs/doc-export/utils.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,3 +261,30 @@ export const deriveMediaFilename = ({
261261

262262
return filename;
263263
};
264+
265+
/**
266+
* Generates a complete HTML document structure for export.
267+
*
268+
* @param documentTitle - The title of the document (will be escaped)
269+
* @param editorHtmlWithLocalMedia - The HTML content from the editor
270+
* @param lang - The language code for the document (e.g., 'fr', 'en')
271+
* @returns A complete HTML5 document string
272+
*/
273+
export const generateHtmlDocument = (
274+
documentTitle: string,
275+
editorHtmlWithLocalMedia: string,
276+
lang: string,
277+
): string => {
278+
return `<!DOCTYPE html>
279+
<html lang="${lang}">
280+
<head>
281+
<meta charset="utf-8" />
282+
<title>${escapeHtml(documentTitle)}</title>
283+
</head>
284+
<body>
285+
<main role="main">
286+
${editorHtmlWithLocalMedia}
287+
</main>
288+
</body>
289+
</html>`;
290+
};

0 commit comments

Comments
 (0)