| 510 | * @param text - text to copy |
| 511 | */ |
| 512 | export function copyTextToClipboard(text): void { |
| 513 | const el = Dom.make('div', 'codex-editor-clipboard', { |
| 514 | innerHTML: text, |
| 515 | }); |
| 516 | |
| 517 | document.body.appendChild(el); |
| 518 | |
| 519 | const selection = window.getSelection(); |
| 520 | const range = document.createRange(); |
| 521 | |
| 522 | range.selectNode(el); |
| 523 | |
| 524 | window.getSelection().removeAllRanges(); |
| 525 | selection.addRange(range); |
| 526 | |
| 527 | document.execCommand('copy'); |
| 528 | document.body.removeChild(el); |
| 529 | } |
| 530 | |
| 531 | /** |
| 532 | * Returns object with os name as key and boolean as value. Shows current user OS |