- From: Thomas Steiner <notifications@github.com>
- Date: Wed, 16 Feb 2022 13:35:48 -0800
- To: w3c/clipboard-apis <clipboard-apis@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
Received on Wednesday, 16 February 2022 21:36:00 UTC
> Just curious, why can't the author enumerate the `types` after the read operation to see if a particular format is available or not? That way you don't have to add special code for this feature. Here is a sample code (mentioned in the explainer): > > ``` > const item = items[0] > if (item.types.includes("web text/custom")) { > // prefer this web app's custom markup if available > const custom_markup = await (await clipboardItem.getType("web text/custom")).text() > // process the custom markup... > } > else if (types.includes("web text/html")) { > // native apps may write "web text/html" in addition to "text/html", prefer it > const html = await (await clipboardItem.getType("web text/html")).text(); > // process the html... > } > else if (types.includes("text/html")) { > // process html if available > const html = await (await clipboardItem.getType("text/html")).text(); > // process the html... > } > ``` Just to be sure, this is about _writing_ to the clipboard. See my [sample code](https://github.com/tomayac/SVGcode/blob/b29b27dadf2cf3c8aefb77e2c3db9feb0872d91d/src/js/clipboard.js#L64-L136) and the comments. -- Reply to this email directly or view it on GitHub: https://github.com/w3c/clipboard-apis/issues/165#issuecomment-1042332210 You are receiving this because you are subscribed to this thread. Message ID: <w3c/clipboard-apis/issues/165/1042332210@github.com>
Received on Wednesday, 16 February 2022 21:36:00 UTC