advoor / nova-editor-js

Editor JS field for Laravel Nova
92 stars 54 forks source link

Something went wrong: Field `blocks` is missing #72

Closed joostvanhoof closed 2 years ago

joostvanhoof commented 2 years ago

@roelofr thanks for the previous fixes with the attribute casting. After the upgrade however (I'm using the casting now), this is what's happening:

joostvanhoof commented 2 years ago

Actually, if I save an empty EditorJs field the data that's stored in the database is "[object Object]" so it looks like there is still something wrong with attribute casting and encoding/decoding from array to JSON?

roelofr commented 2 years ago

I've seen this on my site too.

It looks like it's double-encoding the JSON for some reason. Might be the cast encoding something that Nova has already encoded.

Does your data look something like this:

""{\"time\":228372095,\"blocks\":[{\"data\":{\"text\":\"Iusto consequatur voluptas itaque minus. Dolorem sunt reiciendis quia rerum ut laborum temporibus.\"},\"type\":\"paragraph\"},],\"version\":\"2.15.0\"}"
joostvanhoof commented 2 years ago

Yes:

"{\"time\":1658065712458,\"blocks\":[{\"id\":\"lI-Qi6ysGA\",\"type\":\"paragraph\",\"data\":{\"text\":\"text here\"}}],\"version\":\"2.25.0\"}"

And when saving an empty field:

[object Object]
roelofr commented 2 years ago

I can't seem to replicate the [object Object] error, my empty fields just remain empty, but I've fixed the other issue.