Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Should we have an API to return the set of readable/writable data types? #67

Open
garykac opened this issue Feb 15, 2018 · 2 comments
Open

Comments

@garykac
Copy link
Member

garykac commented Feb 15, 2018

We should consider defining a way for JS to determine the set of data types that the UA supports for reading/writing.

Currently, we have a list of supported types in 10. Mandatory data types. But some UAs may choose to support a larger set.

In addition, note that the set of supported types will be different for the legacy (execCommand-based) APIs and the new Async APIs, because the newer APIs can safely support a larger set of types.

@garykac
Copy link
Member Author

garykac commented Feb 15, 2018

See related issue: #30

@lgarron
Copy link
Contributor

lgarron commented Jun 26, 2020

Now that Safari 13.1 is shipping significant support, 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, 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.

However:

  • navigator.clipboard.write() doesn't support HTML in Chrome.
  • document.execCommand() doesn't support HTML in Safari.
  • It is not possible to use "proper" feature detection, because document.queryCommandEnabled("copy") is broken in most implementations.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants