- From: Lucas Garron <notifications@github.com>
- Date: Fri, 26 Jun 2020 16:11:21 -0700
- To: w3c/clipboard-apis <clipboard-apis@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
Received on Friday, 26 June 2020 23:11:33 UTC
I think there are a few reasonable options: - Return which data types were copied, e.g. give `write()` a return type of `Promise<Array<{[type: string]: boolean}>>`. - Specify that the browser should error. - Specify that the browser should ignore it. It would also be useful if there was a way to query for supported types (#67), especially in the last case. ---------- Consider the following snippet: document.body.addEventListener("click", async function() { console.log("copying!"); const item = new ClipboardItem({ "food/falafel": new Blob(["\uD83E\uDDC6"], { type: "food/falafel" }) }); await navigator.clipboard.write([item]); console.log("copied!"); }); Chrome throws an error: <img width="490" alt="Screen Shot 2020-06-26 at 16 05 17" src="https://user-images.githubusercontent.com/248078/85907585-d731e380-b7c6-11ea-8953-82846246ab11.png"> Safari resolves the Promise without an error. <img width="534" alt="Screen Shot 2020-06-26 at 16 05 57" src="https://user-images.githubusercontent.com/248078/85907628-ef096780-b7c6-11ea-8b6b-ac59478705b9.png"> Note that since the return type is `Promise<void>`, there is no other way (in general) to check that the copy operation succeeded. -- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/w3c/clipboard-apis/issues/128
Received on Friday, 26 June 2020 23:11:33 UTC