| 24 | * copy from element |
| 25 | */ |
| 26 | const copyFromElement = elem => { |
| 27 | const range = document.createRange() |
| 28 | const selection = window.getSelection() |
| 29 | |
| 30 | range.selectNode(elem) |
| 31 | |
| 32 | if (selection.rangeCount > 0) { |
| 33 | selection.removeAllRanges() |
| 34 | } |
| 35 | |
| 36 | selection.addRange(range) |
| 37 | execCopy() |
| 38 | selection.removeAllRanges() |
| 39 | } |
| 40 | |
| 41 | /** |
| 42 | * copy from textarea |