State of the art in Copy to Clipboard feature (My investigations)
Flash alternative
- I have found the following alternatives:
- Zclip: we are using
- zeroclipboard (ancestor, zclip uses its button flash movie): only text
- Clippy: only text in the page https://github.com/mojombo/clippy
- You can see in the (ActionScript:Flash) code: http://code.google.com/p/zeroclipboard/source/browse/trunk/ZeroClipboard.as (line 77)
- They use System.setClipboard(cliptText) call, which only supports plain text strings, as we can see in Adobe AIR API refference: http://help.adobe.com/en_US/air/reference/html/flash/system/System.html
- So we cant pass formatted text through flash.
HTML5 alternative
There is an API in draft to standardize clipboard events, but is not implemented in any browser for the moment http://dev.w3.org/2006/webapi/clipops/
My Rails/Zclip implementation
I'm using zclip (based on zeroclipboard) to copy text from a restfule service to the system clipboard:
$('.copy-to-clipboard').zclip
path:'/ZeroClipboard.swf'
setHandCursor: true
copy: ->
ajaxReturn = $.ajax
type: 'GET'
async: false
url: '/resources/copy_to_clipboard/' + $(this).attr("class").match(/[0-9]+/)
return ajaxReturn.responseText
It's coffeescript.
If the service (/resources/copy_to_clipboard/) serves text it's copied right. But if it servers a DOCX file, it doesn't copy right to the clipboard. Take a look at the rails controller:
def copy_to_clipboard
send_file @resource.resource_content.content.file.file, :type => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'
end
The question
Have you solved the copy BINARY data to clipboard any time ? and how ?
Thanks