I'm trying to read the clipboardData attribute of a paste event for a plugin that I'm developing for CKEditor 4.
I've established that, in Chrome, if I listen to the document object for a paste event, then the event object I get passed in the handler will contain the clipboardData attribute. I was surprised to see the same is not true of Firefox (v20).
This is the code I'm using in my CKEditor plugin, although I don't believe this to be an question relevant only to CKEditor. In Chrome I see the clipboardData object, in Firefox I do not.
editor.document.on('paste', function(event) {
var clipboardData = event.data.$.clipboardData;
if (clipboardData) {
console.log(clipboardData);
}
});
I can't see anything on the MDN site confirming if this is yet supported, I also believe that IE10 is meant to support this, but will it work on a standard API?
Edit:
I should have made this clear from the start, but I'm trying to develop support for pasting images, so I need to read the clipboard data as a file.
If you want to get clipboard data in paste event,these can help you:
The W3C Standard (Chrome):
event.clipboardData.getData(type)
You cant get type frome event.clipboardData.types,which is usually "text/plain". http://www.w3.org/TR/clipboard-apis/
IE:
window.clipboardData.getData(type)
Type can only be "Text" or "URL":http://msdn.microsoft.com/en-us/library/ie/ms536436%28v=vs.85%29.aspx
Firefox:
There is no api to access clipboard in ff.If you want to realize it,you can try some other way,which is depending on what you want to do.