-
Notifications
You must be signed in to change notification settings - Fork 21
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
Nested inline style configuration question #136
Comments
Hey @drxcheng, good question. This is how the exporter is intended to work, is this output causing any issues for you? I haven’t looked at this in a while but from what I recall the current implementation is because Draft.js allows inline style ranges to partially overlap, so converting style ranges to HTML can’t be as simple as mapping single ranges to single tags. For example in a case like: {
"text": "Bold Both Italic",
"type": "unstyled",
"inlineStyleRanges": [
{
"offset": 0,
"length": 10,
"style": "BOLD"
},
{
"offset": 5,
"length": 11,
"style": "ITALIC"
}
]
} This is even more important when style ranges overlap with entity ranges, since a given entity should always map to a single HTML tag – so style tags have to be split like the exporter does. The case you provide where we could shorten the output didn’t feel worthwhile to implement differently. |
Thanks for the reply. It is currently causing me some minor issue because another library (https://github.com/niuware/mui-rte) behaves differently. I honestly don't know what's the expected behaviour. Feel free to close the ticket if you think it's not an issue. |
👍 thank you for the extra details. I think it would be cool to change the implementation to use the representation you suggest when the ranges are strictly nested rather than overlapping, since admittedly the HTML is much more elegant like that. I’m not entirely sure how much work that would be so won’t commit to it myself for now, but for future reference the logic is around here: draftjs_exporter/draftjs_exporter/html.py Lines 118 to 126 in 2ec7b82
Commentary mostly for my future benefit: |
I have this block
I expect it to render HTML as
but it renders HTML as
Is it a bug or is there any configuration?
The text was updated successfully, but these errors were encountered: