perf: Add toasts for copy/paste success/error (#620)

This commit is contained in:
Rémi Marseault 2023-01-24 10:53:34 +01:00 committed by GitHub
parent e990d344d2
commit 6cabef1b56
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 18 additions and 9 deletions

View file

@ -241,19 +241,24 @@ export default {
startDropFile() {
this.showWrapDrag = true
},
DragLeave(e) {
DragLeave() {
this.showWrapDrag = false
},
closeWrap() {
if (this.showWrapDrag) this.showWrapDrag = false
else this.close()
},
async paste() {
async paste(e) {
if (navigator.clipboard && window.isSecureContext) {
this.urls = await navigator.clipboard.readText()
} else {
this.urls = document.execCommand('paste')
e.target.focus()
if (!document.execCommand('paste')) {
this.$toast.error(this.$i18n.t("toast.pasteNotSupported").toString())
return
}
}
this.$toast.success(this.$i18n.t("toast.pasteSuccess").toString())
},
submit() {
if (this.files.length || this.urls) {

View file

@ -432,13 +432,13 @@ export default {
textArea.style.opacity = '0'
document.body.appendChild(textArea)
textArea.select()
try {
document.execCommand('copy')
} catch (err) {
console.error('Unable to copy to clipboard', err)
if (!document.execCommand('copy')) {
this.$toast.error(this.$i18n.t("toast.copyNotSupported").toString())
return
}
document.body.removeChild(textArea)
}
this.$toast.success(this.$i18n.t("toast.copySuccess").toString())
}
}
}

View file

@ -461,7 +461,9 @@
"ruleSaved": "Rule saved!",
"renameFileFailed": "Unable to rename file",
"renameFolderFailed": "Unable to rename file",
"copySuccess": "Text copied!",
"copyNotSupported": "Unable to copy, clipboard API unavailable on this browser",
"pasteSuccess": "Text pasted!",
"pasteNotSupported": "Unable to paste, clipboard API unavailable on this browser"
},
"rightClick": {

View file

@ -450,8 +450,10 @@
"ruleSaved": "Règle enregistrée !",
"renameFileFailed": "Impossible de renommer le fichier",
"renameFolderFailed": "Impossible de renommer le dossier",
"copyNotSupported": "Impossible de copier, clipboard API indisponible dans ce navigateur",
"pasteNotSupported": "Impossible de coller, clipboard API indisponible dans ce navigateur"
"copySuccess": "Texte copié!",
"copyNotSupported": "Impossible de copier, Clipboard API indisponible dans ce navigateur",
"pasteSuccess": "Texte collé!",
"pasteNotSupported": "Impossible de coller, Clipboard API indisponible dans ce navigateur"
},
"rightClick": {
"resume": "Reprendre",