diff --git a/src/components/events/partials/modals/EmbeddingCodeModal.tsx b/src/components/events/partials/modals/EmbeddingCodeModal.tsx index c36d9859b4..75d38ba644 100644 --- a/src/components/events/partials/modals/EmbeddingCodeModal.tsx +++ b/src/components/events/partials/modals/EmbeddingCodeModal.tsx @@ -31,10 +31,10 @@ const EmbeddingCodeModal = ({ }, []); const copy = () => { - const copyText = document.getElementById("social_embed-textarea") as HTMLTextAreaElement; + const copyText = document.getElementById("social_embed-textarea"); if (copyText) { - copyText.select(); - document.execCommand("copy"); + const text = copyText.innerText; + navigator.clipboard.writeText(text); setCopySuccess(true); } @@ -78,6 +78,13 @@ const EmbeddingCodeModal = ({ setCopySuccess(false); }; + const handleKeyDown = (e: React.KeyboardEvent) => { + if ((e.ctrlKey || e.metaKey) && e.key === "c") { + e.preventDefault(); + copy(); + } + }; + return ( <> {/* embed size buttons */} @@ -142,14 +149,15 @@ const EmbeddingCodeModal = ({ {/* text area containing current iFrame code to copy*/}
-