jpuri / jpuri/draftjs-to-html

image tag src,height and width are undefined after conversion

Open
#121 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
325
Forks
139
PR merge metrics
No merged PRs in 30d

Description

What am i doing wrong?

content state:
{"blocks":[{"key":"1qgq4","text":"","type":"unstyled","depth":0,"inlineStyleRanges":[],"entityRanges":[],"data":{}},{"key":"o1rg","text":" ","type":"atomic","depth":0,"inlineStyleRanges":[],"entityRanges":[{"offset":0,"length":1,"key":0}],"data":{}},{"key":"9kv7b","text":"","type":"unstyled","depth":0,"inlineStyleRanges":[],"entityRanges":[],"data":{}}],"entityMap":{"0":{"type":"IMAGE","mutability":"IMMUTABLE","data":{"url":"https://png.pngtree.com/png-clipart/20190611/original/pngtree-wolf-logo-png-image_2306634.jpg"}}}}

after draftTohtml conversion:
img src="undefined" alt="undefined" style="height: undefined;width: undefined

Hereby a codesanbox
https://codesandbox.io/s/mui-rte-demo-forked-wn4ym6?file=/src/App.tsx

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

Start with the linked CodeSandbox and the provided Draft.js content state, then inspect how the IMAGE entity is converted by draftToHtml. Determine why the generated image attributes are undefined; done means the conversion produces the expected image HTML from this content state.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.