Run "make fmt"
This commit is contained in:
parent
28c5c1be7b
commit
3280ab38e9
1 changed files with 6 additions and 6 deletions
|
@ -149,11 +149,11 @@ export default class Util {
|
|||
static async copyToMachineClipboard(text) {
|
||||
if (window.navigator.clipboard) {
|
||||
await window.navigator.clipboard.writeText(text);
|
||||
} else if (document.execCommand) {
|
||||
} else if (document.execCommand) {
|
||||
// Clipboard is available only in HTTPS pages. see https://web.dev/async-clipboard/
|
||||
// So if the the official 'clipboard' doesn't supported and the 'document.execCommand' is supported.
|
||||
// copy by a work-around by creating a textarea in the DOM and execute copy command from him.
|
||||
|
||||
|
||||
// Create the text area element (to copy from)
|
||||
const clipboardElement = document.createElement("textarea");
|
||||
|
||||
|
@ -171,19 +171,19 @@ export default class Util {
|
|||
// "Select" the new textarea
|
||||
clipboardElement.focus();
|
||||
clipboardElement.select();
|
||||
|
||||
|
||||
// Copy the selected textarea content
|
||||
const succeed = document.execCommand('copy');
|
||||
const succeed = document.execCommand("copy");
|
||||
|
||||
// Remove the textarea from DOM
|
||||
document.body.removeChild(clipboardElement);
|
||||
|
||||
// Validate operation succeed
|
||||
if (!succeed) {
|
||||
throw new Error('Failed copying to clipboard');
|
||||
throw new Error("Failed copying to clipboard");
|
||||
}
|
||||
} else {
|
||||
throw new Error('Copy to clipboard does not support in your browser');
|
||||
throw new Error("Copy to clipboard does not support in your browser");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue