slab / delta

Simple and expressive JSON format for describing rich-text content and their changes
https://quilljs.com/docs/delta
BSD 3-Clause "New" or "Revised" License
914 stars 130 forks source link

Error on converting Delta to JSON #20

Closed livthomas closed 6 years ago

livthomas commented 6 years ago

The README file says that it should be possible to convert Delta to string using JSON.stringify(). However, when I try to serialize a simple delta, I get the following error:

TypeError: Converting circular structure to JSON

Is this a bug or am I doing something wrong? I use Quill 1.3.4 integrated to my Angular application through ngx-quill library.

livthomas commented 6 years ago

It seems that the error only occurs when I try to serialize Delta with my custom Blot. Some guidelines on how to create your custom blots would be very useful since it is not clear from the existing materials.

jhchen commented 6 years ago

Deltas are not doing anything special here -- they are just Javascript objects and all normal JSON stringification constraints apply, such as the circular reference one you encountered. Please consult the JSON documentation for what you can and cannot stringify.