
Explore how editor state and content state objects organize Draft.js content, including the editor contents and two selection states before and after rendering, and how they are used.
Install draft.js for a React project using npm, add it to the project, and verify it in package.json, then prepare to use draft.js in the app.
Create a Draft.js editor in a React app by building an editor component, importing editor and editorState, and wiring an onChange handler. Render hello world and add rich style features.
Add rich text utilities to the editor by implementing a handle key command that uses a utility library to apply bold, italic, and underline through editor state updates.
Learn to save and load rich text editor content in a React with Draft.js app using local storage, and optionally via a REST API to a database.
Learn to load saved editor content from local storage into a draft.js editor by deserializing raw data with convertFromRaw, converting to content state, and creating an editor state.
Display saved contents as HTML in a React Draft.js editor using dangerouslySetInnerHTML. This approach is not recommended due to cross-site scripting risks and potential security exposure.
Use a read-only draft.js editor to display saved content as static text, loading content from local storage into an editor state and rendering it without edit controls.
Learn to implement rich text editing features in a React application using Draft.js, and check out the author's blog for tutorials on React and other web development topics.
In this course we will go through how to add rich text editing features (such as bold, underline, italic) to your React application, using an open source framework called Draft.js.
You will learn
How to add rich text editor component to your React application
How to add features like bold and underline to the editor
How to save rich text content to database
How to load rich text content from database
How to edit saved content
How to display saved rich text content e.g. as HTML
Prior knowledge of rich text editing and Draft.js is NOT required. Basic knowledge on React is however required because we will be concentrating on Draft.js features.