mirror of
https://github.com/zadam/trilium.git
synced 2025-11-04 20:36:13 +01:00
feat(client): improve error handling if unable to copy to clipboard
This commit is contained in:
@@ -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"));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user