Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

convertToHTML throws for "code-block" #182

Closed
pwlmaciejewski opened this issue Jan 15, 2021 · 4 comments · Fixed by #195
Closed

convertToHTML throws for "code-block" #182

pwlmaciejewski opened this issue Jan 15, 2021 · 4 comments · Fixed by #195

Comments

@pwlmaciejewski
Copy link

Description

convertToHTML throws convertToHTML: missing HTML definition for block with type code-block error when ContentState block type is code-block.

It's a confusing behavior given that convertFromHTML will convert <pre> tags to code-blocks from the HTML input: https://github.com/HubSpot/draft-convert/blob/master/src/convertFromHTML.js#L185

Steps to reproduce

convertToHTML(convertFromHTML("<pre>Foo</pre>"))

Demo: https://codesandbox.io/s/draft-convert-missing-html-definition-for-block-with-type-code-block-54nt4?file=/src/App.js

Notes

Adding 'code-block': <pre /> to the default blocks (https://github.com/HubSpot/draft-convert/blob/master/src/default/defaultBlockHTML.js#L6) should fix the issue.

@MudulOzan
Copy link

Issue still exists

@benbriggs
Copy link
Contributor

fixed in 2.1.12, sorry for the delay!

@Gtes
Copy link

Gtes commented May 12, 2022

Got the same problem while trying to use 2.1.12 with react-draft-wysiwyg

Demo
https://codesandbox.io/s/crimson-sun-fle8vr?file=/src/App.js

@khalilabid95
Copy link

Got the same problem using "draft-convert": "^2.1.13"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants