clipboard-apis
clipboard-apis copied to clipboard
Does write() take ClipboardItem or ClipboardItems?
The IDL specifies that write()
takes ClipboardItems
, but all the examples I've seen take a single ClipboardItem
.
Related to this: why do read()
/write()
take/return multiple ClipboardItem
s, when each ClipboardItem
may contain may contain multiple types?
Shouldn't either exactly one ClipboardItem
with multiple types or multiple ClipboardItem
s with each having one type suffice? If not, it should be possible to provide use-cases.
What do Chrome/Safari do here?
@evilpie did you run into this?
More research about the issue lead to https://blog.tomayac.com/2020/03/20/multi-mime-type-copying-with-the-async-clipboard-api/#copying-an-image, which links to https://support.microsoft.com/en-us/topic/copy-and-paste-using-the-office-clipboard-714a72af-1ad4-450f-8708-c2931e73ec8a?ui=en-us&rs=en-us&ad=us#ID0EAABAAA=Windows. Apparently, Microsoft Office indeed supports multiple clipboard items (up to 24). So I guess a future use-case could be copy-pasting from Microsoft Office to Office 365, that is, to the browser.
So it seems this ticket can be closed. It could be worth mentioning this use-case in the spec, though.
I think the issue in OP remains, no? That article also mentions that implementations might not do this?
Chrome (and Firefox, because there is no spec ..) only allows a single ClipboardItem to be passed to write. A zero length array will silently do nothing.
I think the issue in OP remains, no? That article also mentions that implementations might not do this?
Yes. Blink's idl interface takes multiple ClipboardItem
s, but throws an exception if multiple items are received.
If the use case given in above comment is invalid, then indeed taking only one ClipboardItem
would be simpler and hence preferable.
@gked: since you're working for Microsoft, can you please shed some light on this?
Copying multiple items where each item has multiple representation is a thing in iOS & iPadOS. e.g. you can select multiple images in Photos and copy them over to Notes and paste them all. WebKit supports this capability for both reading & writing.
Copying multiple items where each item has multiple representation is a thing in iOS & iPadOS. e.g. you can select multiple images in Photos and copy them over to Notes and paste them all. WebKit supports this capability for both reading & writing.
Thanks, that's helpful to know. So multiple ClipboardItem
s are needed. I suggest adding the iOS/iPadOS use case to the spec. Otherwise, this question might arise again.
Since there are operating systems, e.g. Ubuntu, that support multiple clipboards, it seems the spec should state that ClipboardItem
s should stem from exactly one of them. But this should be dealt with in a separate ticket.