Search code examples
javascriptquill

how to convert a delta to a string that you have entered


I am entering a string to the quill editor. The quill editor convert the string to a delta and saving it to the database. So I want to trim the string when I am retrieving it from the database but because it's a delta is trim the delta and all my styling is not working and it return an uncompleted delta


Solution

  • This is a pretty old question but just in case the next one is looking for an answer I will explain how I fixed is. It's a way, doesn't really feel right... But it gets the job done.

    You should convert the JSON, that's only understood by Quill as a Delta object, to normal content. This is just plain old html. Since we got the html as a string we can perform a string.replace to replace the whitespace with no whitespace.