Re:Why ContentEditable Is Terrible, Or: How the Medium Edito...
by dminor on Wednesday April 13, 2016 @10:38AM
(#11488535)
One big problem with draft.js is it doesn't play well with tools like grammarly that reach into the dom and modify it.
Medium's editor side steps this by just rerendering after each input.
Re:Why ContentEditable Is Terrible, Or: How the Medium Edito...
by underwater on Wednesday April 13, 2016 @10:56AM
(#11488686)
Draft.js does (or did at some point) have some affordances for this so that it could handle mobile devices.
Keyboards on Android Chrome used to emit keycode 0 for every character that was inserted and then mutate the DOM directly. And spelling corrections just mutated he DOM without firing events.
Re:Why ContentEditable Is Terrible, Or: How the Medium Edito...
by BasDirks on Wednesday April 13, 2016 @10:55AM
(#11488672)
There are a bunch of bugs immediately apparent. Try typing while making a selection with mouse. Is that expected behaviour? nah.
Re:Why ContentEditable Is Terrible, Or: How the Medium Edito...
by teleclimber on Wednesday April 13, 2016 @01:27PM
(#11490247)
What is the "expected behavior" for simultaneously drag-selecting text and typing? And why? And who decided that?
I've found that there are many edge cases in rich content-editing. If your general-purpose editor does something reasonable and constructive with esoteric inputs it's fine.
Draft.js appears to cancel the selection process and drops the typed character wherever the mouse happens to be. Reasonable.
I have only played with it, not used it in production, but if you are using React it could be a good solution.
The one limitation I've seen is that is doesn't really support documents that need a hierarchical model (an example of this would be tables, but also things like "I want a code block within a blockquote").
If you want to see draft.js's document model, I made a tool to do that, too[2].
[1]: https://facebook.github.io/draft-js/ [2]: http://afiedler.github.io/draft-js-dm-demo/