• In HTML view the inserted codes had <br> at the end.

    I edited some code to take care of it. Took me couple of hours to figure this our. ??

    jQuery(".insert-code").click(function() {
        var example = jQuery( this ).parent().prev().find("code").text();
    
        var is_tinymce_active = (typeof tinyMCE != "undefined") && tinyMCE.activeEditor && !tinyMCE.activeEditor.isHidden();
    
        if (is_tinymce_active) {
            var lines = example.split('\n');
            var paras = '';
            jQuery.each(lines, function(i, line) {
                if (line) {
                    paras += line + '<br>';
                }
            });
        } else {
            var paras = example;
        }
    
        var win = window.dialogArguments || opener || parent || top;
        win.send_to_editor(paras);
    });
  • The topic ‘Elegant switch between TinyMCE and HTML modes’ is closed to new replies.