-
Notifications
You must be signed in to change notification settings - Fork 26
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
Style attribute not being returned #16
Comments
Hi @arunmenon1975 . Thanks for reaching out. I appreciate your write up of the issue. I'm a little backed up at work. I'll do my best to review this and get back to you soon! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The Quill editor on my page saves both the delta and the HTML content to the DB. Since I don't want to load a Quill instance to display the HTML in view-only pages, i use the saved HTML(from my understanding having the HTML is better from an SEO perspective). This HTML page will then have an Edit button that would then open the editor in a modal where i use the saved delta from the DB to populate the editor. This works fine (with a fixed caveat, please see comments and code snippet for the fix at the end).
I also have a requirement to translate the content in the editor to a different language by tapping on an appropriate button. I use the Google translate API(on the server) and send it the HTML (innerHTML) from the editor and i get back proper translated HTML. Still on the server, just after the translation, i call
convertHtmlToDelta
with this translated HTML and send back the returned delta to the client. I then update the value of the editor with this new delta information and my editor shows the translated content. Works great and the whole operation seems almost seamless. But there seems to be just one issue: thestyles
attribute doesn't seem to be present in the delta returned fromconvertHtmlToDelta
. Everything else remains intact thus far.So assuming this is the original delta for an image that has a float style:
This gets rendered to:
<img src="https://source.unsplash.com/featured?art" style="display: inline; margin: 0px 1em 1em 0px; float: left;" width="181" />
After
convertHtmlToDelta
the delta becomesI originally had the problem with the Quill editor itself when i was preloading it with delta from the DB and from some net research i found that i had to add
width
,alt
,height
andstyle
to theformats
object. Additionally i had to add the following snippet as well:Is there some way i could get the styles attribute as well in the returned delta? What are the possibilities of any other attribute getting stripped similarly?
The text was updated successfully, but these errors were encountered: