TinyMCE fixes. Reinstate "More..." button. Filter trailing br. fixes #1789
git-svn-id: http://svn.automattic.com/wordpress/trunk@2964 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
85a85a8aaf
commit
29c6e8b3e2
|
@ -87,7 +87,7 @@ tinyMCE.init({
|
||||||
textarea_trigger : "title",
|
textarea_trigger : "title",
|
||||||
width : "100%",
|
width : "100%",
|
||||||
theme : "advanced",
|
theme : "advanced",
|
||||||
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",
|
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",
|
||||||
theme_advanced_buttons2 : "",
|
theme_advanced_buttons2 : "",
|
||||||
theme_advanced_buttons3 : "",
|
theme_advanced_buttons3 : "",
|
||||||
theme_advanced_toolbar_location : "top",
|
theme_advanced_toolbar_location : "top",
|
||||||
|
@ -99,8 +99,9 @@ tinyMCE.init({
|
||||||
theme_advanced_resize_horizontal : false,
|
theme_advanced_resize_horizontal : false,
|
||||||
entity_encoding : "raw",
|
entity_encoding : "raw",
|
||||||
relative_urls : false,
|
relative_urls : false,
|
||||||
|
remove_script_host : false,
|
||||||
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",
|
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",
|
||||||
plugins : "autosave, contextmenu"
|
plugins : "contextmenu,wordpress"
|
||||||
<?php do_action('mce_options'); ?>
|
<?php do_action('mce_options'); ?>
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -9,7 +9,7 @@ function TinyMCE_wordpress_initInstance(inst) {
|
||||||
function TinyMCE_wordpress_getControlHTML(control_name) {
|
function TinyMCE_wordpress_getControlHTML(control_name) {
|
||||||
switch (control_name) {
|
switch (control_name) {
|
||||||
case "wordpress":
|
case "wordpress":
|
||||||
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\');" />';
|
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>-->';
|
||||||
}
|
}
|
||||||
|
|
||||||
return "";
|
return "";
|
||||||
|
@ -68,16 +68,16 @@ function TinyMCE_wordpress_execCommand(editor_id, element, command, user_interfa
|
||||||
// Handle commands
|
// Handle commands
|
||||||
switch (command) {
|
switch (command) {
|
||||||
case "mcewordpressmore":
|
case "mcewordpressmore":
|
||||||
var name = "";
|
var flag = "";
|
||||||
var template = new Array();
|
var template = new Array();
|
||||||
var inst = tinyMCE.getInstanceById(editor_id);
|
var inst = tinyMCE.getInstanceById(editor_id);
|
||||||
var focusElm = inst.getFocusElement();
|
var focusElm = inst.getFocusElement();
|
||||||
|
|
||||||
// Is selection a image
|
// Is selection a image
|
||||||
if (focusElm != null && focusElm.nodeName.toLowerCase() == "img") {
|
if (focusElm != null && focusElm.nodeName.toLowerCase() == "img") {
|
||||||
name = getAttrib(focusElm, 'name');
|
flag = getAttrib(focusElm, 'class');
|
||||||
|
|
||||||
if (name != 'mce_plugin_wordpress_more') // Not a wordpress
|
if (flag != 'mce_plugin_wordpress_more') // Not a wordpress
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
action = "update";
|
action = "update";
|
||||||
|
@ -91,16 +91,16 @@ function TinyMCE_wordpress_execCommand(editor_id, element, command, user_interfa
|
||||||
tinyMCE.selectedInstance.repaint();
|
tinyMCE.selectedInstance.repaint();
|
||||||
return true;
|
return true;
|
||||||
case "mcewordpresspage":
|
case "mcewordpresspage":
|
||||||
var name = "";
|
var flag = "";
|
||||||
var template = new Array();
|
var template = new Array();
|
||||||
var inst = tinyMCE.getInstanceById(editor_id);
|
var inst = tinyMCE.getInstanceById(editor_id);
|
||||||
var focusElm = inst.getFocusElement();
|
var focusElm = inst.getFocusElement();
|
||||||
|
|
||||||
// Is selection a image
|
// Is selection a image
|
||||||
if (focusElm != null && focusElm.nodeName.toLowerCase() == "img") {
|
if (focusElm != null && focusElm.nodeName.toLowerCase() == "img") {
|
||||||
name = getAttrib(focusElm, 'name');
|
flag = getAttrib(focusElm, 'name');
|
||||||
|
|
||||||
if (name != 'mce_plugin_wordpress_page') // Not a wordpress
|
if (flag != 'mce_plugin_wordpress_page') // Not a wordpress
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
action = "update";
|
action = "update";
|
||||||
|
@ -132,7 +132,7 @@ function TinyMCE_wordpress_cleanup(type, content) {
|
||||||
content = content.substring(0, startPos);
|
content = content.substring(0, startPos);
|
||||||
content += '<img src="' + (tinyMCE.getParam("theme_href") + "/images/spacer.gif") + '" ';
|
content += '<img src="' + (tinyMCE.getParam("theme_href") + "/images/spacer.gif") + '" ';
|
||||||
content += ' width="100%" height="10px" ';
|
content += ' width="100%" height="10px" ';
|
||||||
content += 'alt="More..." title="More..." class="mce_plugin_wordpress_more" name="mce_plugin_wordpress_more" />';
|
content += 'alt="More..." title="More..." class="mce_plugin_wordpress_more" />';
|
||||||
content += contentAfter;
|
content += contentAfter;
|
||||||
|
|
||||||
startPos++;
|
startPos++;
|
||||||
|
@ -146,7 +146,7 @@ function TinyMCE_wordpress_cleanup(type, content) {
|
||||||
content = content.substring(0, startPos);
|
content = content.substring(0, startPos);
|
||||||
content += '<img src="' + (tinyMCE.getParam("theme_href") + "/images/spacer.gif") + '" ';
|
content += '<img src="' + (tinyMCE.getParam("theme_href") + "/images/spacer.gif") + '" ';
|
||||||
content += ' width="100%" height="10px" ';
|
content += ' width="100%" height="10px" ';
|
||||||
content += 'alt="...Next Page..." title="...Next Page..." class="mce_plugin_wordpress_page" name="mce_plugin_wordpress_page" />';
|
content += 'alt="...Next Page..." title="...Next Page..." class="mce_plugin_wordpress_page" />';
|
||||||
content += contentAfter;
|
content += contentAfter;
|
||||||
|
|
||||||
startPos++;
|
startPos++;
|
||||||
|
@ -160,7 +160,7 @@ function TinyMCE_wordpress_cleanup(type, content) {
|
||||||
var endPos = content.indexOf('/>', startPos);
|
var endPos = content.indexOf('/>', startPos);
|
||||||
var attribs = TinyMCE_wordpress_parseAttributes(content.substring(startPos + 4, endPos));
|
var attribs = TinyMCE_wordpress_parseAttributes(content.substring(startPos + 4, endPos));
|
||||||
|
|
||||||
if (attribs['name'] == "mce_plugin_wordpress_more") {
|
if (attribs['class'] == "mce_plugin_wordpress_more") {
|
||||||
endPos += 2;
|
endPos += 2;
|
||||||
|
|
||||||
var embedHTML = '<!--more-->';
|
var embedHTML = '<!--more-->';
|
||||||
|
@ -170,7 +170,7 @@ function TinyMCE_wordpress_cleanup(type, content) {
|
||||||
chunkAfter = content.substring(endPos);
|
chunkAfter = content.substring(endPos);
|
||||||
content = chunkBefore + embedHTML + chunkAfter;
|
content = chunkBefore + embedHTML + chunkAfter;
|
||||||
}
|
}
|
||||||
if (attribs['name'] == "mce_plugin_wordpress_page") {
|
if (attribs['class'] == "mce_plugin_wordpress_page") {
|
||||||
endPos += 2;
|
endPos += 2;
|
||||||
|
|
||||||
var embedHTML = '<!--nextpage-->';
|
var embedHTML = '<!--nextpage-->';
|
||||||
|
@ -181,6 +181,14 @@ function TinyMCE_wordpress_cleanup(type, content) {
|
||||||
content = chunkBefore + embedHTML + chunkAfter;
|
content = chunkBefore + embedHTML + chunkAfter;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Handle TinyMCE weirdness without messing up the core
|
||||||
|
//alert("Content before TinyMCE_wordpress_cleanup\n\n'"+content+"'");
|
||||||
|
|
||||||
|
// Strip any trailing <br /> and whitespace.
|
||||||
|
content = content.replace(new RegExp('<br ?/?>[ \t]*$', ''), '');
|
||||||
|
|
||||||
|
//alert("Content after TinyMCE_wordpress_cleanup\n\n'"+content+"'");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -200,9 +208,9 @@ function TinyMCE_wordpress_handleNodeChange(editor_id, node, undo_index, undo_le
|
||||||
return;
|
return;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
if (node.nodeName.toLowerCase() == "img" && getAttrib(node, 'name').indexOf('mce_plugin_wordpress_more') == 0)
|
if (node.nodeName.toLowerCase() == "img" && getAttrib(node, 'class').indexOf('mce_plugin_wordpress_more') == 0)
|
||||||
tinyMCE.switchClassSticky(editor_id + '_wordpress_more', 'mceButtonSelected');
|
tinyMCE.switchClassSticky(editor_id + '_wordpress_more', 'mceButtonSelected');
|
||||||
if (node.nodeName.toLowerCase() == "img" && getAttrib(node, 'name').indexOf('mce_plugin_wordpress_page') == 0)
|
if (node.nodeName.toLowerCase() == "img" && getAttrib(node, 'class').indexOf('mce_plugin_wordpress_page') == 0)
|
||||||
tinyMCE.switchClassSticky(editor_id + '_wordpress_page', 'mceButtonSelected');
|
tinyMCE.switchClassSticky(editor_id + '_wordpress_page', 'mceButtonSelected');
|
||||||
} while ((node = node.parentNode));
|
} while ((node = node.parentNode));
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@ function TinyMCE_wordpress_initInstance(inst) {
|
||||||
function TinyMCE_wordpress_getControlHTML(control_name) {
|
function TinyMCE_wordpress_getControlHTML(control_name) {
|
||||||
switch (control_name) {
|
switch (control_name) {
|
||||||
case "wordpress":
|
case "wordpress":
|
||||||
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\');" />';
|
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>-->';
|
||||||
}
|
}
|
||||||
|
|
||||||
return "";
|
return "";
|
||||||
|
@ -68,16 +68,16 @@ function TinyMCE_wordpress_execCommand(editor_id, element, command, user_interfa
|
||||||
// Handle commands
|
// Handle commands
|
||||||
switch (command) {
|
switch (command) {
|
||||||
case "mcewordpressmore":
|
case "mcewordpressmore":
|
||||||
var name = "";
|
var flag = "";
|
||||||
var template = new Array();
|
var template = new Array();
|
||||||
var inst = tinyMCE.getInstanceById(editor_id);
|
var inst = tinyMCE.getInstanceById(editor_id);
|
||||||
var focusElm = inst.getFocusElement();
|
var focusElm = inst.getFocusElement();
|
||||||
|
|
||||||
// Is selection a image
|
// Is selection a image
|
||||||
if (focusElm != null && focusElm.nodeName.toLowerCase() == "img") {
|
if (focusElm != null && focusElm.nodeName.toLowerCase() == "img") {
|
||||||
name = getAttrib(focusElm, 'name');
|
flag = getAttrib(focusElm, 'class');
|
||||||
|
|
||||||
if (name != 'mce_plugin_wordpress_more') // Not a wordpress
|
if (flag != 'mce_plugin_wordpress_more') // Not a wordpress
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
action = "update";
|
action = "update";
|
||||||
|
@ -91,16 +91,16 @@ function TinyMCE_wordpress_execCommand(editor_id, element, command, user_interfa
|
||||||
tinyMCE.selectedInstance.repaint();
|
tinyMCE.selectedInstance.repaint();
|
||||||
return true;
|
return true;
|
||||||
case "mcewordpresspage":
|
case "mcewordpresspage":
|
||||||
var name = "";
|
var flag = "";
|
||||||
var template = new Array();
|
var template = new Array();
|
||||||
var inst = tinyMCE.getInstanceById(editor_id);
|
var inst = tinyMCE.getInstanceById(editor_id);
|
||||||
var focusElm = inst.getFocusElement();
|
var focusElm = inst.getFocusElement();
|
||||||
|
|
||||||
// Is selection a image
|
// Is selection a image
|
||||||
if (focusElm != null && focusElm.nodeName.toLowerCase() == "img") {
|
if (focusElm != null && focusElm.nodeName.toLowerCase() == "img") {
|
||||||
name = getAttrib(focusElm, 'name');
|
flag = getAttrib(focusElm, 'name');
|
||||||
|
|
||||||
if (name != 'mce_plugin_wordpress_page') // Not a wordpress
|
if (flag != 'mce_plugin_wordpress_page') // Not a wordpress
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
action = "update";
|
action = "update";
|
||||||
|
@ -132,7 +132,7 @@ function TinyMCE_wordpress_cleanup(type, content) {
|
||||||
content = content.substring(0, startPos);
|
content = content.substring(0, startPos);
|
||||||
content += '<img src="' + (tinyMCE.getParam("theme_href") + "/images/spacer.gif") + '" ';
|
content += '<img src="' + (tinyMCE.getParam("theme_href") + "/images/spacer.gif") + '" ';
|
||||||
content += ' width="100%" height="10px" ';
|
content += ' width="100%" height="10px" ';
|
||||||
content += 'alt="More..." title="More..." class="mce_plugin_wordpress_more" name="mce_plugin_wordpress_more" />';
|
content += 'alt="More..." title="More..." class="mce_plugin_wordpress_more" />';
|
||||||
content += contentAfter;
|
content += contentAfter;
|
||||||
|
|
||||||
startPos++;
|
startPos++;
|
||||||
|
@ -146,7 +146,7 @@ function TinyMCE_wordpress_cleanup(type, content) {
|
||||||
content = content.substring(0, startPos);
|
content = content.substring(0, startPos);
|
||||||
content += '<img src="' + (tinyMCE.getParam("theme_href") + "/images/spacer.gif") + '" ';
|
content += '<img src="' + (tinyMCE.getParam("theme_href") + "/images/spacer.gif") + '" ';
|
||||||
content += ' width="100%" height="10px" ';
|
content += ' width="100%" height="10px" ';
|
||||||
content += 'alt="...Next Page..." title="...Next Page..." class="mce_plugin_wordpress_page" name="mce_plugin_wordpress_page" />';
|
content += 'alt="...Next Page..." title="...Next Page..." class="mce_plugin_wordpress_page" />';
|
||||||
content += contentAfter;
|
content += contentAfter;
|
||||||
|
|
||||||
startPos++;
|
startPos++;
|
||||||
|
@ -160,7 +160,7 @@ function TinyMCE_wordpress_cleanup(type, content) {
|
||||||
var endPos = content.indexOf('/>', startPos);
|
var endPos = content.indexOf('/>', startPos);
|
||||||
var attribs = TinyMCE_wordpress_parseAttributes(content.substring(startPos + 4, endPos));
|
var attribs = TinyMCE_wordpress_parseAttributes(content.substring(startPos + 4, endPos));
|
||||||
|
|
||||||
if (attribs['name'] == "mce_plugin_wordpress_more") {
|
if (attribs['class'] == "mce_plugin_wordpress_more") {
|
||||||
endPos += 2;
|
endPos += 2;
|
||||||
|
|
||||||
var embedHTML = '<!--more-->';
|
var embedHTML = '<!--more-->';
|
||||||
|
@ -170,7 +170,7 @@ function TinyMCE_wordpress_cleanup(type, content) {
|
||||||
chunkAfter = content.substring(endPos);
|
chunkAfter = content.substring(endPos);
|
||||||
content = chunkBefore + embedHTML + chunkAfter;
|
content = chunkBefore + embedHTML + chunkAfter;
|
||||||
}
|
}
|
||||||
if (attribs['name'] == "mce_plugin_wordpress_page") {
|
if (attribs['class'] == "mce_plugin_wordpress_page") {
|
||||||
endPos += 2;
|
endPos += 2;
|
||||||
|
|
||||||
var embedHTML = '<!--nextpage-->';
|
var embedHTML = '<!--nextpage-->';
|
||||||
|
@ -181,6 +181,14 @@ function TinyMCE_wordpress_cleanup(type, content) {
|
||||||
content = chunkBefore + embedHTML + chunkAfter;
|
content = chunkBefore + embedHTML + chunkAfter;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Handle TinyMCE weirdness without messing up the core
|
||||||
|
//alert("Content before TinyMCE_wordpress_cleanup\n\n'"+content+"'");
|
||||||
|
|
||||||
|
// Strip any trailing <br /> and whitespace.
|
||||||
|
content = content.replace(new RegExp('<br ?/?>[ \t]*$', ''), '');
|
||||||
|
|
||||||
|
//alert("Content after TinyMCE_wordpress_cleanup\n\n'"+content+"'");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -200,9 +208,9 @@ function TinyMCE_wordpress_handleNodeChange(editor_id, node, undo_index, undo_le
|
||||||
return;
|
return;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
if (node.nodeName.toLowerCase() == "img" && getAttrib(node, 'name').indexOf('mce_plugin_wordpress_more') == 0)
|
if (node.nodeName.toLowerCase() == "img" && getAttrib(node, 'class').indexOf('mce_plugin_wordpress_more') == 0)
|
||||||
tinyMCE.switchClassSticky(editor_id + '_wordpress_more', 'mceButtonSelected');
|
tinyMCE.switchClassSticky(editor_id + '_wordpress_more', 'mceButtonSelected');
|
||||||
if (node.nodeName.toLowerCase() == "img" && getAttrib(node, 'name').indexOf('mce_plugin_wordpress_page') == 0)
|
if (node.nodeName.toLowerCase() == "img" && getAttrib(node, 'class').indexOf('mce_plugin_wordpress_page') == 0)
|
||||||
tinyMCE.switchClassSticky(editor_id + '_wordpress_page', 'mceButtonSelected');
|
tinyMCE.switchClassSticky(editor_id + '_wordpress_page', 'mceButtonSelected');
|
||||||
} while ((node = node.parentNode));
|
} while ((node = node.parentNode));
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue