Underline style is removed after converting HTML to DraftJS Editor content
Nobody has claimed this yet.
- Dominant language
- HTML
- Stars
- 163
- Forks
- 104
- PR merge metrics
- No merged PRs in 30d
Description
Let's say I pass this HTML:
<p><u>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</u></p>
When I convert it to DraftJS content and set it as editor state, the editor shows no trace of any underlined text. I checked if the issue is possibly with the package that I use to convert back to HTML string, but it doesn't seems like it.
Here's what I do:
`
setEditorState = (slide = this.props.editor.slide) => {
const blocksFromHTML = htmlToDraft(slide.text.text || '');
const state = blocksFromHTML.contentBlocks
? EditorState.createWithContent(
ContentState.createFromBlockArray(
blocksFromHTML.contentBlocks,
blocksFromHTML.entityMap
)
)
: createEditorStateWithText('');
return state;
};
`
Am I doing something wrong, or is there a bug with the package?
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the reported conversion with the provided HTML and the htmlToDraft entry point. Trace how inline styles are represented in the resulting DraftJS content, then verify that underlined text is preserved when the content is loaded into the editor state.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100