I’m trying to make a block of code blinking by adding a class when I press mod-e keyboard shortcut.
To make this I’m trying to follow the Decoration example from here : https://codemirror.net/6/examples/decoration/
First of all, the example for me is super complicated to understand and so, adapt(not the fault of the example, more because is to advanced for me).
So my question is simple, is there an easy way to add a class to the text by giving a range? With dispatch for instance?
If no I will share my code, but I’m sure is really not correct, awfull and messy so I will do that only if following the example is the only way to achieve that.
Now the class is added to the html element after event jeyboard, and that’s great. But I would need, to make the feature more clean and stable, to remove this class after a while (1.5sec). Do you think that in this kind of setup this is possible?
You could associate an ID with each mark, and set a timeout that fires a transaction that removes the mark with the given ID when you initially add it.
But then I don’t get which kind of transaction I should do to : "removes the mark with the given ID ". Could you please give me an hint on that? Step by step I’m starting to get more familiar with the reference, but it’s still a bit complicated so, sorry if my questions looks a bit silly…
thank you very much for helping me in this adventure.
I also noticed that in this part of the documentation : CodeMirror 5 to 6 Migration Guide
in the “Marked Text” part there is an example were they filter some marks, maybe I could try to follow this method also?