question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Inline Blots Leaving formatting behind when deleted

See original GitHub issue

Setup

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:open
  • Created 4 years ago
  • Reactions:1
  • Comments:7

github_iconTop GitHub Comments

3reactions
scottfrcommented, Jun 24, 2019

Here is a codepen:

https://codepen.io/scottfr/pen/LKLLpJ

The two things to check out are:

  1. Delete one of the @'s. When Quill rehighlights (happens every 2 seconds) it will correctly remove the styling from the rest of the tag. This works as expected
  2. Select from the start of one of the @'s to the end of the line. (E.g. if the text is “This @tag is good” select: “This [@tag is good]”). Type something to replace the selection. The new text will retain the blot styling even after the highlighter runs again. This is incorrect and not what is expected
1reaction
mijnnaamisramoncommented, Oct 13, 2020

I have this as well… any news on this? It’s kind of a bummer… 😉

Read more comments on GitHub >

github_iconTop Results From Across the Web

What, how and when to use static formats ... - Stack Overflow
DESCRIPTION. I am trying to create an inline blot for text highlighting. I know this feature is already present ...
Read more >
Cloning Medium with Parchment - Quill Rich Text Editor
This works since Blots just pass unknown formats to its children, eventually reaching the leaves. This also allows different Embeds to handle unregistered ......
Read more >
10 Most Common Bootstrap Mistakes That Developers Make
If a sanity check fails, it leaves an informative comment on the pull request explaining the mistake and how to fix it, and...
Read more >
Advanced Bash-Scripting Guide
Consider that as a Linux machine boots up, it executes the shell scripts in ... (Leaving out the replacement pattern results in a...
Read more >
GNU GRUB Manual 2.06
The partition table format traditionally used on PC BIOS platforms is called the ... the cache device for reading the required dirty data...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found