-
Notifications
You must be signed in to change notification settings - Fork 3.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Proposal: (Doc) write about **the correct way** to store & display quill editor content #2276
Comments
Quill work with Delta. |
@benbro got it. thank you. new question: can you put these into doc? a new section, maybe here: |
Adding a huge screenshot for each post is unneeded. Please use text only. |
got it, thanks |
This was a deal breaker for me with using this; I don't want to store both Delta json and HTML; shame because looks like such a great product; I am switching to summernote |
It's really frustrating to invest a lot of time in understanding Quill, expecting there will be instructions along the way about rendering its content, only to learn that this project is bring-your-own-renderer. It'd be great to mention that at the beginning. |
A little update: (in short: I am not using Quill anymore) because our product pivot to another direction. So I am not using Quill anymore. This is just a simple update in case anyone interested |
This is 2020 and i still find it difficult to display data saved from the editor. This is a bit disappointing i must say after going through the stress of integrating the library. It also says a lot about the library with its number of opened issues and pending pull requests |
please help me with this similar issue: pingcap/tidb#18922 |
Save the html output from quill editor. Then render it as an innerHTML on a div. Give class="ql-editor" to the div and the html will be formatted as we see it in the editor. No need to instantiate editor context. Just import quill's css file. Vue example:
|
The problem with saving the HTML from the editor is that the user can submit any HTML to save. We don't know it actually came from the editor. |
In the spirit of being helpful to someone else starting with Quill for the first time, I thought I'd share how I got Quill to save and load from a database. You can access the delta format by the .getContents() and .setContents() on the quill object. So the code would look something like this: var quill = new Quill('#editor', {
theme: 'snow'
});
quill.setContents({{ delta_content }}); // <-- This is the magic Where I'm using jinja2 with Python/Flask so I needed to pass the "safe" modifier to my template vars so the delta object wasn't html escaped. Here was my Javascript line with the jinja2 template tag: Displaying the work done in Quill to a browser (i.e. Delta to HTML) is still a touch of a work in progress. Right now I'm saving the html via the quill.root.innerHTML function and just displaying that. Seems to be working but I don't love having both the HTML and the Delta stored in the database. I may switch to a python library that renders Delta to HTML but more research is needed. |
This is how I save delta in my database Firstly I create a hidden input field and use JS to handle picking the data.
|
This works very well, at least since now:
The displaying html page not only does not contain any Quill js code, it need not contain any javascript at all. Just HTML tags are fine. Sure, differing CSS would influence the visual result. But you can probably enforce such CSS as you like. You store just what the model itself stores using its QuillField type. No other content management, no conversions, except what I have taken it from this tutorial |
In case anyone comes across this and finds this useful. You don't need to use innerHTML to render the delta, you can instantiate a new quill object with the settings of readonly and no toolbar, use CSS to remove the border if you want.
To save the delta in the database I use JSON.stringify($delta) like above, with a listener that updates a hidden input
|
1. Why
so far(2018-8-26) Quill document didn't say anything about what is the correct / suggest way to store and display content from quill editor
2. Base on my current understanding
There are 2 way to store and then display content when using quill editor to write content.
(Delta) Store Delta into database (MySQL/PostgreSQL as JSON). then, when Display, use some library convert Delta to HTML and then display
(HTML) Store HTML using
quill.root.innerHTML
into database (MySQL/PostgreSQL) and then just Display these HTML3. Question
Would you guys write about this topic (store&display) in document?
Thanks!
(I am still researching, If I find any new info helpful for this. I would update this issue)
4. info relate to this topic
https://www.bountysource.com/issues/37978100-render-quill-delta-without-instantiating-an-editor
#993
#1551
The text was updated successfully, but these errors were encountered: