File tree Expand file tree Collapse file tree 2 files changed +37
-13
lines changed
src/frontend/apps/impress/src/features/docs/doc-export Expand file tree Collapse file tree 2 files changed +37
-13
lines changed Original file line number Diff line number Diff line change @@ -27,7 +27,11 @@ import { TemplatesOrdering, useTemplates } from '../api/useTemplates';
2727import { docxDocsSchemaMappings } from '../mappingDocx' ;
2828import { odtDocsSchemaMappings } from '../mappingODT' ;
2929import { pdfDocsSchemaMappings } from '../mappingPDF' ;
30- import { deriveMediaFilename , downloadFile , escapeHtml } from '../utils' ;
30+ import {
31+ deriveMediaFilename ,
32+ downloadFile ,
33+ generateHtmlDocument ,
34+ } from '../utils' ;
3135
3236enum 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 ) ;
Original file line number Diff line number Diff 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+ } ;
You can’t perform that action at this time.
0 commit comments