Any ideas how to switch tabs from codemirror back to default WordPress tab (HTML and Visual)

I am wondering how to switch back from CodeMirror editor mode back to WordPress default editor modes like HTMl and Text. I have a WordPress theme that uses 3 editing modes (Text and Visual which are WordPress defaults and the Syntax editing mode using Code Mirror).
I manage to switch to CodeMirror from HTML or Text by writing a JS script that will toggle the code mirror. THis is my JS code:

            //Hide WordPress tinyMCE
            tinymce.get('content').hide();

            //Enable code mirror
            my_editor.toggleCodeMirror('content', true); 

The problem is that when I switch back to Visual editor mode like this:

Read More
            my_editor.toggleCodeMirror('content', false);

            if(!jQuery('#content_parent').is(':visible'))
            {
                tinymce.get('content').show();                  
            }

It’s not stable and sometimes it breaks the default WP editor. Any ideas how to correctly back to WP default editors from a Code Mirror instance? Thank you so much for the help 🙂

Related posts

Leave a Reply