Re: [clipboard events] seeking implementor feedback on using CID: URI scheme for pasting embedded binary data

>> Of course it would be nice to support a script that wants to generate random HTML with embedded files 
>> use case for example with a CANVAS app where the script wants to copy the state of the CANVAS 

> I was thinking about images that aren't available cross-domain

Indeed, that's another use case which is pretty important.

>> document.addEventListener('copy', function(e){
>> // So, you want to copy the current status of your game? No problem.
>> // Let's say this game generates a number of PNG graphics from CANVAS tags
>> // and keeps them in memory in ArrayBuffers or something
>> var html = '<div><b>player</b>\'s medals: <img src="cid:1"><img src="cid:2"></div>';
>> e.clipboardData.items.add(html, 'text/html');
>> e.clipboardData.items.add(new File(medals[0], 'medal.png', {type:'image/png'}));
>> e.clipboardData.items.add(new File(medals[1], 'medal.png', {type:'image/png'}));
>> e.preventDefault();
>> }, false);

> This seems like we're depending on add() working in a precise order, which seems vulnerable
> to code changes or other issues. Maybe add() should return the location in the list where
> the item was added, and then it can be used with CID more safely?

That is a good observation and a very good suggestion! We should suggest a change to the HTML spec.

>>> Second, can you provide the javascript for how a site would put them into the pasted markup during paste?

>> The way I thought this would work, would be that the site starts XHR uploads from the paste processing,
>> and shows some intermediate 'loading' animation or something before it gets the final URLs back from the server.

> This generally makes sense. If sites prefer to use local dataURI or blob, they can use the blob URL, and then
> upload the file later (like in an email scenario). This means they don't have to wait for them to be on the
> server before displaying them. If they want to upload them first and use the server's new URL for them,
> they would need to do what you're saying.

Sounds good, but this requires standardising something similar to msConvertURL(), right?


Received on Friday, 28 February 2014 04:46:37 UTC