Add fallback clipboard copy and wrap content in layout container
This commit is contained in:
+31
-4
@@ -6029,11 +6029,38 @@
|
||||
},
|
||||
|
||||
_copyPath(path) {
|
||||
navigator.clipboard.writeText(path).then(() => {
|
||||
showToast(`Chemin copié : ${path}`, 'success');
|
||||
}).catch(() => {
|
||||
// Try modern clipboard API first, fall back to execCommand for non-secure contexts
|
||||
if (navigator.clipboard && navigator.clipboard.writeText) {
|
||||
navigator.clipboard.writeText(path).then(() => {
|
||||
showToast(`Chemin copié : ${path}`, 'success');
|
||||
}).catch(() => {
|
||||
this._copyPathFallback(path);
|
||||
});
|
||||
} else {
|
||||
this._copyPathFallback(path);
|
||||
}
|
||||
},
|
||||
|
||||
_copyPathFallback(path) {
|
||||
const textarea = document.createElement('textarea');
|
||||
textarea.value = path;
|
||||
textarea.style.position = 'fixed';
|
||||
textarea.style.left = '-9999px';
|
||||
textarea.style.top = '-9999px';
|
||||
document.body.appendChild(textarea);
|
||||
textarea.focus();
|
||||
textarea.select();
|
||||
try {
|
||||
const success = document.execCommand('copy');
|
||||
if (success) {
|
||||
showToast(`Chemin copié : ${path}`, 'success');
|
||||
} else {
|
||||
showToast('Erreur lors de la copie', 'error');
|
||||
}
|
||||
} catch (e) {
|
||||
showToast('Erreur lors de la copie', 'error');
|
||||
});
|
||||
}
|
||||
document.body.removeChild(textarea);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user