Contact emails
Eng: gar...@chromium.org
Spec
Editor's Draft Clipboard Spec: https://w3c.github.io/clipboard-apis/
Explainer: https://github.com/garykac/clipboard/blob/master/clipboard.md
WICG Discourse: https://discourse.wicg.io/t/proposal-modern-asynchronous-clipboard-api/1513
Summary
A modern, asynchronous Clipboard API based on Promises.
Motivation
The primary motivation for this proposal is to address the following issues present in the current synchronous Clipboard API:
Interoperability and Compatibility Risk
Low.
This intent is to add a new async API without changing the current sync API, so existing content will not break.
Response from other browser vendors (Apple, Mozilla, Microsoft) has been positive.
This feature was discussed at TPAC during the Web Platform meeting (present: Microsoft, Apple, Mozilla, Yandex), and it was agreed that this should move forward. See discussion at https://www.w3.org/2016/09/22-webapps-minutes.html#item17
Note that proper web platform support for clipboard cut/copy/paste has been a longstanding request from users and web developers. See related bugs: 150835, 390583, 424968, 443355, 593475.
Ongoing technical constraints
None.
Will this feature be supported on all six Blink platforms (Windows, Mac, Linux, Chrome OS, Android, and Android WebView)?
Yes.
OWP launch tracking bug
Link to entry on the feature dashboard
https://www.chromestatus.com/feature/5861289330999296
Requesting approval to ship?
Not at this time.
Nice to see changes to the clipboard API. A few questions.
- https://w3c.github.io/clipboard-apis/#selection-mod says If the event listener modifies the selection or focus, the clipboard action must be completed on the modified selection. Do you know if this somewhat is meant to cover cross-origin selection/focus changes (eg, to an iframe)?
- https://w3c.github.io/clipboard-apis/#h-clipboard-read and https://w3c.github.io/clipboard-apis/#h-clipboard-write-data say TODO: Handle access permissions. Reject promise if not allowed. Do you know already how would that be implemented? The synchronous API has some hints about it, but I don't know if they also can apply to the asynchronous API. For example, would this be allowed?
window.addEventListener('copy', e=>{
e.preventDefault();
convertSvgToPng().then(png=>{
var data = new DataTransfer();
data.items.add("image/png", png);
navigator.clipboard.write(png);
});
});
- https://github.com/garykac/clipboard/blob/master/clipboard.md#navigatorclipboard mentions that this API is meant to be accessible from Workers. This is interesting because it also implies background access to the clipboard is an intended use case (I'm thinking about service workers, for example). Furthermore, https://github.com/garykac/clipboard/blob/master/clipboard.md#mitigating-abuse also says that permission dialogs might be skipped with the right set of permissions. Do you envision there to be a permission where background access to the clipboard is available to a service worker, for example? This question is mostly to try to understand whether this API would be exposing a permission that gives background access to the clipboard.