springload / wagtaildraftail

🐦📝🍸 Draft.js editor for Wagtail, built upon Draftail and draftjs_exporter
https://pypi.python.org/pypi/wagtaildraftail
MIT License
24 stars 3 forks source link

Change block/field default to None #32

Closed loicteixeira closed 3 years ago

loicteixeira commented 7 years ago

Currently, the default value is an empty dict which is basically an invalid content state. Therefore, the editor should return None which clearly state the lack of content.

thibaudcolas commented 7 years ago

@loicteixeira I've done the work in Draftail (#40) and the exporter (#36) to support this, and updated those two here – will leave the Django changes to you if you have the time.

thibaudcolas commented 7 years ago

I have re-added a default value of {} within this project (https://github.com/springload/wagtaildraftail/pull/42/commits/bb4b68ff9cd9c88985e58070b59184985afabe80) so that we can finish this later on.

Note that nothing needs to happen for the exporter, it will handle None or {} just the same.

loicteixeira commented 7 years ago

Sorry I didn't get time to look into this before my break.

Basically, the block use a custom form field to handle the '{}' string as empty.

Now that draftail returns None, this is not needed anymore. This can probably use the same formfield as the parent class, so there is no need for the form and validator linked above in the issue.

FWIW, it looks like DraftailTextBlock and DraftailTextField don't use the same underlying form field and this should be updated to the same (but potentially removing the overwrite on the block should do the trick).