[clipboard-apis] Non Recognizable formats (#9)

Currently there is no mechanism for a web app to use the clipboard to interface with a native application that uses a format not recognized by the browser.

Many (most?) native applications use custom formats that allow them to copy and paste rich featured content either within the application or across to other applications (think MS Office figures or the case I'm interested in MathCad formulas)

It's likely that many of these formats will never be mime-typed, especially for small applications and even if they were, browsers would have to be able to recognize the format in order to present it to the web app. Given the shear number of native applications and their custom formats, this problem should be passed on to the web developer who wants to develop an interface with one application, and thus only has to understand that application to write the code.

Web applications could submit their own mappings for use on that page. For example, Mathcad uses 13 different registered formats on windows. So a web app wanted to use 2 of those formats it could call a function:

```javascript
registerClipboardFormats({
   "application/vnd.mathsoft.equation+xml":[
        "XMCD Format", //Windows handle
        "XMCD_FORMAT", //Linux handle
        "com.mathsoft.xml"], // OSX handle
   "application/vnd.mathsoft.equation.meta+xml":[
        "Provenance Data", //windows handle
        "PROVENANCE_DATA", //Linux handle
        "com.mathsoft.pd"] // OSX handle
});
//returns:
//{
//   "application/vnd.mathsoft.equation+xml":true,
//   "application/vnd.mathsoft.equation.meta+xml":true
//}
```

Then whenever any of the OS handles are on the clipboard during a paste event those objects could be exposed via the mime-type listed. Additionally, during a copy event if one of the newly registered mime-types is set, then the browser could look to see if any of the OS handles given are registered, and those that are could be set to the data provided.

This custom registration would allow small applications to have their datatypes be recognized in a cross platform way. The only additional coding required to support more operating systems would be to add the handle name (a five minute job). Browsers could even collect and use this page specific registered data to augment the default registered datatypes if they so desired.

An additional benefit of this custom registration is that the currently undefined behavior about registering custom formats could be sidestepped by only setting formats that have already been registered by other applications. The registration function could even provide feedback as to which formats found an already registered format and which were effectively rejected. This would allow developers to notify the user that they might need to copy something with the native app and then retry. Then the web app could try to register the formats again after the native app had done the registration. This would prevent every website from registering their own formats on the native clipboard potentially maxing out the number of registration slots on windows.

---
Reply to this email directly or view it on GitHub:
https://github.com/w3c/clipboard-apis/issues/9

Received on Monday, 1 June 2015 15:34:16 UTC