Gutenberg custom block: HTML does not unescape
-
I’m building some custom Gutenberg blocks and noticed a problem. I defined an attribute like so:
desc: { type: "string", source: "html", selector: "div.dishdetails__desc", },
and create the RichText editor in the edit function like so:
el( wp.editor.RichText, { className: "dishdetails__desc", tagName: "div", key: "editable", placeholder: "Type beschrijving", value: desc, onChange: function(newText) { props.setAttributes({desc: newText}); } } )
I saved it like this:
el( "div", { className: "dishdetails__desc" }, desc )
But when I output the text into the page, the html in the div doesn’t get escaped correctly. I took a look at the source. The closing tag does get escaped, but the opening one doesn’t. So for instance a
<strong>
tag will look like this: “& lt;\/strong>” (NO SPACE in between but I had to cause ironically this does get escaped)- This topic was modified 5 years, 11 months ago by .
- This topic was modified 5 years, 11 months ago by .
- This topic was modified 5 years, 11 months ago by .
- This topic was modified 5 years, 11 months ago by .
- This topic was modified 5 years, 11 months ago by .
- This topic was modified 5 years, 11 months ago by .
Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
- The topic ‘Gutenberg custom block: HTML does not unescape’ is closed to new replies.