- From: Edgar Chen <notifications@github.com>
- Date: Tue, 07 Jun 2022 02:40:08 -0700
- To: w3c/clipboard-apis <clipboard-apis@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
- Message-ID: <w3c/clipboard-apis/pull/175/c1148437953@github.com>
> The web custom types are stored inside a JSON map structure, with fixed number of native web clipboard formats, and a well-defined format structure that helps the native apps parse the content of the format.
@snianu We could also write arbitrary type with "web" prefix via legacy API, e.g.
```javascript
document.addEventListener("copy", function(e) {
e.preventDefault();
let clipboardData = e.clipboardData;
clipboardData.setData("web text/foo", "foo");
clipboardData.setData("text/bar", "bar");
});
```
I would expect the type with "web" prefix to follow the well-defined format/structure, too. So it could be interop with async clipobard API/browsers/native apps. for example, if we write the data into clipboard via above example and read clipboard data via async clipboard API
```javascript
const items = await navigator.clipboard.read();
items[0].getType("web text/foo"); // get "foo"
items[0].getType("text/bar"); // promise reject
```
(and vice versa)
Yes, this introduce a behavior changes in legacy API, but I think this also make web custom type less surprise to user? And the impact in legacy API should be small?
--
Reply to this email directly or view it on GitHub:
https://github.com/w3c/clipboard-apis/pull/175#issuecomment-1148437953
You are receiving this because you are subscribed to this thread.
Message ID: <w3c/clipboard-apis/pull/175/c1148437953@github.com>
Received on Tuesday, 7 June 2022 09:40:20 UTC