mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-07-27 10:02:59 +08:00
feat(client): improve error handling if unable to copy to clipboard
This commit is contained in:
parent
a666e26194
commit
ac0f6662a6
@ -114,12 +114,20 @@ export function copyText(text: string) {
|
||||
return;
|
||||
}
|
||||
|
||||
let succeeded = false;
|
||||
|
||||
try {
|
||||
if (navigator.clipboard) {
|
||||
navigator.clipboard.writeText(text);
|
||||
toast.showMessage(t("code_block.copy_success"));
|
||||
succeeded = true;
|
||||
}
|
||||
} catch (e) {
|
||||
succeeded = false;
|
||||
}
|
||||
|
||||
if (succeeded) {
|
||||
toast.showMessage(t("code_block.copy_success"));
|
||||
} else {
|
||||
toast.showError(t("code_block.copy_failed"));
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user