diff options
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/clipboard.coffee | 4 | ||||
| -rw-r--r-- | lib/dom_utils.coffee | 5 |
2 files changed, 8 insertions, 1 deletions
diff --git a/lib/clipboard.coffee b/lib/clipboard.coffee index 2b28df70..836b57e4 100644 --- a/lib/clipboard.coffee +++ b/lib/clipboard.coffee @@ -15,13 +15,15 @@ Clipboard = document.execCommand("Copy") document.body.removeChild(textArea) - paste: -> + paste: (refocusElement = null) -> textArea = @._createTextArea() document.body.appendChild(textArea) textArea.focus() document.execCommand("Paste") value = textArea.value document.body.removeChild(textArea) + # The caller wants this element refocused. + refocusElement.focus() if refocusElement value diff --git a/lib/dom_utils.coffee b/lib/dom_utils.coffee index 477abef2..c1ce051f 100644 --- a/lib/dom_utils.coffee +++ b/lib/dom_utils.coffee @@ -231,6 +231,11 @@ DomUtils = @remove() false + simulateTextEntry: (element, text) -> + event = document.createEvent "TextEvent" + event.initTextEvent "textInput", true, true, null, text + element.dispatchEvent event + extend DomUtils, # From: https://github.com/component/textarea-caret-position/blob/master/index.js getCaretCoordinates: do -> |
