Is there an event that is fired when a TextMarker is changed?


I’m trying to achieve the following:

  1. Add a text marker to a section of text within CodeMirror.
  2. I add line classes to each line that the text marker covers.
  3. As I add more text I want more line classes to be added for new lines. This text can be typed in or pasted from the clipboard.

At the moment I’m using the Enter key KeyMap and check to see if the cursor is within a text marker. If so I add the line classes. However, this seems inefficient and I was wondering if the TextMarker can emit events to say it has changed, which I could then use to add or remove the line classes.


No such event exists. Listening for enter key presses isn’t robust either—you can paste or drop or programmatically change line structure. So you’d want to listen to the "changes" event and double-check whether your line classes are still accurate after every one.

Thanks for the quick response Marijn and for the all the effort you put into this package.