Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | 1x 5x 5x 5x 5x | const init = () => {
const button = document.querySelector(
"[data-js='copy-deploy-command']"
) as HTMLButtonElement | null;
const codeEl = document.getElementById("deploy-command");
Eif (!button || !codeEl || !navigator.clipboard) {
return;
}
button.addEventListener("click", async () => {
const text = codeEl.textContent?.trim();
if (!text) {
return;
}
const icon = button.querySelector("i");
if (!icon) {
return;
}
try {
await navigator.clipboard.writeText(text);
} catch {
return;
}
icon.className = "p-icon--success";
button.title = "Copied";
button.setAttribute("aria-label", "Deploy command copied");
window.setTimeout(() => {
icon.className = "p-icon--copy";
button.title = "Copy deploy command";
button.setAttribute("aria-label", "Copy deploy command");
}, 2000);
});
};
export { init as copyCommand };
|