jpuri / jpuri/html-to-draftjs

img with span problem

Open
#63 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
HTML
Stars
163
Forks
104
PR merge metrics
No merged PRs in 30d

Description

   const blocksFromHtml = htmlToDraft(this.props.value);
    const { contentBlocks, entityMap } = blocksFromHtml;
    const contentState = ContentState.createFromBlockArray(contentBlocks, entityMap);
    const editorState = EditorState.createWithContent(contentState);
    this.state = {
      editorState,
      loading: false
    };
<Editor editorState={this.state.editorState} defaultEditorState={this.state.editorState}/>

here props value just is img tag with src

it will throw an error Unknown DraftEntity key: null.

why ????

and if i pass

<p></p>
<img src="..."/>

it will work

and if i pass

<p></p>
<img src="..."/>
<span>it will invisible or miss in editor<span>

// or

<p></p>
<img src="..."/>it will invisible or miss in editor

it will invisible all the element after img tag

Hope to get the answer

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the issue through htmlToDraft, ContentState.createFromBlockArray, and the Editor component using the HTML examples in the report. Trace the img handling and verify that an image followed by a span or later content neither raises the Unknown DraftEntity key error nor hides the following elements.

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
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.