aboutsummaryrefslogtreecommitdiffstats
path: root/lib/clipboard.coffee
diff options
context:
space:
mode:
Diffstat (limited to 'lib/clipboard.coffee')
-rw-r--r--lib/clipboard.coffee9
1 files changed, 5 insertions, 4 deletions
diff --git a/lib/clipboard.coffee b/lib/clipboard.coffee
index 1d378e76..a9e2e82e 100644
--- a/lib/clipboard.coffee
+++ b/lib/clipboard.coffee
@@ -1,8 +1,9 @@
Clipboard =
- _createTextArea: ->
- textArea = document.createElement "textarea"
+ _createTextArea: (tagName = "textarea") ->
+ textArea = document.createElement tagName
textArea.style.position = "absolute"
textArea.style.left = "-100%"
+ textArea.contentEditable = "true"
textArea
# http://groups.google.com/group/chromium-extensions/browse_thread/thread/49027e7f3b04f68/f6ab2457dee5bf55
@@ -16,11 +17,11 @@ Clipboard =
document.body.removeChild(textArea)
paste: ->
- textArea = @_createTextArea()
+ textArea = @_createTextArea "div" # Use a <div> so Firefox pastes rich text.
document.body.appendChild(textArea)
textArea.focus()
document.execCommand("Paste")
- value = textArea.value
+ value = textArea.innerText
document.body.removeChild(textArea)
value