Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

(Biased React dev here.)

The key insight in Draft.js is that it's incredibly difficult to keep your model in sync with the browser's contenteditable behavior unless you intercept many of the behaviors and perform them entirely in the model, then change the DOM accordingly. Medium found the same thing when building their editor:

https://medium.com/medium-eng/why-contenteditable-is-terribl...

In order to build high-quality text editors, you need to be in control of what's happening in the DOM. There's obviously many ways to control the DOM. React is a solid base for this, as are many other libraries. Facebook uses React extensively so it made sense to use as a base for Draft to avoid needing to essentially rewrite React and to make it even easier to integrate with existing React apps. Of course, you can also use Draft easily inside a non-React app.

The entire Draft model is also separate code decoupled from the UI and you're free to use the model and implement the views yourself if you're allergic to React or aren't targeting the DOM. The Facebook Groups app uses Draft's model but implements custom views for it in React Native.



(Biased Quill author here)

Most modern rich text editors have or are moving towards having a document model that maps to the DOM, ideally also producing compact and canonical output. Quill's new document model Parchment takes this approach as well though I admit I borrowed the idea from the Etherpad guys, and some design ideas from React as well [1]. I have not had the time to dig into Draft.js in depth but Facebook has made many high quality contributions to open source and looking forward to borrowing more ideas.

[1] http://quilljs.com/blog/the-road-to-1-0/


Any chance that react native view code will be released at any point? Would be so useful!


Good idea. It's based off of an older version of the Draft code so it might not work out of the box. If we don't get a chance, hopefully it won't be hard for people to build out a solid implementation on RN.


I am extesively using the polymer webcomponents framework, do I need to install react in the background or can I use draft.js independently?


You'll have to use ReactJS as it's needed to have the control over the DOM.




Consider applying for YC's Fall 2026 batch! Applications are open till July 27.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: