Re: [w3c/clipboard-apis] Should we have an API to return the set of readable/writable data types? (#67)

Now that Safari 13.1 is [shipping significant support](https://webkit.org/blog/10855/async-clipboard-api/), this would be rather useful.

For example:
- Safari 13.1 supports `text/plain`, `text/html`, `text/uri-list`, `image/png`.
- Chrome 83 supports `text/plain`, `image/png`.

I maintain [`clipboard-polyfill`](https://github.com/lgarron/clipboard-polyfill), a library that uses old APIs as fallback. Since copying `text/html` was supported in all browsers using the old clipboard API, I want to make sure that my library can use it as a fallback until [Chrome supports it](https://bugs.chromium.org/p/chromium/issues/detail?id=931839&colspec=ID%20Pri%20M%20Status%20Owner%20Summary%20OS%20Modified&x=m&y=releaseblock&cells=tiles&q=clipboard%20lgarron%20html&can=2).

However:
- `navigator.clipboard.write()` doesn't support HTML in Chrome.
- `document.execCommanc()` doesn't support HTML in Safari.
- It is not possible to use "proper" feature detection, because `document.queryCommandEnabled("copy")` is [broken in most implementations](https://github.com/lgarron/clipboard-polyfill/blob/main/experiment/Conclusions.md).

The best I can think of right now is to try copying and catch if it fails, but the spec doesn't specify that the browser should throw an error on unsupported data types, and different browsers currently behave differently (at the moment, Chrome errors and Safari ignores it).

Note that #30 and #97 are about the same thing; these issues should probably all be deduplicated into one.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/w3c/clipboard-apis/issues/67#issuecomment-650439507

Received on Friday, 26 June 2020 22:58:06 UTC