Compare commits

..

2 commits

Author SHA1 Message Date
C. Fuhrman
8e8bff3894 Supporter images et le titre du quiz en haut, taille du papier USLetter 2025-04-10 21:30:15 -04:00
C. Fuhrman
4895b2b8a7 Corriger pb de vulnérabilités (jsPDF >= 3.0.0) 2025-04-10 21:29:04 -04:00
3 changed files with 214 additions and 160 deletions

353
client/package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -18,18 +18,18 @@
"@fortawesome/fontawesome-svg-core": "^6.7.2", "@fortawesome/fontawesome-svg-core": "^6.7.2",
"@fortawesome/free-solid-svg-icons": "^6.7.2", "@fortawesome/free-solid-svg-icons": "^6.7.2",
"@fortawesome/react-fontawesome": "^0.2.0", "@fortawesome/react-fontawesome": "^0.2.0",
"@mui/icons-material": "^7.0.1", "@mui/icons-material": "^7.0.2",
"@mui/lab": "^5.0.0-alpha.153", "@mui/lab": "^5.0.0-alpha.153",
"@mui/material": "^7.0.1", "@mui/material": "^7.0.2",
"@types/uuid": "^9.0.7", "@types/uuid": "^9.0.7",
"axios": "^1.8.1", "axios": "^1.8.1",
"dompurify": "^3.2.5", "dompurify": "^3.2.5",
"esbuild": "^0.25.2", "esbuild": "^0.25.2",
"gift-pegjs": "^2.0.0-beta.1", "gift-pegjs": "^2.0.0-beta.1",
"jest-environment-jsdom": "^29.7.0", "jest-environment-jsdom": "^29.7.0",
"jspdf": "^2.5.2", "jspdf": "^3.0.1",
"jwt-decode": "^4.0.0", "jwt-decode": "^4.0.0",
"katex": "^0.16.11", "katex": "^0.16.22",
"marked": "^15.0.8", "marked": "^15.0.8",
"nanoid": "^5.1.5", "nanoid": "^5.1.5",
"qrcode.react": "^4.2.0", "qrcode.react": "^4.2.0",
@ -74,7 +74,7 @@
"ts-jest": "^29.3.1", "ts-jest": "^29.3.1",
"typescript": "^5.8.3", "typescript": "^5.8.3",
"typescript-eslint": "^8.29.1", "typescript-eslint": "^8.29.1",
"vite": "^6.2.0", "vite": "^6.2.6",
"vite-plugin-environment": "^1.1.3" "vite-plugin-environment": "^1.1.3"
} }
} }

View file

@ -65,7 +65,7 @@ const DownloadQuizModal: React.FC<DownloadQuizModalProps> = ({ quiz }) => {
if (!selectedQuiz) throw new Error('Quiz not found'); if (!selectedQuiz) throw new Error('Quiz not found');
let previewHTML = ''; let previewHTML = '<h2>' + selectedQuiz.title + '</h2>';
selectedQuiz.content.forEach((giftQuestion) => { selectedQuiz.content.forEach((giftQuestion) => {
try { try {
const question = parse(giftQuestion); const question = parse(giftQuestion);
@ -76,9 +76,9 @@ const DownloadQuizModal: React.FC<DownloadQuizModalProps> = ({ quiz }) => {
}); });
} catch (error) { } catch (error) {
if (error instanceof Error) { if (error instanceof Error) {
previewHTML += ErrorTemplate(giftQuestion + '\n' + error.message); previewHTML += ErrorTemplate(giftQuestion, error.message );
} else { } else {
previewHTML += ErrorTemplate(giftQuestion + '\n' + 'Erreur inconnue'); previewHTML += ErrorTemplate(giftQuestion, 'Erreur inconnue');
} }
} }
}); });
@ -107,11 +107,12 @@ const DownloadQuizModal: React.FC<DownloadQuizModalProps> = ({ quiz }) => {
tempDiv.innerHTML = sanitizedHTML; tempDiv.innerHTML = sanitizedHTML;
document.body.appendChild(tempDiv); document.body.appendChild(tempDiv);
const canvas = await html2canvas(tempDiv, { scale: 2 }); // allowTaint and useCORS are set to true to allow cross-origin images to be used in the canvas
const canvas = await html2canvas(tempDiv, { scale: 2, useCORS: true, allowTaint: true });
document.body.removeChild(tempDiv); document.body.removeChild(tempDiv);
const pdf = new jsPDF('p', 'mm', 'a4'); const pdf = new jsPDF('p', 'mm', 'letter');
const pageWidth = pdf.internal.pageSize.width; const pageWidth = pdf.internal.pageSize.width;
const pageHeight = pdf.internal.pageSize.height; const pageHeight = pdf.internal.pageSize.height;
const margin = 10; const margin = 10;