mirror of
https://github.com/schlagmichdoch/PairDrop.git
synced 2025-04-21 15:26:17 -04:00
show warning to user if navigator.clipboard.writeText fails
This commit is contained in:
parent
c71bf456e3
commit
bd7b3c6d28
4 changed files with 18 additions and 6 deletions
|
@ -100,6 +100,7 @@
|
|||
"pairing-key-invalidated": "Key {{key}} invalidated.",
|
||||
"pairing-cleared": "All Devices unpaired.",
|
||||
"copied-to-clipboard": "Copied to clipboard",
|
||||
"copied-to-clipboard-error": "Copying not possible. Copy manually.",
|
||||
"text-content-incorrect": "Text content is incorrect.",
|
||||
"file-content-incorrect": "File content is incorrect.",
|
||||
"clipboard-content-incorrect": "Clipboard content is incorrect.",
|
||||
|
|
|
@ -1497,9 +1497,14 @@ class ReceiveTextDialog extends Dialog {
|
|||
|
||||
async _onCopy() {
|
||||
const sanitizedText = this.$text.innerText.replace(/\u00A0/gm, ' ');
|
||||
await navigator.clipboard.writeText(sanitizedText);
|
||||
navigator.clipboard.writeText(sanitizedText)
|
||||
.then(_ => {
|
||||
Events.fire('notify-user', Localization.getTranslation("notifications.copied-to-clipboard"));
|
||||
this.hide();
|
||||
})
|
||||
.catch(_ => {
|
||||
Events.fire('notify-user', Localization.getTranslation("notifications.copied-to-clipboard-error"));
|
||||
});
|
||||
}
|
||||
|
||||
hide() {
|
||||
|
|
|
@ -97,6 +97,7 @@
|
|||
"pairing-key-invalidated": "Key {{key}} invalidated.",
|
||||
"pairing-cleared": "All Devices unpaired.",
|
||||
"copied-to-clipboard": "Copied to clipboard",
|
||||
"copied-to-clipboard-error": "Copying not possible. Copy manually.",
|
||||
"text-content-incorrect": "Text content is incorrect.",
|
||||
"file-content-incorrect": "File content is incorrect.",
|
||||
"clipboard-content-incorrect": "Clipboard content is incorrect.",
|
||||
|
|
|
@ -1498,9 +1498,14 @@ class ReceiveTextDialog extends Dialog {
|
|||
|
||||
async _onCopy() {
|
||||
const sanitizedText = this.$text.innerText.replace(/\u00A0/gm, ' ');
|
||||
await navigator.clipboard.writeText(sanitizedText);
|
||||
navigator.clipboard.writeText(sanitizedText)
|
||||
.then(_ => {
|
||||
Events.fire('notify-user', Localization.getTranslation("notifications.copied-to-clipboard"));
|
||||
this.hide();
|
||||
})
|
||||
.catch(_ => {
|
||||
Events.fire('notify-user', Localization.getTranslation("notifications.copied-to-clipboard-error"));
|
||||
});
|
||||
}
|
||||
|
||||
hide() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue