warn if clipboard support is missing (#922)

* warn if clipboard support is missing

* make the message a bit more helpful

* Update assets/js/app.js

Co-authored-by: Jonatan Kłosko <jonatanklosko@gmail.com>
This commit is contained in:
Joe Martinez 2022-01-24 05:21:13 -05:00 committed by GitHub
parent e94950e70c
commit cd958f1492
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -91,12 +91,16 @@ window.addEventListener("lb:set_value", (event) => {
event.target.value = event.detail.value;
});
if ("clipboard" in navigator) {
window.addEventListener("lb:clipcopy", (event) => {
window.addEventListener("lb:clipcopy", (event) => {
if ("clipboard" in navigator) {
const text = event.target.textContent;
navigator.clipboard.writeText(text);
});
}
} else {
alert(
"Sorry, your browser does not support clipboard copy.\nThis generally requires a secure origin — either HTTPS or localhost."
);
}
});
// Other global handlers