Because a text editor doesn't exist in a vacuum and it's important to save
contents for storage or transmission, you will want to be able to
ContentState into raw JS, and vice versa.
To that end, we provide a couple of utility functions that allow you to perform these conversions.
The Flow type
denotes the expected structure of the raw format of the contents. The raw state
contains a list of content blocks, as well as a map of all relevant entity
Given a raw state, convert it to a
ContentState. This is useful when
restoring contents to use within a Draft editor.
ContentState object, convert it to a raw JS structure. This is useful
when saving an editor state for storage, conversion to other formats, or
other usage within an application.
Given an HTML fragment, convert it to an object with two keys; one holding the
ContentBlock objects, and the other holding a reference to the
entityMap. Construct content state from the array of block elements and the
entityMap, and then update the editor state with it. Full example available