⚡️(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 <c.gromoff@gmail.com>
This commit is contained in:
10
CHANGELOG.md
10
CHANGELOG.md
@@ -8,6 +8,12 @@ and this project adheres to
|
|||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- ⚡️(frontend) improve accessibility:
|
||||||
|
- #1248
|
||||||
|
- #1235
|
||||||
|
|
||||||
## [3.5.0] - 2025-07-31
|
## [3.5.0] - 2025-07-31
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
@@ -25,9 +31,7 @@ and this project adheres to
|
|||||||
- ♻️(frontend) redirect to doc after duplicate #1175
|
- ♻️(frontend) redirect to doc after duplicate #1175
|
||||||
- 🔧(project) change env.d system by using local files #1200
|
- 🔧(project) change env.d system by using local files #1200
|
||||||
- ⚡️(frontend) improve tree stability #1207
|
- ⚡️(frontend) improve tree stability #1207
|
||||||
- ⚡️(frontend) improve accessibility
|
- ⚡️(frontend) improve accessibility #1232
|
||||||
- #1232
|
|
||||||
- #1248
|
|
||||||
- 🛂(frontend) block drag n drop when not desktop #1239
|
- 🛂(frontend) block drag n drop when not desktop #1239
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|||||||
@@ -10,7 +10,8 @@ import {
|
|||||||
useToastProvider,
|
useToastProvider,
|
||||||
} from '@openfun/cunningham-react';
|
} from '@openfun/cunningham-react';
|
||||||
import { DocumentProps, pdf } from '@react-pdf/renderer';
|
import { DocumentProps, pdf } from '@react-pdf/renderer';
|
||||||
import { useMemo, useState } from 'react';
|
import i18next from 'i18next';
|
||||||
|
import { cloneElement, isValidElement, useMemo, useState } from 'react';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { css } from 'styled-components';
|
import { css } from 'styled-components';
|
||||||
|
|
||||||
@@ -92,10 +93,15 @@ export const ModalExport = ({ onClose, doc }: ModalExportProps) => {
|
|||||||
const exporter = new PDFExporter(editor.schema, pdfDocsSchemaMappings, {
|
const exporter = new PDFExporter(editor.schema, pdfDocsSchemaMappings, {
|
||||||
resolveFileUrl: async (url) => exportCorsResolveFileUrl(doc.id, url),
|
resolveFileUrl: async (url) => exportCorsResolveFileUrl(doc.id, url),
|
||||||
});
|
});
|
||||||
const pdfDocument = (await exporter.toReactPDFDocument(
|
const rawPdfDocument = (await exporter.toReactPDFDocument(
|
||||||
exportDocument,
|
exportDocument,
|
||||||
)) as React.ReactElement<DocumentProps>;
|
)) as React.ReactElement<DocumentProps>;
|
||||||
|
|
||||||
|
// Inject language for screen reader support
|
||||||
|
const pdfDocument = isValidElement(rawPdfDocument)
|
||||||
|
? cloneElement(rawPdfDocument, { language: i18next.language })
|
||||||
|
: rawPdfDocument;
|
||||||
|
|
||||||
blobExport = await pdf(pdfDocument).toBlob();
|
blobExport = await pdf(pdfDocument).toBlob();
|
||||||
} else {
|
} else {
|
||||||
const exporter = new DOCXExporter(editor.schema, docxDocsSchemaMappings, {
|
const exporter = new DOCXExporter(editor.schema, docxDocsSchemaMappings, {
|
||||||
|
|||||||
Reference in New Issue
Block a user