fbjs icon indicating copy to clipboard operation
fbjs copied to clipboard

DataTransfer.getHTML() should not return text

Open robbertbrak opened this issue 8 years ago • 3 comments

In https://github.com/facebook/fbjs/blob/master/packages/fbjs/src/datatransfer/DataTransfer.js#L97, getHTML is returning the 'Text' data from the clipboard (dataTransfer), but this seems incorrect to me. Presumably this is done for IE, which does not support the text/html content type, but it is rather misleading to have getHTML return plain text rather than HTML.

In Draft.js, this leads to subtle bugs such as https://github.com/facebook/draft-js/issues/656.

Do you agree this is something that should be fixed?

robbertbrak avatar Oct 08 '16 16:10 robbertbrak

@zpao, maybe you could find the time to comment on this?

robbertbrak avatar Nov 28 '16 08:11 robbertbrak

I just hit this today.

There's already getText() for a reason.

intentionally-left-nil avatar Feb 01 '17 07:02 intentionally-left-nil

I think the problem here is that DataTransfer.getText() is not handling IE's 'text' type correctly. It's just checking on the length of the this.types array, whilst in IE11 the types array does contain the 'text' data using "Text". So it should rather do this:

if (!this.types.length || this.types.indexOf('Text') != -1) {
    text = this.data.getData('Text');
}

I tested it only on IE11 and seems to be working fine.

NicolaMagnabosco avatar Mar 31 '17 15:03 NicolaMagnabosco