Also, is there a way to fire an event when the user hovers over marked text? Or does one have to add their own custom mode as in your htmlmixed example here?
Hmm, my beforeCursorEnter appears to be firing twice. This below is now currently the entirety of my <script> section (there are no others) and I am getting “myMarker → beforeCursorEnter” printed twice inside the console. Any idea why that is?
will log an empty array. So no preventDefault() is available. Is there an option that needs to be set to prevent double event firing? Oh and by the way, the console logs twice too.
I went digging into the source code and it’s inside the source file selection_updates.js, the function skipAtomicInSelection() does make TWO calls to skipAtomic() which calls skipAtomicInner where the calls to signal(m, "beforeCursorEnter") takes place.
The two calls inside the skipAtomicInSelection() are to set variables newAnchor and newHead
Should I use a debounce method to deal with the double “beforeCursorEnter” events or is there a better way?
Looks like it fires it both for the selection head and the selection anchor, even if those are the same. The patch below avoids the extra call, though you’d probably still want to make your handler idempotent or debounce it somehow, since quick selection changes or the creation of a non-cursor selection in your range will still cause it to fire multiple times.