Open sstur opened 8 years ago
I don't think this is a bug, since the current behavior is what most users will expect. The Draft.js team at Facebook chose this behavior, since most text editors (such as Microsoft Word and Pages) use it as well.
I suggest adding an optional resetOnNewline
setting that defaults to the current behavior.
I've found this is what some users expect but others expect the opposite. Especially with some inline styles, like code/monospace, users expect insertion of a new block to signify they are done writing that snippet of code.
In my own research, I've found that editors who treat a return more like a line break (Word, Pages, Draft demo) do not tend to reset inline styles. But editors which have clear paragraph blocks, like Quip, give you a fresh start when you start a fresh block. When using Quip users find this behavior intuitive, but admittedly this is far less common than the MSWord behavior.
It sounds reasonable to make an option for this, but I'd like, by default, to reset inline styles for a new block for a few reasons:
From a technical standpoint, I've checked into it and there are some complications that will make this a little difficult to solve. But I do think solving it is the right thing to do.
I must say you make a compelling argument, and I personally find the reset on newline behavior preferable.
FYI: There has been some discussion on this topic in the Draft.js repo as well, where somebody suggested using a handleReturn
prop function.
If you set bold/italic/etc, type some text and then press enter to start a new paragraph, the style should be back to normal in the new block.
Thanks to @codesoda for noticing this bug.