nadar / quill-delta-parser

A PHP library to parse and render Quill WYSIWYG Deltas into HTML - Flexibel and extendible for custom elements.
MIT License
122 stars 20 forks source link

Can I use delta coming from quill to update contents (delta object) with this library? #83

Closed owenfar closed 8 months ago

owenfar commented 8 months ago

Hello, sorry for opening an issue about this question, but from the documentation alone I cannot figure it out. And maybe you'll be better at helping me towards the right direction - I would very much appreciate it!

The discussion started here: https://github.com/quilljs/quill/discussions/4026

In summary, I'm saving Quill content in my SQL database as a delta object. And when changes are made on the website, I want to send only the changed text (using delta from text-change event), because it's not ideal to keep sending the whole editor contents for simple changes/updates in the document.

As far as I can tell, there's nothing mentioned about this in the documentation or under quill-awesome repo that can do this. But I'm a bit stunned because how is everyone else doing it then? Send the whole getContents each time (currently I'm doing this)? Can you help me sum up this question please?

If I can use this library or contribute in some way here so that we can achieve this goal it would be great!

Thanks in advance

nadar commented 8 months ago

Hey @owenfar, I have to admit, I never thought about that. For all the use cases I had, it was never a problem to send the full Quill JSON content. I assume you'd like to send the Quill delta after each "change" to an API, which then stores this information.

If this is the case, I would just debounce the requests so that when you type, it waits for a second or two until nothing is typed anymore, and then sends the AJAX request.

I think, sadly, that's all I can help with here. I also don't like Quill and Delta; use ProseMirror with Tiptap, it's so much better 😄. If you need a PHP parser for that as well, I did one: https://github.com/nadar/prosemirror-json-parser.

owenfar commented 8 months ago

Hello @nadar, thank you for your reply. Yes I already do the debounce :)

I was actually looking into alternatives just because of this. My use-case is a bit like Dropbox Paper, so imagine if you have a large document, and you just want to add a punctuation or a small update. To send the whole document each time kind of hurts me a little 😄 Because I did my best for my app to have as small requests as possible.

Now that you mentioned it, I will have another look at ProseMirror.

Appreciate your time to look into this! All the best