[w3c/clipboard-apis] Feature detection for supported clipboard formats (Issue #170)

Migrated and adapted from https://github.com/w3c/clipboard-apis/issues/165#issuecomment-1041668421:

I suggest we add some sort of feature-detection for custom and classic formats. This is actual nightmare-ish application code of mine that only makes sure copying works on three browsers (Firefox, Chrome, Safari): https://github.com/tomayac/SVGcode/blob/b29b27dadf2cf3c8aefb77e2c3db9feb0872d91d/src/js/clipboard.js#L64-L136

My suggestion would be to add a static function on `ClipboardItem`

```js
ClipboardItem.supports('image/webp');
// `false`
ClipboardItem.supports('image/png');
// `true`
ClipboardItem.supports('web');
// `true`
```

Not sure how to express custom types here, as a ground for discussion I just went with `"web"`. What do you think?


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

Message ID: <w3c/clipboard-apis/issues/170@github.com>

Received on Wednesday, 16 February 2022 16:30:46 UTC