Make WordPress Core

Changeset 2964


Ignore:
Timestamp:
10/25/2005 11:10:14 PM (21 years ago)
Author:
ryan
Message:

TinyMCE fixes. Reinstate "More..." button. Filter trailing br. fixes #1789

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/admin-header.php

    r2917 r2964  
    8888        width : "100%",
    8989        theme : "advanced",
    90         theme_advanced_buttons1 : "bold,italic,strikethrough,separator,bullist,numlist,outdent,indent,separator,justifyleft,justifycenter,justifyright,separator,link,unlink,image,emotions,separator,undo,redo,wordpress,code",
     90        theme_advanced_buttons1 : "bold,italic,strikethrough,separator,bullist,numlist,outdent,indent,separator,justifyleft,justifycenter,justifyright,separator,link,unlink,image,emotions,separator,wordpress,separator,undo,redo,code",
    9191        theme_advanced_buttons2 : "",
    9292        theme_advanced_buttons3 : "",
     
    100100        entity_encoding : "raw",
    101101        relative_urls : false,
     102        remove_script_host : false,
    102103        valid_elements : "a[href|title],strong/b,em/i,strike,u,p[class|align],ol,ul,li,br,img[class|src|alt|title|width|height|align],sub,sup,blockquote,table[border=0|cellspacing|cellpadding|width|height|class|align],tr[class|rowspan|width|height|align|valign],td[dir|class|colspan|rowspan|width|height|align|valign],div[dir|class|align],span[class|align],pre[class],address,h1[class|align],h2[class|align],h3[class|align],h4[class|align],h5[class|align],h6[class|align],hr",
    103         plugins : "autosave, contextmenu"
     104        plugins : "contextmenu,wordpress"
    104105        <?php do_action('mce_options'); ?>
    105106});
  • trunk/wp-includes/js/tinymce/plugins/wordpress/editor_plugin.js

    r2820 r2964  
    1010    switch (control_name) {
    1111        case "wordpress":
    12             return '<img id="{$editor_id}_wordpress_more" src="{$pluginurl}/images/more.gif" title="More..." width="20" height="20" class="mceButtonNormal" onmouseover="tinyMCE.switchClass(this,\'mceButtonOver\');" onmouseout="tinyMCE.restoreClass(this);" onmousedown="tinyMCE.restoreAndSwitchClass(this,\'mceButtonDown\');tinyMCE.execInstanceCommand(\'{$editor_id}\',\'mcewordpressmore\');" /><img id="{$editor_id}_wordpress_page" src="{$pluginurl}/images/page.gif" title="...Page..." width="20" height="20" class="mceButtonNormal" onmouseover="tinyMCE.switchClass(this,\'mceButtonOver\');" onmouseout="tinyMCE.restoreClass(this);" onmousedown="tinyMCE.restoreAndSwitchClass(this,\'mceButtonDown\');tinyMCE.execInstanceCommand(\'{$editor_id}\',\'mcewordpresspage\');" />';
     12            return '<a href="javascript:tinyMCE.execInstanceCommand(\'{$editor_id}\',\'mcewordpressmore\')" target="_self" onmousedown="return false;"><img id="{$editor_id}_wordpress_more" src="{$pluginurl}/images/more.gif" title="More..." width="20" height="20" class="mceButtonNormal" onmouseover="tinyMCE.switchClass(this,\'mceButtonOver\');" onmouseout="tinyMCE.restoreClass(this);" onmousedown="tinyMCE.restoreAndSwitchClass(this,\'mceButtonDown\');" /></a><!--<a href="javascript:tinyMCE.execInstanceCommand(\'{$editor_id}\',\'mcewordpresspage\')" target="_self" onmousedown="return false;"><img id="{$editor_id}_wordpress_page" src="{$pluginurl}/images/page.gif" title="...Page..." width="20" height="20" class="mceButtonNormal" onmouseover="tinyMCE.switchClass(this,\'mceButtonOver\');" onmouseout="tinyMCE.restoreClass(this);" onmousedown="tinyMCE.restoreAndSwitchClass(this,\'mceButtonDown\');" /></a>-->';
    1313    }
    1414
     
    6666        }
    6767
    68     // Handle commands
    69     switch (command) {
     68        // Handle commands
     69        switch (command) {
    7070                        case "mcewordpressmore":
    71                                 var name = "";
     71                                var flag = "";
    7272                                var template = new Array();
    7373                                var inst = tinyMCE.getInstanceById(editor_id);
     
    7676                                // Is selection a image
    7777                                if (focusElm != null && focusElm.nodeName.toLowerCase() == "img") {
    78                                         name = getAttrib(focusElm, 'name');
    79        
    80                                         if (name != 'mce_plugin_wordpress_more') // Not a wordpress
     78                                        flag = getAttrib(focusElm, 'class');
     79       
     80                                        if (flag != 'mce_plugin_wordpress_more') // Not a wordpress
    8181                                                return true;
    8282       
     
    8585       
    8686                                html = ''
    87                 + '<img src="' + (tinyMCE.getParam("theme_href") + "/images/spacer.gif") + '" '
     87                                        + '<img src="' + (tinyMCE.getParam("theme_href") + "/images/spacer.gif") + '" '
    8888                                        + ' width="100%" height="10px" '
    8989                                        + 'alt="More..." title="More..." class="mce_plugin_wordpress_more" name="mce_plugin_wordpress_more" />';
    90               tinyMCE.execCommand("mceInsertContent",true,html);
     90                                tinyMCE.execCommand("mceInsertContent",true,html);
    9191                                tinyMCE.selectedInstance.repaint();
    9292                                return true;
    9393                        case "mcewordpresspage":
    94                                 var name = "";
     94                                var flag = "";
    9595                                var template = new Array();
    9696                                var inst = tinyMCE.getInstanceById(editor_id);
     
    9999                                // Is selection a image
    100100                                if (focusElm != null && focusElm.nodeName.toLowerCase() == "img") {
    101                                         name = getAttrib(focusElm, 'name');
    102        
    103                                         if (name != 'mce_plugin_wordpress_page') // Not a wordpress
     101                                        flag = getAttrib(focusElm, 'name');
     102       
     103                                        if (flag != 'mce_plugin_wordpress_page') // Not a wordpress
    104104                                                return true;
    105105       
     
    108108       
    109109                                html = ''
    110                 + '<img src="' + (tinyMCE.getParam("theme_href") + "/images/spacer.gif") + '" '
     110                                        + '<img src="' + (tinyMCE.getParam("theme_href") + "/images/spacer.gif") + '" '
    111111                                        + ' width="100%" height="10px" '
    112112                                        + 'alt="More..." title="More..." class="mce_plugin_wordpress_page" name="mce_plugin_wordpress_page" />';
    113               tinyMCE.execCommand("mceInsertContent",true,html);
     113                                tinyMCE.execCommand("mceInsertContent",true,html);
    114114                                tinyMCE.selectedInstance.repaint();
    115115                                return true;
    116    }
    117 
    118    // Pass to next handler in chain
    119    return false;
     116        }
     117
     118        // Pass to next handler in chain
     119        return false;
    120120}
    121121
     
    131131                                var contentAfter = content.substring(startPos + 11);
    132132                                content = content.substring(0, startPos);
    133               content += '<img src="' + (tinyMCE.getParam("theme_href") + "/images/spacer.gif") + '" ';
     133                                content += '<img src="' + (tinyMCE.getParam("theme_href") + "/images/spacer.gif") + '" ';
    134134                                content += ' width="100%" height="10px" ';
    135                                 content += 'alt="More..." title="More..." class="mce_plugin_wordpress_more" name="mce_plugin_wordpress_more" />';
     135                                content += 'alt="More..." title="More..." class="mce_plugin_wordpress_more" />';
    136136                                content += contentAfter;
    137137
     
    145145                                var contentAfter = content.substring(startPos + 15);
    146146                                content = content.substring(0, startPos);
    147               content += '<img src="' + (tinyMCE.getParam("theme_href") + "/images/spacer.gif") + '" ';
     147                                content += '<img src="' + (tinyMCE.getParam("theme_href") + "/images/spacer.gif") + '" ';
    148148                                content += ' width="100%" height="10px" ';
    149                                 content += 'alt="...Next Page..." title="...Next Page..." class="mce_plugin_wordpress_page" name="mce_plugin_wordpress_page" />';
     149                                content += 'alt="...Next Page..." title="...Next Page..." class="mce_plugin_wordpress_page" />';
    150150                                content += contentAfter;
    151151
     
    161161                                var attribs = TinyMCE_wordpress_parseAttributes(content.substring(startPos + 4, endPos));
    162162
    163                                 if (attribs['name'] == "mce_plugin_wordpress_more") {
     163                                if (attribs['class'] == "mce_plugin_wordpress_more") {
    164164                                        endPos += 2;
    165165       
     
    171171                                        content = chunkBefore + embedHTML + chunkAfter;
    172172                                }
    173                                 if (attribs['name'] == "mce_plugin_wordpress_page") {
     173                                if (attribs['class'] == "mce_plugin_wordpress_page") {
    174174                                        endPos += 2;
    175175       
     
    182182                                }
    183183                        }
     184
     185                        // Handle TinyMCE weirdness without messing up the core
     186                        //alert("Content before TinyMCE_wordpress_cleanup\n\n'"+content+"'");
     187
     188                        // Strip any trailing <br /> and whitespace.
     189                        content = content.replace(new RegExp('<br ?/?>[ \t]*$', ''), '');
     190
     191                        //alert("Content after TinyMCE_wordpress_cleanup\n\n'"+content+"'");
    184192                        break;
    185193        }
     
    201209
    202210        do {
    203                 if (node.nodeName.toLowerCase() == "img" && getAttrib(node, 'name').indexOf('mce_plugin_wordpress_more') == 0)
     211                if (node.nodeName.toLowerCase() == "img" && getAttrib(node, 'class').indexOf('mce_plugin_wordpress_more') == 0)
    204212                        tinyMCE.switchClassSticky(editor_id + '_wordpress_more', 'mceButtonSelected');
    205                 if (node.nodeName.toLowerCase() == "img" && getAttrib(node, 'name').indexOf('mce_plugin_wordpress_page') == 0)
     213                if (node.nodeName.toLowerCase() == "img" && getAttrib(node, 'class').indexOf('mce_plugin_wordpress_page') == 0)
    206214                        tinyMCE.switchClassSticky(editor_id + '_wordpress_page', 'mceButtonSelected');
    207215        } while ((node = node.parentNode));
  • trunk/wp-includes/js/tinymce/plugins/wordpress/editor_plugin_src.js

    r2820 r2964  
    1010    switch (control_name) {
    1111        case "wordpress":
    12             return '<img id="{$editor_id}_wordpress_more" src="{$pluginurl}/images/more.gif" title="More..." width="20" height="20" class="mceButtonNormal" onmouseover="tinyMCE.switchClass(this,\'mceButtonOver\');" onmouseout="tinyMCE.restoreClass(this);" onmousedown="tinyMCE.restoreAndSwitchClass(this,\'mceButtonDown\');tinyMCE.execInstanceCommand(\'{$editor_id}\',\'mcewordpressmore\');" /><img id="{$editor_id}_wordpress_page" src="{$pluginurl}/images/page.gif" title="...Page..." width="20" height="20" class="mceButtonNormal" onmouseover="tinyMCE.switchClass(this,\'mceButtonOver\');" onmouseout="tinyMCE.restoreClass(this);" onmousedown="tinyMCE.restoreAndSwitchClass(this,\'mceButtonDown\');tinyMCE.execInstanceCommand(\'{$editor_id}\',\'mcewordpresspage\');" />';
     12            return '<a href="javascript:tinyMCE.execInstanceCommand(\'{$editor_id}\',\'mcewordpressmore\')" target="_self" onmousedown="return false;"><img id="{$editor_id}_wordpress_more" src="{$pluginurl}/images/more.gif" title="More..." width="20" height="20" class="mceButtonNormal" onmouseover="tinyMCE.switchClass(this,\'mceButtonOver\');" onmouseout="tinyMCE.restoreClass(this);" onmousedown="tinyMCE.restoreAndSwitchClass(this,\'mceButtonDown\');" /></a><!--<a href="javascript:tinyMCE.execInstanceCommand(\'{$editor_id}\',\'mcewordpresspage\')" target="_self" onmousedown="return false;"><img id="{$editor_id}_wordpress_page" src="{$pluginurl}/images/page.gif" title="...Page..." width="20" height="20" class="mceButtonNormal" onmouseover="tinyMCE.switchClass(this,\'mceButtonOver\');" onmouseout="tinyMCE.restoreClass(this);" onmousedown="tinyMCE.restoreAndSwitchClass(this,\'mceButtonDown\');" /></a>-->';
    1313    }
    1414
     
    6666        }
    6767
    68     // Handle commands
    69     switch (command) {
     68        // Handle commands
     69        switch (command) {
    7070                        case "mcewordpressmore":
    71                                 var name = "";
     71                                var flag = "";
    7272                                var template = new Array();
    7373                                var inst = tinyMCE.getInstanceById(editor_id);
     
    7676                                // Is selection a image
    7777                                if (focusElm != null && focusElm.nodeName.toLowerCase() == "img") {
    78                                         name = getAttrib(focusElm, 'name');
    79        
    80                                         if (name != 'mce_plugin_wordpress_more') // Not a wordpress
     78                                        flag = getAttrib(focusElm, 'class');
     79       
     80                                        if (flag != 'mce_plugin_wordpress_more') // Not a wordpress
    8181                                                return true;
    8282       
     
    8585       
    8686                                html = ''
    87                 + '<img src="' + (tinyMCE.getParam("theme_href") + "/images/spacer.gif") + '" '
     87                                        + '<img src="' + (tinyMCE.getParam("theme_href") + "/images/spacer.gif") + '" '
    8888                                        + ' width="100%" height="10px" '
    8989                                        + 'alt="More..." title="More..." class="mce_plugin_wordpress_more" name="mce_plugin_wordpress_more" />';
    90               tinyMCE.execCommand("mceInsertContent",true,html);
     90                                tinyMCE.execCommand("mceInsertContent",true,html);
    9191                                tinyMCE.selectedInstance.repaint();
    9292                                return true;
    9393                        case "mcewordpresspage":
    94                                 var name = "";
     94                                var flag = "";
    9595                                var template = new Array();
    9696                                var inst = tinyMCE.getInstanceById(editor_id);
     
    9999                                // Is selection a image
    100100                                if (focusElm != null && focusElm.nodeName.toLowerCase() == "img") {
    101                                         name = getAttrib(focusElm, 'name');
    102        
    103                                         if (name != 'mce_plugin_wordpress_page') // Not a wordpress
     101                                        flag = getAttrib(focusElm, 'name');
     102       
     103                                        if (flag != 'mce_plugin_wordpress_page') // Not a wordpress
    104104                                                return true;
    105105       
     
    108108       
    109109                                html = ''
    110                 + '<img src="' + (tinyMCE.getParam("theme_href") + "/images/spacer.gif") + '" '
     110                                        + '<img src="' + (tinyMCE.getParam("theme_href") + "/images/spacer.gif") + '" '
    111111                                        + ' width="100%" height="10px" '
    112112                                        + 'alt="More..." title="More..." class="mce_plugin_wordpress_page" name="mce_plugin_wordpress_page" />';
    113               tinyMCE.execCommand("mceInsertContent",true,html);
     113                                tinyMCE.execCommand("mceInsertContent",true,html);
    114114                                tinyMCE.selectedInstance.repaint();
    115115                                return true;
    116    }
    117 
    118    // Pass to next handler in chain
    119    return false;
     116        }
     117
     118        // Pass to next handler in chain
     119        return false;
    120120}
    121121
     
    131131                                var contentAfter = content.substring(startPos + 11);
    132132                                content = content.substring(0, startPos);
    133               content += '<img src="' + (tinyMCE.getParam("theme_href") + "/images/spacer.gif") + '" ';
     133                                content += '<img src="' + (tinyMCE.getParam("theme_href") + "/images/spacer.gif") + '" ';
    134134                                content += ' width="100%" height="10px" ';
    135                                 content += 'alt="More..." title="More..." class="mce_plugin_wordpress_more" name="mce_plugin_wordpress_more" />';
     135                                content += 'alt="More..." title="More..." class="mce_plugin_wordpress_more" />';
    136136                                content += contentAfter;
    137137
     
    145145                                var contentAfter = content.substring(startPos + 15);
    146146                                content = content.substring(0, startPos);
    147               content += '<img src="' + (tinyMCE.getParam("theme_href") + "/images/spacer.gif") + '" ';
     147                                content += '<img src="' + (tinyMCE.getParam("theme_href") + "/images/spacer.gif") + '" ';
    148148                                content += ' width="100%" height="10px" ';
    149                                 content += 'alt="...Next Page..." title="...Next Page..." class="mce_plugin_wordpress_page" name="mce_plugin_wordpress_page" />';
     149                                content += 'alt="...Next Page..." title="...Next Page..." class="mce_plugin_wordpress_page" />';
    150150                                content += contentAfter;
    151151
     
    161161                                var attribs = TinyMCE_wordpress_parseAttributes(content.substring(startPos + 4, endPos));
    162162
    163                                 if (attribs['name'] == "mce_plugin_wordpress_more") {
     163                                if (attribs['class'] == "mce_plugin_wordpress_more") {
    164164                                        endPos += 2;
    165165       
     
    171171                                        content = chunkBefore + embedHTML + chunkAfter;
    172172                                }
    173                                 if (attribs['name'] == "mce_plugin_wordpress_page") {
     173                                if (attribs['class'] == "mce_plugin_wordpress_page") {
    174174                                        endPos += 2;
    175175       
     
    182182                                }
    183183                        }
     184
     185                        // Handle TinyMCE weirdness without messing up the core
     186                        //alert("Content before TinyMCE_wordpress_cleanup\n\n'"+content+"'");
     187
     188                        // Strip any trailing <br /> and whitespace.
     189                        content = content.replace(new RegExp('<br ?/?>[ \t]*$', ''), '');
     190
     191                        //alert("Content after TinyMCE_wordpress_cleanup\n\n'"+content+"'");
    184192                        break;
    185193        }
     
    201209
    202210        do {
    203                 if (node.nodeName.toLowerCase() == "img" && getAttrib(node, 'name').indexOf('mce_plugin_wordpress_more') == 0)
     211                if (node.nodeName.toLowerCase() == "img" && getAttrib(node, 'class').indexOf('mce_plugin_wordpress_more') == 0)
    204212                        tinyMCE.switchClassSticky(editor_id + '_wordpress_more', 'mceButtonSelected');
    205                 if (node.nodeName.toLowerCase() == "img" && getAttrib(node, 'name').indexOf('mce_plugin_wordpress_page') == 0)
     213                if (node.nodeName.toLowerCase() == "img" && getAttrib(node, 'class').indexOf('mce_plugin_wordpress_page') == 0)
    206214                        tinyMCE.switchClassSticky(editor_id + '_wordpress_page', 'mceButtonSelected');
    207215        } while ((node = node.parentNode));
Note: See TracChangeset for help on using the changeset viewer.