# html-to-draftjs **Repository Path**: mirrors_geosolutions-it/html-to-draftjs ## Basic Information - **Project Name**: html-to-draftjs - **Description**: No description available - **Primary Language**: Unknown - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2020-09-16 - **Last Updated**: 2026-04-18 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # HTML To DraftJS A library for converting plain HTML to DraftJS Editor content. Build for use with **[react-draft-wysiwyg](https://github.com/jpuri/react-draft-wysiwyg)**. ## Installation ``` npm install html-to-draftjs --save ``` ## Usage ``` import { EditorState, ContentState } from 'draft-js'; import htmlToDraft from 'html-to-draftjs'; const blocksFromHtml = htmlToDraft(this.props.content); const { contentBlocks, entityMap } = blocksFromHtml; const contentState = ContentState.createFromBlockArray(contentBlocks, entityMap); const editorState = EditorState.createWithContent(contentState); ``` ### (optional) customChunkRenderer Use to define additional html nodes. Only supports atomic blocks. * _nodeName: string_ - the name of the node, in lowercase * _node: HTMLElement_ - the parsed node itself This renderer function is executed before any other html to draft conversion. Return nothing (or something falsy) to continue with the normal translation. Example: ``` htmlToDraft('