Closed ericpai closed 6 years ago
@thibaudcolas Maybe the bug is caused by draftjs_exporter.html.build_command_groups
?
Hey @ericpai, thanks for reporting this and taking the time to provide a self-contained example.
build_command_groups
does sound like the most likely place for a bug like this. I'll investigate and hopefully get this fixed ASAP.
If you want to help out, a first step would be to add a (failing) test for this next to the one for adjacent inline styles, over at https://github.com/springload/draftjs_exporter/blob/cafdffcdeb35888882d98d6db1f0b99e417ebb3e/tests/test_exports.json#L118-L149.
@thibaudcolas I have added test cases for this issue.
Thanks @ericpai, that helps. I've had a look, wasn't able to fully figure it out just yet. From what I can see the commands grouping is correct, I think the issue is that the entity state completely resets at the "stop" command of an entity – even if another entity also just had its "start" command. I'll investigate further.
Relevant code for reference:
I think (but have yet to confirm) that the issue is the reset of the element_stack
here https://github.com/springload/draftjs_exporter/blob/cafdffcdeb35888882d98d6db1f0b99e417ebb3e/draftjs_exporter/entity_state.py#L61. The sequence of apply
of commands and rendering isn't correct in that case.
Yep, I've found the issue and a fix: when an entity is marked as complete and rendered, the entity state doesn't handle starting the rendering of another entity at the same time. All other tests pass so I think the fix is good, but I'll do a bit of refactoring to make sure the code stays understandable.
@ericpai v2.1.5 is now available on PyPI, with the fix! Thanks again for the help 🙂
Test version: v2.1.4
Test with the following code:
Actual output:
Expected output: