Skip to content

Commit

Permalink
Affiche correctement les contributeurs mentionnés dans les activités
Browse files Browse the repository at this point in the history
  • Loading branch information
ThibaudMZN committed Sep 18, 2024
1 parent 40dc69d commit 4679c4d
Showing 1 changed file with 21 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,31 @@
<script lang="ts">
import type { ActiviteMesure, DetailsAjoutCommentaire } from '../../mesure.d';
import { decode } from 'html-entities';
import { contributeurs } from '../../../tableauDesMesures/stores/contributeurs.store';
export let activite: ActiviteMesure;
const details = <DetailsAjoutCommentaire>activite.details;
const regex =
/@\[([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})\]/gm;
const contenu = decode(details.contenu).replaceAll(
regex,
(_s, idUtilisateur) => {
const contributeur = $contributeurs.find((c) => c.id === idUtilisateur);
const texte = contributeur ? contributeur.prenomNom : 'Utilisateur.rice';
return `<span class="mention">@${texte}</span>`;
}
);
</script>

<div>
<span>{decode(details.contenu)}</span>
<span>{@html contenu}</span>
</div>

<style>
:global(.mention) {
color: var(--bleu-mise-en-avant);
font-weight: 700;
}
</style>

0 comments on commit 4679c4d

Please sign in to comment.