MOBILE-3565 utils: Fix copy to clipboard on browser
parent
919b4f5d44
commit
41dd1a6a74
|
@ -308,12 +308,17 @@ export class CoreUtilsProvider {
|
||||||
async copyToClipboard(text: string): Promise<void> {
|
async copyToClipboard(text: string): Promise<void> {
|
||||||
try {
|
try {
|
||||||
await Clipboard.instance.copy(text);
|
await Clipboard.instance.copy(text);
|
||||||
|
|
||||||
// Show toast using ionicLoading.
|
|
||||||
CoreDomUtils.instance.showToast('core.copiedtoclipboard', true);
|
|
||||||
} catch {
|
} 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);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue