(text)
| 499 | return null; |
| 500 | } |
| 501 | function insertIntoForumEditor(text) { |
| 502 | var cm = findForumEditor(); |
| 503 | if (!cm) return false; |
| 504 | if (typeof cm.replaceSelection === 'function') { |
| 505 | cm.replaceSelection(text); |
| 506 | if (typeof cm.focus === 'function') cm.focus(); |
| 507 | return true; |
| 508 | } |
| 509 | if (cm.hasFocus && typeof cm.getCursor === 'function' && typeof cm.replaceRange === 'function') { |
| 510 | var from = cm.getCursor(); |
| 511 | var to = cm.somethingSelected() ? cm.getSelection() : from; |
| 512 | cm.replaceRange(text, from, to); |
| 513 | if (typeof cm.focus === 'function') cm.focus(); |
| 514 | return true; |
| 515 | } |
| 516 | return false; |
| 517 | } |
| 518 | function copyText(t, onOk, onErr) { |
| 519 | if (navigator.clipboard && navigator.clipboard.writeText) { |
| 520 | navigator.clipboard.writeText(t).then(onOk).catch(onErr); |
no test coverage detected