clipboard-apis icon indicating copy to clipboard operation
clipboard-apis copied to clipboard

Discoverability of custom type support

Open hallvors opened this issue 9 years ago • 2 comments

Some implementations support adding custom types on the clipboard, some do not. This is presumably a temporary state while implementations (and the spec) improve(s) - however, should there be a way to feature-detect whether custom types are supported?

Perhaps we should add ClipboardData.prototype.supportedTypes = ['text/plain', 'text/html', ... 'custom'] - or something like that?

hallvors avatar Apr 24 '16 09:04 hallvors

I wonder why one would like to detect this: isn't it just easier to always attach a custom type even if not supported ?

julienw avatar Apr 24 '16 09:04 julienw

In Wikipedia's VisualEditor we store the a clipboard key in the custom type that refers to our custom model data stored in memory. If the custom type isn't available we store this key in an empty span in the HTML type, but it is wasteful to do that the custom type is supported.

So, in general: you may want to know if you need to store your custom data in another way if extra MIME type storage is not available.

edg2s avatar Apr 24 '16 11:04 edg2s