Draft.js is a framework for building rich text editors in React, powered by an immutable model and abstracting over cross-browser differences.
Draft.js allows you to build any type of rich text input, whether you're only looking to support a few inline text styles or building a complex text editor for composing long-form articles.
Draft.js was introduced at React.js Conf in February 2016.
Draft.js is distributed via npm. It depends on React and React DOM which must also be installed.
Draft.js uses some modern ECMAScript features which are not available to IE11 and not part of create-react-app's default babel config. If you're running into problems out-of-the-box try installing a shim or polyfill alongside Draft.
Learn more about using a shim with Draft.
API Changes Notice
Before getting started, please be aware that we recently changed the API of
Entity storage in Draft. The latest version,
v0.10.0, supports both the old
and new API. Following that up will be
v0.11.0 which will remove the old API.
If you are interested in helping out, or tracking the progress, please follow
Since the release of React 16.8, you can use Hooks as a way to work with
EditorState without using a class.
Because Draft.js supports unicode, you must have the following meta tag in the
<head></head> block of your HTML file:
Draft.css should be included when rendering the editor. Learn more about why.
Next, let's go into the basics of the API and learn what else you can do with Draft.js.