0
0
mirror of https://github.com/wagtail/wagtail.git synced 2024-12-01 11:41:20 +01:00

Return null for empty content, rather than adding a dummy block

This commit is contained in:
Matt Westcott 2018-01-18 16:00:40 +00:00
parent e690e95503
commit 5928662b95

View File

@ -85,8 +85,8 @@ class ContentstateConverter():
self.html_to_contentstate_handler.feed(html)
if not self.html_to_contentstate_handler.contentstate.blocks:
# add an empty paragraph block to make contentstate valid
self.html_to_contentstate_handler.add_block(Block('unstyled', depth=0))
# Draftail does not accept an empty block list as valid, but does accept 'null' as meaning "no content"
return 'null'
return self.html_to_contentstate_handler.contentstate.as_json(indent=4, separators=(',', ': '))