Proposal: Add "files" attribute to dataTransfer object

I'm talking focused on "WYSIWYG" environments, although some of the
ideas might be useful in other apps. I might talk about onPaste or
onDrop, and I mean any one of those events as it's basically getting
outside content into the page.

The current definition for the dataTransfer that it's available when
some content is pasted into a web page is missing at least one
functionality that always makes users realize that they are using a
web page and not a desktop application: they can't copy and paste any
content from another program and automatically include those images,
they can't drop some files from their file manager into their editor
and get that file correctly placed on the server and linked/displayed.

That could be made possible if the dataTransfer object included an
attribute "files", so it behaves like an "invisible input type=file"
element has been added and its content are the files corresponding to
what is being pasted.

The process would be:
1 the html editing widget set an onPaste listener,
2 when the event is raised, it gets the text/html content of the
dataTransfer, and any associated file.
3 the files are automatically sent to the server with any kind of ajax
method, and the url for those files are returned to the widget
4 meanwhile the widget has processed the pasted content (with any kind
of filtering like cleaning of conditional comments, <o:> tags...) and
has inserted it in the correct place
5 when the final url for the uploaded files are know the widget
replaces the source attribute of images or href of links that were in
the original content.

The user is happy because he just used copy and paste like in any
other program and everything worked automatically.

Further refinements:
if the content of the clipboard is just an image (eg: screenshot),
then provide an option to get that content as an image file (not only
raw data), being able to choose between png and jpg.

FileList interface:
http://dev.w3.org/2006/webapi/FileUpload/publish/FileUpload.html#FileList-if

dataTransfer interface:
http://www.whatwg.org/specs/web-apps/current-work/multipage/editing.html#datatransfer

Received on Tuesday, 21 April 2009 21:56:21 UTC