copy to clipboard in IE (#19281)
This commit is contained in:
parent
51592c652a
commit
1f6f662c08
|
@ -20,12 +20,12 @@ function createHiddenTextElement(text) {
|
|||
export function copyToClipboard(text) {
|
||||
let isCopied = true;
|
||||
const range = document.createRange();
|
||||
const selection = document.getSelection();
|
||||
const selection = window.getSelection();
|
||||
const elementToBeCopied = createHiddenTextElement(text);
|
||||
|
||||
document.body.appendChild(elementToBeCopied);
|
||||
range.selectNode(elementToBeCopied);
|
||||
selection.empty();
|
||||
selection.removeAllRanges();
|
||||
selection.addRange(range);
|
||||
|
||||
if (!document.execCommand('copy')) {
|
||||
|
|
Loading…
Reference in a new issue