parse html to draft js content state
npm install html-to-draft> parse html to draft js content state

!GitHub code size in bytes
!Build Status
!module formats: cjs, and es


Tested on latest versions of Firefox, Chrome, Safari
``bash`
npm install --save html-to-draft
This package just contains one method, to convert html to draft js content state. For starters, here's all the type info you need to build custom converters.
`js
convertFromHtml(
html: string,
options?: {
parseBlock?: HTMLElement => TextBlock | AtomicBlock
parseTextFragment?: HTMLElement => TextFragment
}
)
type TextFragment = {
offset: number,
length: number,
inlineStyleRanges: ?Array
entity: ?{
type: string,
data: ?Object,
}
}
type AtomicBlock = {
type: 'atomic',
entity: ?{
type: string,
data: ?Object,
},
data: ?Object,
}
type TextBlock = {
type: ?string,
depth: ?number,
data: ?Object,
}
``
MIT © tettra
Developed by Julian Krispel