fix: corriger l'erreur CSP et le nettoyage HTML des notes

- Remplacer l'audio base64 par Web Audio API dans PomodoroTimer pour éviter les erreurs CSP
- Ajouter une fonction cleanHtmlContent pour correctement décoder les entités HTML
- Corriger l'affichage des notes pour supprimer les caractères parasites (&nb-, etc.)
This commit is contained in:
Claude committed 2025-11-28 20:29:59 +00:00
1 parent 3b8644bc4c
commit c66e5adc4a
2 files changed
+60 -9

No files matched your search

+42 -8
View File
@@ -21,12 +21,48 @@ export function PomodoroTimer() {
const [isRunning, setIsRunning] = useState(false); const [isRunning, setIsRunning] = useState(false);
const [sessionsCompleted, setSessionsCompleted] = useState(0); const [sessionsCompleted, setSessionsCompleted] = useState(0);
const intervalRef = useRef<NodeJS.Timeout | null>(null); const intervalRef = useRef<NodeJS.Timeout | null>(null);
const audioRef = useRef<HTMLAudioElement | null>(null);
useEffect(() => { // Function to play notification sound using Web Audio API
// Create audio element for notification const playNotificationSound = () => {
audioRef.current = new Audio('data:audio/wav;base64,UklGRnoGAABXQVZFZm10IBAAAAABAAEAQB8AAEAfAAABAAgAZGF0YQoGAACBhYqFbF1fdJivrJBhNjVgodDbq2EcBj+a2/LDciUFLIHO8tiJNwgZaLvt559NEAxQp+PwtmMcBjiR1/LMeSwFJHfH8N2QQAoUXrTp66hVFApGn+DyvmwhBSuBzvPaizMHGGS56+mgUBELTqXj8bllHgU2jdXtyHAmBSl+zPLaizsIE12y6OqqWBQLSKHh8rxrIQUsgs/z2ow0BxdnuertolIRC0ul4/K5Zx4FNo3V7chxJwUpf8zy24s7CBRdsujqqVgTCkig4fK8ayCFLILP8tqMNAcXZ7nq7aJSEQtLpePxuGYeBS+Mz+3McyYEKH3L8tmKOwgUXLLn6qdZFApHnuDyvGscBSyCzvLbjDMHF2e56+yiUhELSqXj8rhnHgU2jdXtyHEmBCh+y/LZijsJE1yx6OqoWRMKR57g8rxrHAUsgs7y24wzBxdnuevoIlIQC0ql4/K4Zh4FNo3V7chxJgQofszy2Yo7CBNcsefqp1oUCkee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ahZFQpHneDxvGocBSuCzvLajDQIF2a56+ujVRELSqPj8rllHgU2jdXuyHEnBCh+zPLYijsIE1uw6OmoWhYKR53f8bxqHAYrgs7y2ow0Bhdn'); try {
}, []); const audioContext = new (window.AudioContext || (window as any).webkitAudioContext)();
const oscillator = audioContext.createOscillator();
const gainNode = audioContext.createGain();
oscillator.connect(gainNode);
gainNode.connect(audioContext.destination);
// Create a pleasant notification sound (two beeps)
oscillator.frequency.value = 800;
oscillator.type = 'sine';
gainNode.gain.setValueAtTime(0.3, audioContext.currentTime);
gainNode.gain.exponentialRampToValueAtTime(0.01, audioContext.currentTime + 0.2);
oscillator.start(audioContext.currentTime);
oscillator.stop(audioContext.currentTime + 0.2);
// Second beep
setTimeout(() => {
const oscillator2 = audioContext.createOscillator();
const gainNode2 = audioContext.createGain();
oscillator2.connect(gainNode2);
gainNode2.connect(audioContext.destination);
oscillator2.frequency.value = 1000;
oscillator2.type = 'sine';
gainNode2.gain.setValueAtTime(0.3, audioContext.currentTime);
gainNode2.gain.exponentialRampToValueAtTime(0.01, audioContext.currentTime + 0.2);
oscillator2.start(audioContext.currentTime);
oscillator2.stop(audioContext.currentTime + 0.2);
}, 250);
} catch (e) {
console.error('Audio play failed:', e);
}
};
useEffect(() => { useEffect(() => {
if (isRunning && timeLeft > 0) { if (isRunning && timeLeft > 0) {
@@ -52,9 +88,7 @@ export function PomodoroTimer() {
setIsRunning(false); setIsRunning(false);
// Play notification sound // Play notification sound
if (audioRef.current) { playNotificationSound();
audioRef.current.play().catch(e => console.error('Audio play failed:', e));
}
if (mode === 'work') { if (mode === 'work') {
const newSessionCount = sessionsCompleted + 1; const newSessionCount = sessionsCompleted + 1;
+18 -1
View File
@@ -120,6 +120,23 @@ interface UserType {
is_admin: boolean; is_admin: boolean;
} }
// Function to clean HTML content and decode entities
const cleanHtmlContent = (html: string): string => {
if (!html) return '';
// Create a temporary div to decode HTML entities
const temp = document.createElement('div');
temp.innerHTML = html;
// Get text content (removes HTML tags and decodes entities)
let text = temp.textContent || temp.innerText || '';
// Remove any remaining HTML entity artifacts
text = text.replace(/&[a-z]+;?/gi, ' ').replace(/\s+/g, ' ').trim();
return text;
};
const Index = () => { const Index = () => {
const [user, setUser] = useState<UserType | null>(null); const [user, setUser] = useState<UserType | null>(null);
const [showAdmin, setShowAdmin] = useState(false); const [showAdmin, setShowAdmin] = useState(false);
@@ -1398,7 +1415,7 @@ const Index = () => {
{note.title || "Sans titre"} {note.title || "Sans titre"}
</h3> </h3>
<p className="text-sm text-muted-foreground line-clamp-2 mb-3"> <p className="text-sm text-muted-foreground line-clamp-2 mb-3">
{note.content ? note.content.replace(/<[^>]*>/g, '') : "Note vide"} {note.content ? cleanHtmlContent(note.content) : "Note vide"}
</p> </p>
<div className="flex gap-2 flex-wrap mb-2"> <div className="flex gap-2 flex-wrap mb-2">
{note.todos && note.todos.length > 0 && ( {note.todos && note.todos.length > 0 && (