/** Copie texte — writeText async + repli synchrone execCommand. */ export async function copyTextToClipboard(text: string): Promise { if (typeof window === 'undefined') return false if (navigator.clipboard?.writeText) { try { await navigator.clipboard.writeText(text) return true } catch { // repli ci-dessous } } try { const ta = document.createElement('textarea') ta.value = text ta.setAttribute('readonly', '') ta.style.position = 'fixed' ta.style.left = '-9999px' ta.style.top = '0' document.body.appendChild(ta) ta.focus() ta.select() const ok = document.execCommand('copy') document.body.removeChild(ta) return ok } catch { return false } }