Corrections visuel ; optimisation du chargement des pages (préchargement anticité, sinon temps de latence chaque fois qu'on visite un type de page une première fois)

This commit is contained in:
2026-04-22 13:17:05 +02:00
parent 5ea3a5097f
commit 735dd2eee0
13 changed files with 385 additions and 34 deletions

View File

@@ -0,0 +1,23 @@
import { Pipe, PipeTransform } from '@angular/core';
import { DomSanitizer, SafeHtml } from '@angular/platform-browser';
import DOMPurify from 'dompurify';
import { marked } from 'marked';
/**
* Pipe markdown → HTML sanitise. Utilise pour le rendu des reponses IA.
* Combine marked (parser) + DOMPurify (anti-XSS) puis bypass la sanitization
* Angular puisque le contenu est deja nettoye.
*
* Configure en mode synchrone (`async: false`) pour eviter une Promise.
*/
@Pipe({ name: 'markdown', standalone: true })
export class MarkdownPipe implements PipeTransform {
constructor(private readonly sanitizer: DomSanitizer) {}
transform(value: string | null | undefined): SafeHtml {
if (!value) return '';
const html = marked.parse(value, { async: false, gfm: true, breaks: true }) as string;
const clean = DOMPurify.sanitize(html);
return this.sanitizer.bypassSecurityTrustHtml(clean);
}
}