Skip to content

Commit 2bf5330

Browse files
OvgoddAntoLC
authored andcommitted
⚡️(frontend) inject language attribute to pdf export
added language="fr-FR" to <Document /> in ModalExport.tsx via cloneElement() to improve accessibility and ensure correct screen reader pronunciation Signed-off-by: Cyril <[email protected]>
1 parent ec84f31 commit 2bf5330

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

CHANGELOG.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@ and this project adheres to
88

99
## [Unreleased]
1010

11+
### Changed
12+
13+
- ⚡️(frontend) improve accessibility:
14+
- #1248
15+
- #1235
16+
1117
## [3.5.0] - 2025-07-31
1218

1319
### Added
@@ -25,9 +31,7 @@ and this project adheres to
2531
- ♻️(frontend) redirect to doc after duplicate #1175
2632
- 🔧(project) change env.d system by using local files #1200
2733
- ⚡️(frontend) improve tree stability #1207
28-
- ⚡️(frontend) improve accessibility
29-
- #1232
30-
- #1248
34+
- ⚡️(frontend) improve accessibility #1232
3135
- 🛂(frontend) block drag n drop when not desktop #1239
3236

3337
### Fixed

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

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ import {
1010
useToastProvider,
1111
} from '@openfun/cunningham-react';
1212
import { DocumentProps, pdf } from '@react-pdf/renderer';
13-
import { useMemo, useState } from 'react';
13+
import i18next from 'i18next';
14+
import { cloneElement, isValidElement, useMemo, useState } from 'react';
1415
import { useTranslation } from 'react-i18next';
1516
import { css } from 'styled-components';
1617

@@ -92,10 +93,15 @@ export const ModalExport = ({ onClose, doc }: ModalExportProps) => {
9293
const exporter = new PDFExporter(editor.schema, pdfDocsSchemaMappings, {
9394
resolveFileUrl: async (url) => exportCorsResolveFileUrl(doc.id, url),
9495
});
95-
const pdfDocument = (await exporter.toReactPDFDocument(
96+
const rawPdfDocument = (await exporter.toReactPDFDocument(
9697
exportDocument,
9798
)) as React.ReactElement<DocumentProps>;
9899

100+
// Inject language for screen reader support
101+
const pdfDocument = isValidElement(rawPdfDocument)
102+
? cloneElement(rawPdfDocument, { language: i18next.language })
103+
: rawPdfDocument;
104+
99105
blobExport = await pdf(pdfDocument).toBlob();
100106
} else {
101107
const exporter = new DOCXExporter(editor.schema, docxDocsSchemaMappings, {

0 commit comments

Comments
 (0)