Closed judemanutd closed 5 years ago
The stateFromHTML function takes an option object as second parameter where you can define elementStyles to support <sup>
tags like the following:
const contentState = stateFromHTML(data, {
elementStyles: {
// Support `<sup>` (superscript) inline element:
'sup': 'SUPERSCRIPT',
},
});
Had the same problem and found the solution here: https://www.npmjs.com/package/draft-js-import-element (Also it's another plugin, the stateFromHTML function from draft-js-import-html also takes the option object as second param.)
Library version :
1.3.0
React :16.8.1
React Dom :16.8.1
Input given
Expected output
Actual Output
Displays as a normal string
The other tags are being picked up such as H1, H2 etc so they render fine, it's just
<sup>
and<sub>
that don't seem to be rendering in the editor.