-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
Pasting html content (e-mail) partially remove css ( on images ) #1896
Comments
Show an example of HTML you are trying to paste and fill in the rest of the info requested in the issue template. |
Html like this one
|
I'm having the same issue over here. If I paste HTML into the editor, all the inline CSS is lost and the HTML elements are converted to paragraphs and simpler element types. Example:
Is converted to:
Is there any way of allowing the pasting of HTML as it is or it's just a missing feature/bug? Platforms: Version: |
@guilhemwishibam By specifying @freitasskeeled Quill does not allow arbitrary HTML in its contents as it is not safe from a user experience or bug free perspective. Allowing arbitrary HTML is why the previous generation of rich text editors gained their notoriety for bugginess and why Quill was built and became popular. Quill does provide a way for to safely paste new content through its Clipboard APIs: https://quilljs.com/docs/modules/clipboard. If you find this too onerous and would rather risk the occasional bugs, other said editors still exist and are also open source. |
@jhchen Thank you for the feedback. Is it possible to enable the pasting of HTML with inline CSS at all? I understand what you meant but I'm not talking about |
@freitasskeeled No this is not possible. I'm not talking about safety from a security perspective -- I'm talking about safely from a bug free perspective. Browsers decide to do very peculiar things with the most innocuous modifications. |
OK... I've tried all sorts of solutions. I created and registered custom format blots and attributors. I was unsuccessful registering anything that would allow an img tag to have a very specific set of attributes. Here is the diff:
I would like to accomplish this in the proper way. Is there any way to allow these attributes to be retained on an img element through Quill? The specific use case is that I need to align and resize images in html. The ImageResize module and retain the html changes made by that utility. The issue is posted here. |
enable the pasting of HTML with inline CSS at all. is it can be a feature in config to open it ? |
A keepHTML blot could solve the problem:
What this does is that if any html node has "keepHTML" class, the whole html node will be preserved. |
It seems that the below is what causes the removal/change of CCS when using dangerouslyPasteHTML
|
Yeah this won't work if you don't have control over the html being input into the quill editor. I'm looking for the correct quill configuration to allow for img style width/height to be converted to attributes width/height. So far the internet has failed me and this is the closest bug report. Any movement on this? |
5 years on this is still ongoing - @jhchen it'd be ideal if a boolean could be pass to preserve HTML attributes/classes, and explicit argument so that developers know it might lead to "bugginess" etc. :) |
@morecpq I don't know if this can actually help you, and it took me some time to understand how Blot works Anyway, as blackChef suggested you can use Blots (more about Blots on quilljs guide section ) to modify the formats of html tags https://codepen.io/tiziano-meola/pen/YzOzQZr Hope this helps :) |
This solves my issue. Thanks a lot |
Quill 2.0 has been released (announcement post) with many changes and fixes. If this is still an issue please create a new issue after reviewing our updated Contributing guide 🙏 |
Lastest version of quill,
Im using quill to answers to mails
Pasting my mail content [html] with editor.clipboard.dangerouslyPasteHTML();
My html content is fine, but when pasted, all inline css on images are removed
Do i miss any configuration ?
This is my Quill config
html to had :
<img src="https://img.jpg" width="600" height="200" style="width:600px;height:200px;">
result:
<img src="https://img.jpg">
Platforms:
Mac Osx, Chrome 63.0.3239.84
Version:
Quill version : "1.3.4"
The text was updated successfully, but these errors were encountered: