Drag and drop custom clipboard contents from OS

54 views
Skip to first unread message

Martin Ceronio

unread,
Nov 20, 2017, 12:22:35 AM11/20/17
to Chromium-dev

This list of clipboard formats refers:


https://msdn.microsoft.com/en-us/library/windows/desktop/ff729168(v=vs.85).aspx


It seems that only a limited set of clipboard formats is supported for dragging from the OS into an HTML5 drop target.


To test this, I have created an HTML5 drop target on a page and played around by dragging data from various applications into it and examining the contents of event.dataTransfer in debugging. In most cases, there will be something available in dataTransfer.item and via dataTransfer.getData(), but there are some exceptions, especially when the source seems to use some custom clipboard format. (Tested on Windows with Chrome, Firefox and IE).


Is this specifically something in the HTML5 specification? I tried looking through the W3 spec on drag & drop (which is pretty big), but my guess is that at the point the browser creates the drag event, it is filtering out the clipboard contents on format.


I would really like to know, otherwise, how one would be able to access custom clipboard contents, or raw clipboard data in the drop.


(Sorry if this is the wrong place to post this, but hopefully you can steer me in the right direction or explain, in terms of implementation, what the reasoning behind this behaviour is).

Martin Ceronio

unread,
Nov 20, 2017, 12:34:35 AM11/20/17
to Chromium-dev
I think I have found the answer (which I have posted on SO here: https://stackoverflow.com/a/47385597/274354).

It seems to me that the list of clipboard formats for drag and drop is indeed limited and does not support custom clipboard formats.

Daniel Cheng

unread,
Nov 21, 2017, 8:13:50 PM11/21/17
to mar...@ceronio.net, Chromium-dev
Unfortunately, for privacy and security reasons, Chrome limits the native clipboard types that get exposed to the web API. The web API *does* support arbitrary format strings, and any custom formats will be visible to other web pages--just not native apps.

https://github.com/w3c/clipboard-apis/issues/46 has some more background.

Daniel

--
--
Chromium Developers mailing list: chromi...@chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-dev
---
You received this message because you are subscribed to the Google Groups "Chromium-dev" group.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-dev/17c992d2-b6b0-442d-85c8-747aa22b2ae2%40chromium.org.
Reply all
Reply to author
Forward
0 new messages