Skip to content

image position is lost when converting from html to EditorState #101

@Sergej-Vlasov

Description

@Sergej-Vlasov

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions