mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-07-28 10:32:27 +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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let succeeded = false;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (navigator.clipboard) {
|
if (navigator.clipboard) {
|
||||||
navigator.clipboard.writeText(text);
|
navigator.clipboard.writeText(text);
|
||||||
toast.showMessage(t("code_block.copy_success"));
|
succeeded = true;
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
succeeded = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (succeeded) {
|
||||||
|
toast.showMessage(t("code_block.copy_success"));
|
||||||
|
} else {
|
||||||
toast.showError(t("code_block.copy_failed"));
|
toast.showError(t("code_block.copy_failed"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user