MOBILE-3565 utils: Fix copy to clipboard on browser

main
Pau Ferrer Ocaña 2020-10-15 17:07:37 +02:00
parent 919b4f5d44
commit 41dd1a6a74
1 changed files with 9 additions and 4 deletions

View File

@ -308,12 +308,17 @@ export class CoreUtilsProvider {
async copyToClipboard(text: string): Promise<void> {
try {
await Clipboard.instance.copy(text);
// Show toast using ionicLoading.
CoreDomUtils.instance.showToast('core.copiedtoclipboard', true);
} catch {
// Ignore errors.
// Use HTML Copy command.
const virtualInput = document.createElement('textarea');
virtualInput.innerHTML = text;
virtualInput.select();
virtualInput.setSelectionRange(0, 99999);
document.execCommand('copy');
}
// Show toast using ionicLoading.
CoreDomUtils.instance.showToast('core.copiedtoclipboard', true);
}
/**