Prevent Quill from stripping attributes on block and inline elements #4498
Unanswered
lelamanolio
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm currently implementing Quill in a project that has both a WYSIWYG editor (converting from TinyMCE to Quill) and a code editor
If the user adds a
class
attribute on an<h1>
tag and in another moment, try to change the same text from Quill, it automatically removes all attributes that were previously set.After searching for similar issues, I found out a solution that works only partially:
It works partially because at the moment it works only for inline elements.
Even though I tried to have the same function extends both
blocks
andblocks/embed
, Quill still strips all the attributes from the block elements.Plus, an upgrade that it'd be neat would be to not have a "fixed" array of attributes, but rather that it automatically keeps all the attributes set on an element.
That's why I moved on from this solution and tried something else with the clipboard and its matchers.
I managed to create a function that appends the attributes of the element to its delta like so:
In the
console.log()
I can clearly see that the attributes were correctly added in the delta but still, when I invokequill.clipboard.dangerouslyPasteHTML
, it still strips all the attributes.For more clarity, here's a simplified version of my code with the matcher mentioned: https://jsfiddle.net/b9d45zhk/17/
Anyone had the same kind of requirements/issues with it and can help?
Beta Was this translation helpful? Give feedback.
All reactions