This is a good scenario, but I'm not sure if this can be solved using the current design. You probably want a promise to the ClipboardItem? Also, I think the MIME type in the Clipboarditem is only useful when we are specifying DOMString instead of Blobs, which is currently not supported in Chromium. If we create a Blob after the data has been populated, then we can probably just use the MIME type from the Blob during the clipboard write operation. This feature can be implemented just like the promises to blobs without breaking the sites that use ClipboardItem instead of promises to ClipboardItem, so we should definitely consider adding this to the async clipboard API in the future. The promises to Blobs feature unblocks some of the key scenarios in Excel online as well as scenarios where a promise to the Blob helps in creating the Blob asynchronously without losing the transient user activation delay, so I think this feature will still be useful even if we implement promise to ClipboardItem.
-Anupam On Tue, Nov 2, 2021 at 1:23 AM 'Thomas Steiner' via blink-dev < blink-dev@chromium.org> wrote: > One problem with async blob creation I ran into is dynamically created > blobs of unknown type: > > navigator.clipboard.write([ > new ClipboardItem({ > 'foo/bar': new Promise(async (resolve) => { > // Obtain blob data somehow, the type `foo/bar` will be dynamic. > resolve(new Blob([data], { type: 'foo/bar' })); > }), > }), > ]); > > You need to know `foo/bar` for passing it to `ClipboardItem`, but it may > only be available after the data has been created. Since Safari and Chrome > expire user gestures differently (see > https://bugs.webkit.org/show_bug.cgi?id=222262#c5), this renders some > copy use cases currently impossible. > > -- > You received this message because you are subscribed to the Google Groups > "blink-dev" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to blink-dev+unsubscr...@chromium.org. > To view this discussion on the web visit > https://groups.google.com/a/chromium.org/d/msgid/blink-dev/CALgRrLk728Y92SKX%2BEw0mPC_OhTkGqU9geyC%3D70gn4%2BGPPskkA%40mail.gmail.com > <https://groups.google.com/a/chromium.org/d/msgid/blink-dev/CALgRrLk728Y92SKX%2BEw0mPC_OhTkGqU9geyC%3D70gn4%2BGPPskkA%40mail.gmail.com?utm_medium=email&utm_source=footer> > . > -- You received this message because you are subscribed to the Google Groups "blink-dev" group. To unsubscribe from this group and stop receiving emails from it, send an email to blink-dev+unsubscr...@chromium.org. To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/blink-dev/CA%2Bm%3DdJpTbgfmvZd6zvLyu90jrr0tRdKpacBjT%3DsQ6KFT-%2BNhDQ%40mail.gmail.com.