Report a bug
Bug GIF:

https://codesandbox.io/s/slate-reproductions-cm3r7?file=/index.js
Slate: 0.57.1
Browser: Chrome
OS: Mac
The expected behavior is that the string can be parsed to Slate object without throwing an error.
I found that the bug is in this function
because the p tag has no text, the children parameter is an empty array, therefore the for loop is never performed and returns the variable node as an empty array.
Perhaps a validation should be added that if children is an empty array that it returns [{ text: '' }] 馃
Hi @lavaldi , have you tried <p /> to see if it makes a difference?
(Also, the gif with the minimum reproduction is a bit hard for me to use for helping you so a minimum reproduction in a code sandbox would be cool if that doesn't work)
Thanks!
@DamareYoh there is a link to the codesanbox in the issue description (after the GIF).
Also, the error is thrown with the image tag <img src="[image_url]" />. You can test it in the codesandbox.
Hi @lavaldi , the issue is that the paragraph blocks the deserialize function generates are allowed to have no children. This is an invalid state for slate; all blocks need to have at least one text node, even if it is empty. The deserializer function should be updated to correct that issue.
As for images, you should be able to pass a void flag to the image block to indicate that it is not intended to have text children. See the image example for how some examples of void blocks.
I see, thank you for your help 馃憤
Most helpful comment
Hi @lavaldi , the issue is that the paragraph blocks the deserialize function generates are allowed to have no children. This is an invalid state for slate; all blocks need to have at least one text node, even if it is empty. The deserializer function should be updated to correct that issue.
As for images, you should be able to pass a
voidflag to the image block to indicate that it is not intended to have text children. See the image example for how some examples of void blocks.