Search code examples
codemirror

How to capture CodeMirror hide/unhide events?


I want to capture events when markers are removed or when the remove is undone. The docs say there are "hide" and "unhide" events but I can't figure out how to capture these events. Can anyone provide a code snippet?

Thanks.


Solution

  • Finally figured this out:

    // Create a marker
    var myMark = cm.markText(...)
    
    // Add the listener directly on the marker
    CodeMirror.on(myMark, "hide", function(){
        // do stuff
    });