image position is lost when converting from html to EditorState
Nobody has claimed this yet.
- Dominant language
- HTML
- Stars
- 163
- Forks
- 104
- PR merge metrics
- No merged PRs in 30d
Description
when saving the image in react-draft-wysiwyg I get the following output as html:
<div style="text-align:right;"><img src="srcHere" alt="" style="height: auto;width: auto"/></div>
after converting this back to the EditorState and logging out html again I receive:
<p style="text-align:right;"></p> <img src="srcHere" alt="" style="height: auto;width: auto"/>
The image position is lost and wrapping div is converted into adjacent empty p element with same styling as div.
the code that converts the html back to EditorState:
...
const contentBlock = htmlToDraft(fieldHtml);
const contentState = ContentState.createFromBlockArray(contentBlock.contentBlocks);
return EditorState.createWithContent(contentState);
I imagine this might be similar if not the same issue as #98
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 with the htmlToDraft conversion path shown in the report and reproduce it using the supplied div and image HTML. Inspect how the conversion handles a styled div containing an image, then verify that converting to ContentState and back preserves the image alignment without creating an empty adjacent paragraph.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- html, javascript, react
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100