Inline Blots Leaving formatting behind when deleted
See original GitHub issueSetup
I am running into an difficult to solve edge case with inline blots. I am using the blot to provide a syntax highlighting functionality to highlight keywords in the user text as the user types.
An an example, let’s say I want to highlight everything that starts with ‘#’. I create a “Highlight” blot with a span tag and then add the necessary blots to the text after the user types.
So if the user types:
hi #scott, I like your #idea !!!
I would then add the blots leaving the following dom
hi <span class="highlight">#scott</span>, I like your <span class="highlight">#idea</span> !!!
If the user then deleted the first # for instance, we would go in and remove the highlight blot leaving:
hi scott, I like your <span class="highlight">#idea</span> !!!
the highlight class has some css properties on it like a background-color.
Bug
The bug arises if a user selects from exactly the start of one of the highlight spans to anywhere after the end of the highlight span and then types something to replace the content.
For instance using the above example, they select “#idea !!!” and then type “x”.
What I expect to happen is the contents transforms to:
hi scott, I like your x
What actually happens is that the blot styling is left behind even though the blot is gone and the contents transforms to:
hi scott, I like your <span style="background-color: <the highlight color from the blot">x</span>
It appears quill keeps the styling from the blot classes even though the blot is being removed.
How can I prevent styling being left behind in cases like this?
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:7
Here is a codepen:
https://codepen.io/scottfr/pen/LKLLpJ
The two things to check out are:
I have this as well… any news on this? It’s kind of a bummer… 😉