Here is what i do on saving content to db: const contentState = () Ĭonst data = JSON.stringify(raw, null, 2) Īfter this, I am passing data to API. Default Block Render Map is how Draft.js renders HTML by default. You can see that in the JSFiddle I provided, the data-texttrue class is present.
DraftEditorTextNode is what renders text.
I can save the mentions in my database using rest API. DraftEditorContents is the wrapper for all rendering. So far i am able to create the editor and creating the mention tags. Immutable Editor State The Draft.js model is built with immutable-js, offering an API with functional state updates and aggressively leveraging data persistence for scalable memory usage. 19: isListBlock: ContentBlock: boolean: The function will return true is type of block is 'unordered-list-item' or 'ordered-list-item'. Draft.js fits seamlessly into React applications, abstracting away the details of rendering, selection, and input behavior with a familiar declarative API. I am implementing React's "draft js" with mention plugin. The function will handle newline event in editor gracefully, it will insert for soft-new lines and remove selected text if any.