Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 17 additions & 9 deletions src/components/events/partials/modals/EmbeddingCodeModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -78,6 +78,13 @@ const EmbeddingCodeModal = ({
setCopySuccess(false);
};

const handleKeyDown = (e: React.KeyboardEvent<HTMLElement>) => {
if ((e.ctrlKey || e.metaKey) && e.key === "c") {
e.preventDefault();
copy();
}
};

return (
<>
{/* embed size buttons */}
Expand Down Expand Up @@ -142,14 +149,15 @@ const EmbeddingCodeModal = ({

{/* text area containing current iFrame code to copy*/}
<div className="embedded-code-video">
<textarea
<code
id="social_embed-textarea"
className="social_embed-textarea embedded-code-textarea"
rows={2}
value={textAreaContent}
cols={1}
className="embedded-code-textarea"
aria-label={t("EMBEDDING_CODE.EMBEDD_CODE_TEXTAREA_ARIA")}
/>
tabIndex={0}
onKeyDown={handleKeyDown}
>
{textAreaContent}
</code>
</div>

{/* copy confirmation */}
Expand Down
9 changes: 8 additions & 1 deletion src/styles/views/modals/_embedded-code.scss
Original file line number Diff line number Diff line change
Expand Up @@ -93,14 +93,21 @@
.embedded-code-video {
text-align:center;
margin-bottom: 20px;
display: flex;
justify-content: center;
}

.embedded-code-textarea {
font-size:12px;
width:95%;
overflow:auto;
margin-top:5px;
color:black;
color: variables.$color-black;
display: block;
padding: 16px;
border-radius: 10px;
border: 1px solid variables.$color-darkgray;
white-space: pre-wrap;
}

.embedded-code-copy-to-clipboard {
Expand Down
Loading