$(document).ready(function() {

    // Refresh codemirror elements.
    // card collapse on click
    $('.card [data-action=collapse]:not(.disabled)').on('click', function () {

        let cardParent = $(this).parents('.card');

        // check if parent is not collapsed.
        if(!cardParent.hasClass('card-collapsed')) {

            // loop on codemirror elements inside the card.
            $(cardParent).find('.CodeMirror').each(function(i, el){
                el.CodeMirror.refresh();
            });
        }

    })

})