| 560 | // Default innerText doesn't work (on Chrome/Firefox), because <br/> is treated as double new-line |
| 561 | // So the idea is just select text and copy it |
| 562 | function readUserVisibleText(elem) { |
| 563 | const selection = window.getSelection(); |
| 564 | const range = document.createRange(); |
| 565 | range.selectNodeContents(elem); |
| 566 | selection.removeAllRanges(); |
| 567 | selection.addRange(range); |
| 568 | const selectionString = selection.toString(); |
| 569 | selection.removeAllRanges(); |
| 570 | return selectionString; |
| 571 | } |
| 572 | |
| 573 | export function copyToClipboard(elem) { |
| 574 | // if new Clipboard API is available, just use it |