Ticket #5674: tmce3_extra.patch

File tmce3_extra.patch, 14.5 kB (added by azaozz, 9 months ago)
  • wp-admin/js/post.js

    old new  
    178178        } ); 
    179179        jQuery('.categorychecklist :checkbox').change( syncChecks ).filter( ':checked' ).change(); 
    180180}); 
     181 
     182wpEditorInit = function() { 
     183    // Activate tinyMCE if it's the user's default editor 
     184    if ( ( 'undefined' == typeof wpTinyMCEConfig ) || 'tinymce' == wpTinyMCEConfig.defaultEditor ) { 
     185        document.getElementById('editorcontainer').style.padding = '0px'; 
     186        tinyMCE.execCommand("mceAddControl", true, "content"); 
     187        } else { 
     188        var H; 
     189        if ( H = tinymce.util.Cookie.getHash("TinyMCE_content_size") )  
     190            document.getElementById('content').style.height = H.ch - 30 + 'px'; 
     191    } 
     192}; 
     193 
     194switchEditors = { 
     195     
     196    saveCallback : function(el, content, body) { 
     197     
     198        document.getElementById(el).style.color = '#fff'; 
     199        if ( tinyMCE.activeEditor.isHidden() )  
     200            content = document.getElementById(el).value; 
     201        else 
     202            content = this.pre_wpautop(content); 
     203 
     204        return content; 
     205    }, 
     206 
     207    pre_wpautop : function(content) { 
     208           // We have a TON of cleanup to do. 
     209 
     210        // content = content.replace(/\n|\r/g, ' '); 
     211        // Remove anonymous, empty paragraphs. 
     212        content = content.replace(new RegExp('<p>(\\s|&nbsp;|<br>)*</p>', 'mg'), ''); 
     213 
     214        // Mark </p> if it has any attributes. 
     215        content = content.replace(new RegExp('(<p[^>]+>.*?)</p>', 'mg'), '$1</p#>'); 
     216 
     217        // Get it ready for wpautop. 
     218        content = content.replace(new RegExp('\\s*<p>', 'mgi'), ''); 
     219        content = content.replace(new RegExp('\\s*</p>\\s*', 'mgi'), '\n\n'); 
     220        content = content.replace(new RegExp('\\n\\s*\\n', 'mgi'), '\n\n'); 
     221        content = content.replace(new RegExp('\\s*<br ?/?>\\s*', 'gi'), '\n'); 
     222 
     223        // Fix some block element newline issues 
     224        var blocklist = 'blockquote|ul|ol|li|table|thead|tr|th|td|div|h\\d|pre'; 
     225        content = content.replace(new RegExp('\\s*<(('+blocklist+') ?[^>]*)\\s*>', 'mg'), '\n<$1>'); 
     226        content = content.replace(new RegExp('\\s*</('+blocklist+')>\\s*', 'mg'), '</$1>\n'); 
     227        content = content.replace(new RegExp('<li>', 'g'), '\t<li>'); 
     228                 
     229        if ( content.indexOf('<object') != -1 ) { 
     230            content = content.replace(new RegExp('\\s*<param([^>]*)>\\s*', 'g'), "<param$1>"); // no pee inside object/embed 
     231            content = content.replace(new RegExp('\\s*</embed>\\s*', 'g'), '</embed>'); 
     232        } 
     233                 
     234        // Unmark special paragraph closing tags 
     235        content = content.replace(new RegExp('</p#>', 'g'), '</p>\n'); 
     236        content = content.replace(new RegExp('\\s*(<p[^>]+>.*</p>)', 'mg'), '\n$1'); 
     237 
     238        // Trim trailing whitespace 
     239        content = content.replace(new RegExp('\\s*$', ''), ''); 
     240 
     241        // Hope. 
     242        return content; 
     243    }, 
     244 
     245    go : function(id) { 
     246        var ed = tinyMCE.get(id); 
     247        var qt = document.getElementById('quicktags'); 
     248        var H = document.getElementById('edButtonHTML'); 
     249        var P = document.getElementById('edButtonPreview'); 
     250        var ta = document.getElementById(id); 
     251        var ec = document.getElementById('editorcontainer'); 
     252 
     253        if ( ! ed || ed.isHidden() ) { 
     254            ta.style.color = '#fff'; 
     255         
     256            this.edToggle(P, H); 
     257            edCloseAllTags(); // :-( 
     258 
     259            qt.style.display = 'none'; 
     260            ec.style.padding = '0px'; 
     261 
     262            ta.value = this.wpautop(ta.value); 
     263 
     264            if ( ed ) ed.show(); 
     265            else tinyMCE.execCommand("mceAddControl", false, id); 
     266         
     267            this.wpSetDefaultEditor( 'tinymce' ); 
     268        } else { 
     269            this.edToggle(H, P); 
     270            tinyMCE.triggerSave(); 
     271            ta.style.height = tinyMCE.activeEditor.contentAreaContainer.offsetHeight + 6 + 'px'; 
     272 
     273            if ( tinymce.isIE6 )  
     274                ta.style.width = tinyMCE.activeEditor.contentAreaContainer.offsetWidth - 12 + 'px'; 
     275 
     276            ed.hide(); 
     277            ta.value = this.pre_wpautop(ta.value); 
     278         
     279            qt.style.display = 'block'; 
     280            ec.style.padding = '6px'; 
     281            ta.style.color = ''; 
     282 
     283            this.wpSetDefaultEditor( 'html' ); 
     284        } 
     285    }, 
     286 
     287    edToggle : function(A, B) { 
     288        A.className = 'active'; 
     289        B.className = ''; 
     290 
     291        B.onclick = A.onclick; 
     292        A.onclick = null; 
     293    }, 
     294 
     295    wpSetDefaultEditor : function( editor ) { 
     296        try { 
     297            editor = escape( editor.toString() ); 
     298        } catch(err) { 
     299            editor = 'tinymce'; 
     300        } 
     301 
     302        var userID = document.getElementById('user-id'); 
     303        var date = new Date(); 
     304        date.setTime(date.getTime()+(10*365*24*60*60*1000)); 
     305        document.cookie = "wordpress_editor_" + userID.value + "=" + editor + "; expires=" + date.toGMTString(); 
     306    }, 
     307 
     308    wpautop : function(pee) { 
     309        var blocklist = 'table|thead|tfoot|caption|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|pre|select|form|blockquote|address|math|p|h[1-6]'; 
     310     
     311        pee = pee + "\n\n"; 
     312        pee = pee.replace(new RegExp('<br />\\s*<br />', 'gi'), "\n\n"); 
     313        pee = pee.replace(new RegExp('(<(?:'+blocklist+')[^>]*>)', 'gi'), "\n$1");  
     314        pee = pee.replace(new RegExp('(</(?:'+blocklist+')>)', 'gi'), "$1\n\n"); 
     315        pee = pee.replace(new RegExp("\\r\\n|\\r", 'g'), "\n"); 
     316        pee = pee.replace(new RegExp("\\n\\s*\\n+", 'g'), "\n\n"); 
     317        pee = pee.replace(new RegExp('([\\s\\S]+?)\\n\\n', 'mg'), "<p>$1</p>\n"); 
     318        pee = pee.replace(new RegExp('<p>\\s*?</p>', 'gi'), ''); 
     319        pee = pee.replace(new RegExp('<p>\\s*(</?(?:'+blocklist+')[^>]*>)\\s*</p>', 'gi'), "$1"); 
     320        pee = pee.replace(new RegExp("<p>(<li.+?)</p>", 'gi'), "$1"); 
     321        pee = pee.replace(new RegExp('<p><blockquote([^>]*)>', 'gi'), "<blockquote$1><p>"); 
     322        pee = pee.replace(new RegExp('</blockquote></p>', 'gi'), '</p></blockquote>'); 
     323        pee = pee.replace(new RegExp('<p>\\s*(</?(?:'+blocklist+')[^>]*>)', 'gi'), "$1"); 
     324        pee = pee.replace(new RegExp('(</?(?:'+blocklist+')[^>]*>)\\s*</p>', 'gi'), "$1");  
     325        pee = pee.replace(new RegExp('\\s*\\n', 'gi'), "<br />\n"); 
     326        pee = pee.replace(new RegExp('(</?(?:'+blocklist+')[^>]*>)\\s*<br />', 'gi'), "$1"); 
     327        pee = pee.replace(new RegExp('<br />(\\s*</?(?:p|li|div|dl|dd|dt|th|pre|td|ul|ol)>)', 'gi'), '$1'); 
     328        pee = pee.replace(new RegExp('^((?:&nbsp;)*)\\s', 'mg'), '$1&nbsp;'); 
     329        //pee = pee.replace(new RegExp('(<pre.*?>)(.*?)</pre>!ise', " stripslashes('$1') .  stripslashes(clean_pre('$2'))  . '</pre>' "); // Hmm... 
     330        return pee; 
     331    } 
     332} 
  • wp-admin/wp-admin.css

    old new  
    370370        width: 100%; 
    371371} 
    372372 
    373 #postdivrich #content { 
    374         padding: 5px; 
    375         line-height: 140%; 
     373#editorcontainer #content { 
     374        padding: 0; 
     375        line-height: 150%; 
     376        border: 0 none; 
    376377} 
    377378 
     379#editorcontainer { 
     380        padding: 6px; 
     381} 
     382 
    378383#currenttheme img { 
    379384        float: left; 
    380385        border: 1px solid #666; 
     
    394399} 
    395400 
    396401#postdivrich #quicktags { 
    397         background: #f0f0ee
     402        background: #cee1ef
    398403        padding: 0; 
    399         border: 1px solid #ccc; 
    400         border-bottom: none; 
     404        border: 0 none; 
    401405} 
    402406 
    403407#postdiv #quicktags { 
     
    11781182        padding: 2px; 
    11791183} 
    11801184 
    1181 #poststuff .postbox, #titlediv
     1185#poststuff .postbox, #titlediv, #poststuff .postarea
    11821186        margin-left: 20px; 
    11831187        border: 1px solid #ebebeb; 
    11841188        border-right: 1px solid #ccc; 
     
    11881192} 
    11891193 
    11901194#poststuff .postarea { 
    1191         margin-left: 20px; 
    11921195        margin-right: 8px; 
    11931196} 
    11941197 
     
    12231226 
    12241227#poststuff #edButtonPreview, #poststuff #edButtonHTML { 
    12251228        display: block; 
    1226         height: 18px; 
     1229        height: 20px; 
    12271230        padding: 5px; 
    12281231        margin-right: 8px; 
    12291232        float: right; 
     
    12351238        background: #cee1ef; 
    12361239        color: #333; 
    12371240        font-weight: bold; 
    1238         -moz-border-radius: 2px; 
     1241        -moz-border-radius-topright: 2px; 
     1242        -moz-border-radius-topleft: 2px; 
    12391243} 
    12401244 
    12411245#poststuff #media-buttons { 
  • wp-includes/general-template.php

    old new  
    928928        if ( user_can_richedit() ) : 
    929929                $wp_default_editor = wp_default_editor(); 
    930930                $active = " class='active'"; 
    931                 $inactive = " onclick='switchEditors(\"$id\");'"; 
     931                $inactive = " onclick='switchEditors.go(\"$id\");'"; 
    932932 
    933933                if ( 'tinymce' == $wp_default_editor ) 
    934934                        add_filter('the_editor_content', 'wp_richedit_pre'); 
    935935 
    936                 //      The following line moves the border so that the active button "attaches" to the toolbar. Only IE needs it. 
    937         ?> 
    938        <style type="text/css"> 
     936                //      The following line moves the border so that the active button "attaches" to the toolbar. Only IE needs it.  
     937        ?>       
     938    <style type="text/css"> 
    939939                #postdivrich table, #postdivrich #quicktags {border-top: none;} 
    940940                #quicktags {border-bottom: none; padding-bottom: 2px; margin-bottom: -1px;} 
    941941        </style> 
     942         
    942943        <div id='editor-toolbar' style='display:none;'> 
    943                 <div class='zerosize'><input accesskey='e' type='button' onclick='switchEditors("<?php echo $id; ?>")' /></div> 
     944                <div class='zerosize'><input accesskey='e' type='button' onclick='switchEditors.go("<?php echo $id; ?>")' /></div> 
    944945                <a id='edButtonHTML'<?php echo 'html' == $wp_default_editor ? $active : $inactive; ?>><?php _e('HTML'); ?></a> 
    945946                <a id='edButtonPreview'<?php echo 'tinymce' == $wp_default_editor ? $active : $inactive; ?>><?php _e('Visual'); ?></a> 
    946947 
     
    973974        </script> 
    974975        <?php endif; // 'html' != $wp_default_editor 
    975976 
    976         $the_editor = apply_filters('the_editor', "<div><textarea class='' $rows cols='40' name='$id' tabindex='2' id='$id'>%s</textarea></div>\n"); 
     977        $the_editor = apply_filters('the_editor', "<div id='editorcontainer'><textarea class='' $rows cols='40' name='$id' tabindex='2' id='$id'>%s</textarea></div>\n"); 
    977978        $the_editor_content = apply_filters('the_editor_content', $content); 
    978979 
    979980        printf($the_editor, $the_editor_content); 
     
    986987        // If tinyMCE is defined. 
    987988        if ( typeof tinyMCE != 'undefined' ) { 
    988989        // This code is meant to allow tabbing from Title to Post (TinyMCE). 
    989                 if ( tinyMCE.isMSIE ) { 
    990                         document.getElementById('<?php echo $prev_id; ?>').onkeydown = function (e) { 
    991                                 if ( tinyMCE.idCounter == 0 ) 
    992                                         return true; 
    993                                 e = e ? e : window.event; 
    994                                 if (e.keyCode == 9 && !e.shiftKey && !e.controlKey && !e.altKey) { 
    995                                         var i = tinyMCE.getInstanceById('<?php echo $id; ?>'); 
    996                                         if(typeof i ==  'undefined') 
    997                                                 return true; 
    998                                         tinyMCE.execCommand("mceStartTyping"); 
    999                                         this.blur(); 
    1000                                         i.contentWindow.focus(); 
    1001                                         e.returnValue = false; 
    1002                                         return false; 
    1003                                 } 
    1004                         } 
    1005                 } else { 
    1006                         document.getElementById('<?php echo $prev_id; ?>').onkeypress = function (e) { 
    1007                                 if ( tinyMCE.idCounter == 0 ) 
    1008                                         return true; 
    1009                                 e = e ? e : window.event; 
    1010                                 if (e.keyCode == 9 && !e.shiftKey && !e.controlKey && !e.altKey) { 
    1011                                         var i = tinyMCE.getInstanceById('<?php echo $id; ?>'); 
    1012                                         if(typeof i ==  'undefined') 
    1013                                                 return true; 
    1014                                         tinyMCE.execCommand("mceStartTyping"); 
    1015                                         this.blur(); 
    1016                                         i.contentWindow.focus(); 
    1017                                         e.returnValue = false; 
    1018                                         return false; 
    1019                                 } 
    1020                         } 
    1021                 } 
     990        document.getElementById('<?php echo $prev_id; ?>').onkeydown = function (e) { 
     991            e = e || window.event; 
     992            if (e.keyCode == 9 && !e.shiftKey && !e.controlKey && !e.altKey) { 
     993                if ( tinyMCE.activeEditor ) { 
     994                    e = null; 
     995                    if ( tinyMCE.activeEditor.isHidden() ) return true; 
     996                    tinyMCE.activeEditor.focus(); 
     997                    return false; 
     998                } 
     999                return true; 
     1000            } 
     1001        } 
    10221002        } 
    10231003        <?php endif; ?> 
    10241004        //--> 
  • wp-includes/js/autosave.js

    old new  
    8282} 
    8383 
    8484function autosave() { 
    85         var rich = ((typeof tinyMCE != "undefined") && tinyMCE.getInstanceById('content')) ? true : false; 
     85        var rich = ( (typeof tinyMCE != "undefined") && tinyMCE.activeEditor && ! tinyMCE.activeEditor.isHidden() ) ? true : false; 
    8686        var post_data = { 
    8787                        action: "autosave", 
    8888                        post_ID:  jQuery("#post_ID").val() || 0, 
     
    9393                }; 
    9494 
    9595        /* Gotta do this up here so we can check the length when tinyMCE is in use */ 
    96         if ( typeof tinyMCE == "undefined" || tinyMCE.configs.length < 1 || rich == false ) { 
    97                 post_data["content"] = jQuery("#content").val(); 
    98         } else { 
     96        if ( rich ) { 
    9997                // Don't run while the TinyMCE spellcheck is on. 
    100                 if(tinyMCE.selectedInstance.spellcheckerOn) return; 
    101                 tinyMCE.wpTriggerSave(); 
    102                 post_data["content"] = jQuery("#content").val(); 
    103         } 
     98                if ( tinyMCE.activeEditor.plugins.spellchecker && tinyMCE.activeEditor.plugins.spellchecker.active ) return; 
     99                tinyMCE.triggerSave(); 
     100        }  
     101         
     102    post_data["content"] = jQuery("#content").val(); 
    104103 
    105104        if(post_data["post_title"].length==0 || post_data["content"].length==0 || post_data["post_title"] + post_data["content"] == autosaveLast) { 
    106105                return; 
     
    122121        if( jQuery("#excerpt")) 
    123122                post_data["excerpt"] = jQuery("#excerpt").val(); 
    124123 
    125         if ( typeof tinyMCE == "undefined" || tinyMCE.configs.length < 1 || rich == false ) { 
    126                 post_data["content"] = jQuery("#content").val(); 
    127         } else { 
    128                 tinyMCE.wpTriggerSave(); 
    129                 post_data["content"] = jQuery("#content").val(); 
    130         } 
     124        if ( rich )  
     125        tinyMCE.triggerSave(); 
     126     
     127        post_data["content"] = jQuery("#content").val(); 
    131128 
    132129        if(parseInt(post_data["post_ID"]) < 1) { 
    133130                post_data["temp_ID"] = post_data["post_ID"]; 
  • wp-includes/script-loader.php

    old new  
    3030                $this->add( 'colorpicker', '/wp-includes/js/colorpicker.js', false, '3517' ); 
    3131 
    3232                // Modify this version when tinyMCE plugins are changed 
    33                 $this->add( 'tiny_mce', '/wp-includes/js/tinymce/tiny_mce_gzip.php', false, '20080105' ); 
     33                $this->add( 'tiny_mce', '/wp-includes/js/tinymce/tiny_mce_gzip.php', false, '20080129' ); 
    3434 
    3535                $mce_config = apply_filters('tiny_mce_config_url', '/wp-includes/js/tinymce/tiny_mce_config.php'); 
    36                 $this->add( 'wp_tiny_mce', $mce_config, array('tiny_mce'), '20080105' ); 
     36                $this->add( 'wp_tiny_mce', $mce_config, array('tiny_mce'), '20080129' ); 
    3737 
    3838                $this->add( 'prototype', '/wp-includes/js/prototype.js', false, '1.6'); 
    3939