Add failure message for clipboard copy

dev
gravel 2 years ago
parent 37cc4b8ebf
commit 21094ec919
Signed by: gravel
GPG Key ID: C0538F3C906B308F

@ -295,7 +295,11 @@ function hideElementByID(id) {
* @param {string} [toastText] - Text shown by toast.
*/
function copyToClipboard(text, toastText = JOIN_URL_PASTE) {
navigator.clipboard.writeText(text);
if (typeof navigator.clipboard !== "undefined") {
navigator.clipboard.writeText(text);
} else {
toastText = "Can not copy to clipboard in insecure context.";
}
// Find snackbar element
const snackbar = dom.snackbar();

Loading…
Cancel
Save