Draft-js: Handle pasted text to create entities

Created on 11 Mar 2016  路  6Comments  路  Source: facebook/draft-js

Hello

While pasting the content, we can get the pasted content in onPasteRawText but then again editOnPaste handles the pasted data. My usecase is something like this:

I have a input where when a user types a comma separated values, I convert them into entities(immutable) and decorate them to look like this which I have done.

screen shot 2016-03-11 at 7 17 08 pm

But the same steps need to be done to the pasted data. I might be missing something on how to handle the pasted data.

Any help would be appreciated.

Thanks

enhancement

Most helpful comment

Found an example of handlePastedText for anyone searching in the future: https://github.com/facebook/draft-js/issues/416#issuecomment-221639163

All 6 comments

Hmm. onPasteRawText could possibly be a canceling handler, i.e. handlePastedText. Then you would be able to return true if you handle the paste yourself.

Yes. Something like handleBeforeInput is a cancelling event.

I would be fine with this. Would you like to submit a PR to replace onPasteRawText with handlePastedText?

Sure. I will do the changes and submit the PR.

@hingermayank thanks for adding handlePastedText. Are there are any examples of how to use it? The docs are a little sparse...

Found an example of handlePastedText for anyone searching in the future: https://github.com/facebook/draft-js/issues/416#issuecomment-221639163

Was this page helpful?
0 / 5 - 0 ratings

Related issues

sarawinter picture sarawinter  路  3Comments

abeq picture abeq  路  3Comments

darklightblue picture darklightblue  路  3Comments

ufo22940268 picture ufo22940268  路  3Comments

ktjd123 picture ktjd123  路  3Comments