Re: [w3c/clipboard-apis] Arbitrary clipboard types (Issue #165)

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`
```

Or maybe even better (and similar to `await BarcodeDetector.getSupportedFormats()`):

```js
await ClipboardItem.getSupportedFormats()
// `['text/plain', 'image/png', 'web']`

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/165#issuecomment-1041668421
You are receiving this because you are subscribed to this thread.

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

Received on Wednesday, 16 February 2022 15:27:52 UTC