Changes between Initial Version and Version 1 of Ticket #11526, comment 2


Ignore:
Timestamp:
Feb 3, 2014, 4:31:13 PM (11 years ago)
Author:
Piotr Jasiun
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #11526, comment 2

    initial v1  
    11= W3C Documentation =
    22
    3 Both drop and paste events can contain ​DataTransfer object which is most important for us. Basically it a list of items. Every item can be a file or a string data in certain type. Data type might be MIME types but it is not necessary. Theoretically it is possible to have mixed files and string data. I wrote "theoretically", because it is not defined how such data should be thread:
     3Both drop and paste events can contain [http://www.w3.org/TR/html5/editing.html#datatransfer DataTransfer] object which is most important for us.
     4 - in `copy`, `paste` etc. events as `evt.clipboardData`,
     5 - in `dragstart`, `drop` etc. events as `evt.dataTransfer`.
    46
    5 if you drop file you will get two items, both of them are "file", so they are two part of data,
    6 if you drop html you can get also two items, both of them are strings: one in text/html type, second one in text/plain, so this is the same data in two format (this is what we get in Chrome).
    7 Specification does not said if data should be thread as a one piece of data in multiple format of multiple pieces of data. It depend on data. The only information we get is: "The drag data store item list is ordered in the order that the items were added to the list; most recently added last.".
     7DataTransfer object support both old and new API.
    88
    9 DataTransfer support also old interface with separate list of file and list of string data in types (IMHO old interface is cleaner).
     9== New API ==
    1010
    11 There are also a lot of cool features like drag icon or droparea which allows only defined types to be drop. One more good new is that there are both asynchronous and synchronous FileReader to read dropped file.
     11Basically it a list of items (`dataTransfer.items`). Every item can be a file or a string data in certain type. Data type might be MIME types but it is not necessary. Theoretically it is possible to have mixed files and string data. I wrote "theoretically", because it is not defined how such data should be thread:
     12  - if you drop file you will get two items, both of them are "file", so they are two part of data,
     13  - if you drop html you can get also two items, both of them are strings: one in text/html type, second one in text/plain, so this is the same data in two format (this is what we get in Blink).
     14Specification does not said if data should be thread as a one piece of data in multiple formats of multiple pieces of data. It depend on data. The only information we get is: "The drag data store item list is ordered in the order that the items were added to the list; most recently added last.".
     15
     16Blink is now the only engine which support new API for now.
     17
     18== Old API ==
     19
     20Old API is move complex. DataTransfer contains:
     21
     22  - `types` - array of string ex. ['plain/text','plain/html'] or ['Files'],
     23  - `files` - array of files, if files array contains any element then `types` contains 'Files' element,
     24  - `getData(format)` - get string data, format is a string type from `types` array,
     25  - `setData(format, data)` - set data by format.
     26  - `clearData(optional format)` - remove data.
     27
     28Old API works together with the new one so there are two ways to get data from DataTransfer object.
     29
     30[http://msdn.microsoft.com/en-us/library/ie/ms535861(v=vs.85).aspx IE support only "Text" and "URL" types].
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy