Blocks encoding in entityToHTML
See original GitHub issueI was wondering why a ENTITY_MAP
is used to convert text in entities, here https://github.com/HubSpot/draft-convert/blob/master/src/encodeBlock.js#L4 ?
Because this is what is happening when using a entityToHTML
function to transform links into real <a>
:
Editor:

Result after convertToHTML
:

Only because it’s in a entity
(a link).
Why?
Do I have to use a decoder on originalText
to display the original text?
Issue Analytics
- State:
- Created 7 years ago
- Reactions:3
- Comments:8
Top Results From Across the Web
ContentBlock - Draft.js
ContentBlock objects are largely analogous to block-level HTML elements ... This is how we encode styles and entities for a given block.
Read more >Advanced Features - * arachnoid.com
When invoked as [FileEncoding:UTF-8], this command will change subsequent file operations to use the UTF-8 (full Unicode support) chartacter set. When invoked ...
Read more >HTML Entities - W3Schools
... can be used in combination with alphanumeric characters to produce a character that is not present in the character set (encoding) used...
Read more >How to use the draft-convert.convertToHTML function in ... - Snyk
To help you get started, we've selected a few draft-convert.convertToHTML examples, based on popular ways it is used in public projects.
Read more >medium-draft @ 0.5.12 .. 0.5.13 - Package Diff
createElement("div",{className:"md-block-code-container"})};default:return null}},s=t.entityToHTML=function(e,t){return e.type===a.Entity.LINK?l.default.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Ahh I see. Interesting, thanks for bearing with me @jebarjonet. Are you using the same code that you posted above when converting to HTML? The first thing that came to mind as the culprit was using
ReactElement
s to render out the HTML like this:Since React automatically escapes text nodes. However the example you posted above uses a string to convert, which I cannot reproduce the issue with. Additionally returning an empty
ReactElement
avoids the problem:The first example I can fix, but there should be some already available workarounds in the meanwhile.
You are right. It works well with
and
Thank you!
I just does not work well with