facebookarchive / draft-js

A React framework for building text editors.
https://draftjs.org/
MIT License
22.56k stars 2.63k forks source link

`splitTextIntoTextBlocks` should adhere to Unicode standard #1334

Open eelco opened 7 years ago

eelco commented 7 years ago

When pasting text with line-separators (U+2028), it’s not split.

Example (copy from here):

aap
noot
mies

Expected when pasting

aap noot mies

Unicode line breaking algorithm: http://www.unicode.org/reports/tr14/tr14-32.html#Algorithm

Suggested fix: Change NEWLINE_REGEX to

var NEWLINE_REGEX = /\r\n?|\n|\u000C|\u000B|\u0085|\u2028|\u2029/g;

Demo: https://jsfiddle.net/wpsper15/

flarnie commented 7 years ago

Thanks for reporting this! Seems reasonable to me, I'd like to look at our uses and see if there is any reason it was not done in the first place. I'm guessing it was just an oversight though.