tinyMCE 2.0.5 coming at you live. fixes #2598

git-svn-id: http://svn.automattic.com/wordpress/trunk@3664 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan
2006-03-30 07:50:33 +00:00
parent 73ef659763
commit a7337fded7
84 changed files with 12391 additions and 6362 deletions

View File

@@ -1,285 +1,400 @@
/* Import plugin specific language pack */
tinyMCE.importPluginLanguagePack('wordpress', '');
function TinyMCE_wordpress_initInstance(inst) {
if (!tinyMCE.settings['wordpress_skip_plugin_css'])
tinyMCE.importCSS(inst.getDoc(), tinyMCE.baseURL + "/plugins/wordpress/wordpress.css");
}
function TinyMCE_wordpress_getControlHTML(control_name) {
switch (control_name) {
case "wordpress":
var titleMore = tinyMCE.getLang('lang_wordpress_more_button');
var titlePage = tinyMCE.getLang('lang_wordpress_page_button');
var titleHelp = tinyMCE.getLang('lang_wordpress_help_button');
var buttons = '<a href="javascript:tinyMCE.execInstanceCommand(\'{$editor_id}\',\'mcewordpressmore\')" target="_self" onclick="tinyMCE.execInstanceCommand(\'{$editor_id}\',\'mcewordpressmore\');return false;"><img id="{$editor_id}_wordpress_more" src="{$pluginurl}/images/more.gif" title="'+titleMore+'" width="20" height="20" class="mceButtonNormal" onmouseover="tinyMCE.switchClass(this,\'mceButtonOver\');" onmouseout="tinyMCE.restoreClass(this);" onmousedown="tinyMCE.restoreAndSwitchClass(this,\'mceButtonDown\');" /></a>';
// Add this to the buttons var to put the Page button into the toolbar.
// '<a href="javascript:tinyMCE.execInstanceCommand(\'{$editor_id}\',\'mcewordpresspage\')" target="_self" onclick="javascript:tinyMCE.execInstanceCommand(\'{$editor_id}\',\'mcewordpresspage\');return false;"><img id="{$editor_id}_wordpress_page" src="{$pluginurl}/images/page.gif" title="'+titlePage+'" width="20" height="20" class="mceButtonNormal" onmouseover="tinyMCE.switchClass(this,\'mceButtonOver\');" onmouseout="tinyMCE.restoreClass(this);" onmousedown="tinyMCE.restoreAndSwitchClass(this,\'mceButtonDown\');" /></a>';
return buttons;
}
return '';
}
function TinyMCE_wordpress_parseAttributes(attribute_string) {
var attributeName = "";
var attributeValue = "";
var withInName;
var withInValue;
var attributes = new Array();
var whiteSpaceRegExp = new RegExp('^[ \n\r\t]+', 'g');
var titleText = tinyMCE.getLang('lang_wordpress_more');
var titleTextPage = tinyMCE.getLang('lang_wordpress_page');
if (attribute_string == null || attribute_string.length < 2)
return null;
withInName = withInValue = false;
for (var i=0; i<attribute_string.length; i++) {
var chr = attribute_string.charAt(i);
if ((chr == '"' || chr == "'") && !withInValue)
withInValue = true;
else if ((chr == '"' || chr == "'") && withInValue) {
withInValue = false;
var pos = attributeName.lastIndexOf(' ');
if (pos != -1)
attributeName = attributeName.substring(pos+1);
attributes[attributeName.toLowerCase()] = attributeValue.substring(1).toLowerCase();
attributeName = "";
attributeValue = "";
} else if (!whiteSpaceRegExp.test(chr) && !withInName && !withInValue)
withInName = true;
if (chr == '=' && withInName)
withInName = false;
if (withInName)
attributeName += chr;
if (withInValue)
attributeValue += chr;
}
return attributes;
}
function TinyMCE_wordpress_execCommand(editor_id, element, command, user_interface, value) {
var inst = tinyMCE.getInstanceById(editor_id);
var focusElm = inst.getFocusElement();
var doc = inst.getDoc();
function getAttrib(elm, name) {
return elm.getAttribute(name) ? elm.getAttribute(name) : "";
}
// Handle commands
switch (command) {
case "mcewordpressmore":
var flag = "";
var template = new Array();
var altMore = tinyMCE.getLang('lang_wordpress_more_alt');
// Is selection a image
if (focusElm != null && focusElm.nodeName.toLowerCase() == "img") {
flag = getAttrib(focusElm, 'class');
if (flag != 'mce_plugin_wordpress_more') // Not a wordpress
return true;
action = "update";
}
html = ''
+ '<img src="' + (tinyMCE.getParam("theme_href") + "/images/spacer.gif") + '" '
+ ' width="100%" height="10px" '
+ 'alt="'+altMore+'" title="'+altMore+'" class="mce_plugin_wordpress_more" name="mce_plugin_wordpress_more" />';
tinyMCE.execCommand("mceInsertContent",true,html);
tinyMCE.selectedInstance.repaint();
return true;
case "mcewordpresspage":
var flag = "";
var template = new Array();
var altPage = tinyMCE.getLang('lang_wordpress_more_alt');
// Is selection a image
if (focusElm != null && focusElm.nodeName.toLowerCase() == "img") {
flag = getAttrib(focusElm, 'name');
if (flag != 'mce_plugin_wordpress_page') // Not a wordpress
return true;
action = "update";
}
html = ''
+ '<img src="' + (tinyMCE.getParam("theme_href") + "/images/spacer.gif") + '" '
+ ' width="100%" height="10px" '
+ 'alt="'+altPage+'" title="'+altPage+'" class="mce_plugin_wordpress_page" name="mce_plugin_wordpress_page" />';
tinyMCE.execCommand("mceInsertContent",true,html);
tinyMCE.selectedInstance.repaint();
return true;
}
// Pass to next handler in chain
return false;
}
function TinyMCE_wordpress_cleanup(type, content) {
switch (type) {
case "insert_to_editor":
var startPos = 0;
var altMore = tinyMCE.getLang('lang_wordpress_more_alt');
var altPage = tinyMCE.getLang('lang_wordpress_page_alt');
// Parse all <!--more--> tags and replace them with images
while ((startPos = content.indexOf('<!--more-->', startPos)) != -1) {
// Insert image
var contentAfter = content.substring(startPos + 11);
content = content.substring(0, startPos);
content += '<img src="' + (tinyMCE.getParam("theme_href") + "/images/spacer.gif") + '" ';
content += ' width="100%" height="10px" ';
content += 'alt="'+altMore+'" title="'+altMore+'" class="mce_plugin_wordpress_more" />';
content += contentAfter;
startPos++;
}
var startPos = 0;
// Parse all <!--page--> tags and replace them with images
while ((startPos = content.indexOf('<!--nextpage-->', startPos)) != -1) {
// Insert image
var contentAfter = content.substring(startPos + 15);
content = content.substring(0, startPos);
content += '<img src="' + (tinyMCE.getParam("theme_href") + "/images/spacer.gif") + '" ';
content += ' width="100%" height="10px" ';
content += 'alt="'+altPage+'" title="'+altPage+'" class="mce_plugin_wordpress_page" />';
content += contentAfter;
startPos++;
}
// It's supposed to be WYSIWYG, right?
content = content.replace(new RegExp('&', 'g'), '&amp;');
break;
case "get_from_editor":
// Parse all img tags and replace them with <!--more-->
var startPos = -1;
while ((startPos = content.indexOf('<img', startPos+1)) != -1) {
var endPos = content.indexOf('/>', startPos);
var attribs = TinyMCE_wordpress_parseAttributes(content.substring(startPos + 4, endPos));
if (attribs['class'] == "mce_plugin_wordpress_more") {
endPos += 2;
var embedHTML = '<!--more-->';
// Insert embed/object chunk
chunkBefore = content.substring(0, startPos);
chunkAfter = content.substring(endPos);
content = chunkBefore + embedHTML + chunkAfter;
}
if (attribs['class'] == "mce_plugin_wordpress_page") {
endPos += 2;
var embedHTML = '<!--nextpage-->';
// Insert embed/object chunk
chunkBefore = content.substring(0, startPos);
chunkAfter = content.substring(endPos);
content = chunkBefore + embedHTML + chunkAfter;
}
}
// If it says & in the WYSIWYG editor, it should say &amp; in the html.
content = content.replace(new RegExp('&', 'g'), '&amp;');
content = content.replace(new RegExp('&amp;nbsp;', 'g'), '&nbsp;');
// Remove anonymous, empty paragraphs.
content = content.replace(new RegExp('<p>(\\s|&nbsp;)*</p>', 'mg'), '');
// Handle table badness.
content = content.replace(new RegExp('<(table( [^>]*)?)>.*?<((tr|thead)( [^>]*)?)>', 'mg'), '<$1><$3>');
content = content.replace(new RegExp('<(tr|thead|tfoot)>.*?<((td|th)( [^>]*)?)>', 'mg'), '<$1><$2>');
content = content.replace(new RegExp('</(td|th)>.*?<(td( [^>]*)?|th( [^>]*)?|/tr|/thead|/tfoot)>', 'mg'), '</$1><$2>');
content = content.replace(new RegExp('</tr>.*?<(tr|/table)>', 'mg'), '</tr><$1>');
content = content.replace(new RegExp('<(/?(table|tbody|tr|th|td)[^>]*)>(\\s*|(<br ?/?>)*)*', 'g'), '<$1>');
// Pretty it up for the source editor.
var blocklist = 'blockquote|ul|ol|li|table|thead|tr|th|td|div|h\\d|pre|p';
content = content.replace(new RegExp('\\s*</('+blocklist+')>\\s*', 'mg'), '</$1>\n');
content = content.replace(new RegExp('\\s*<(('+blocklist+')[^>]*)>\\s*', 'mg'), '\n<$1>');
content = content.replace(new RegExp('<((li|/?tr|/?thead|/?tfoot)( [^>]*)?)>', 'g'), '\t<$1>');
content = content.replace(new RegExp('<((td|th)( [^>]*)?)>', 'g'), '\t\t<$1>');
content = content.replace(new RegExp('\\s*<br ?/?>\\s*', 'mg'), '<br />\n');
content = content.replace(new RegExp('^\\s*', ''), '');
content = content.replace(new RegExp('\\s*$', ''), '');
break;
}
// Pass through to next handler in chain
return content;
}
function TinyMCE_wordpress_handleNodeChange(editor_id, node, undo_index, undo_levels, visual_aid, any_selection) {
function getAttrib(elm, name) {
return elm.getAttribute(name) ? elm.getAttribute(name) : "";
}
tinyMCE.switchClassSticky(editor_id + '_wordpress_more', 'mceButtonNormal');
tinyMCE.switchClassSticky(editor_id + '_wordpress_page', 'mceButtonNormal');
if (node == null)
return;
do {
if (node.nodeName.toLowerCase() == "img" && getAttrib(node, 'class').indexOf('mce_plugin_wordpress_more') == 0)
tinyMCE.switchClassSticky(editor_id + '_wordpress_more', 'mceButtonSelected');
if (node.nodeName.toLowerCase() == "img" && getAttrib(node, 'class').indexOf('mce_plugin_wordpress_page') == 0)
tinyMCE.switchClassSticky(editor_id + '_wordpress_page', 'mceButtonSelected');
} while ((node = node.parentNode));
return true;
}
function wp_save_callback(el, content, body) {
// We have a TON of cleanup to do.
// Mark </p> if it has any attributes.
content = content.replace(new RegExp('(<p[^>]+>.*?)</p>', 'mg'), '$1</p#>');
// Decode the ampersands of time.
content = content.replace(new RegExp('&amp;', 'g'), '&');
// Get it ready for wpautop.
content = content.replace(new RegExp('[\\s]*<p>[\\s]*', 'mgi'), '');
content = content.replace(new RegExp('[\\s]*</p>[\\s]*', 'mgi'), '\n\n');
content = content.replace(new RegExp('\\n\\s*\\n\\s*\\n*', 'mgi'), '\n\n');
content = content.replace(new RegExp('\\s*<br ?/?>\\s*', 'gi'), '\n');
// Fix some block element newline issues
var blocklist = 'blockquote|ul|ol|li|table|thead|tr|th|td|div|h\\d|pre';
content = content.replace(new RegExp('\\s*<(('+blocklist+') ?[^>]*)\\s*>', 'mg'), '\n<$1>');
content = content.replace(new RegExp('\\s*</('+blocklist+')>\\s*', 'mg'), '</$1>\n');
content = content.replace(new RegExp('<li>', 'g'), '\t<li>');
// Unmark special paragraph closing tags
content = content.replace(new RegExp('</p#>', 'g'), '</p>\n');
content = content.replace(new RegExp('\\s*(<p[^>]+>.*</p>)', 'mg'), '\n$1');
// Trim any whitespace
content = content.replace(new RegExp('^\\s*', ''), '');
content = content.replace(new RegExp('\\s*$', ''), '');
// Hope.
return content;
}
/* Import plugin specific language pack */
tinyMCE.importPluginLanguagePack('wordpress', 'en');
var TinyMCE_wordpressPlugin = {
getInfo : function() {
return {
longname : 'WordPress Plugin',
author : 'WordPress',
authorurl : 'http://wordpress.org',
infourl : 'http://wordpress.org',
version : '1'
};
},
getControlHTML : function(control_name) {
switch (control_name) {
case "wp_more":
return tinyMCE.getButtonHTML(control_name, 'lang_wordpress_more_button', '{$pluginurl}/images/more.gif', 'wpMore');
case "wp_page":
return tinyMCE.getButtonHTML(control_name, 'lang_wordpress_page_button', '{$pluginurl}/images/page.gif', 'wpPage');
case "wp_help":
var buttons = tinyMCE.getButtonHTML(control_name, 'lang_help_button_title', '{$pluginurl}/images/help.gif', 'wpHelp');
var hiddenControls = '<div class="zerosize">'
+ '<input type="button" accesskey="n" onclick="tinyMCE.execInstanceCommand(\'{$editor_id}\',\'mceSpellCheck\',false);" />'
+ '<input type="button" accesskey="k" onclick="tinyMCE.execInstanceCommand(\'{$editor_id}\',\'Strikethrough\',false);" />'
+ '<input type="button" accesskey="l" onclick="tinyMCE.execInstanceCommand(\'{$editor_id}\',\'InsertUnorderedList\',false);" />'
+ '<input type="button" accesskey="o" onclick="tinyMCE.execInstanceCommand(\'{$editor_id}\',\'InsertOrderedList\',false);" />'
+ '<input type="button" accesskey="w" onclick="tinyMCE.execInstanceCommand(\'{$editor_id}\',\'Outdent\',false);" />'
+ '<input type="button" accesskey="q" onclick="tinyMCE.execInstanceCommand(\'{$editor_id}\',\'Indent\',false);" />'
+ '<input type="button" accesskey="f" onclick="tinyMCE.execInstanceCommand(\'{$editor_id}\',\'JustifyLeft\',false);" />'
+ '<input type="button" accesskey="c" onclick="tinyMCE.execInstanceCommand(\'{$editor_id}\',\'JustifyCenter\',false);" />'
+ '<input type="button" accesskey="r" onclick="tinyMCE.execInstanceCommand(\'{$editor_id}\',\'JustifyRight\',false);" />'
+ '<input type="button" accesskey="j" onclick="tinyMCE.execInstanceCommand(\'{$editor_id}\',\'JustifyFull\',false);" />'
+ '<input type="button" accesskey="a" onclick="tinyMCE.execInstanceCommand(\'{$editor_id}\',\'mceLink\',true);" />'
+ '<input type="button" accesskey="s" onclick="tinyMCE.execInstanceCommand(\'{$editor_id}\',\'unlink\',false);" />'
+ '<input type="button" accesskey="m" onclick="tinyMCE.execInstanceCommand(\'{$editor_id}\',\'mceImage\',true);" />'
+ '<input type="button" accesskey="t" onclick="tinyMCE.execInstanceCommand(\'{$editor_id}\',\'wpMore\');" />'
+ '<input type="button" accesskey="g" onclick="tinyMCE.execInstanceCommand(\'{$editor_id}\',\'wpPage\');" />'
+ '<input type="button" accesskey="u" onclick="tinyMCE.execInstanceCommand(\'{$editor_id}\',\'Undo\',false);" />'
+ '<input type="button" accesskey="y" onclick="tinyMCE.execInstanceCommand(\'{$editor_id}\',\'Redo\',false);" />'
+ '<input type="button" accesskey="e" onclick="tinyMCE.execInstanceCommand(\'{$editor_id}\',\'mceCodeEditor\',false);" />'
+ '<input type="button" accesskey="h" onclick="tinyMCE.execInstanceCommand(\'{$editor_id}\',\'wpHelp\',false);" />'
+ '<input type="button" accesskey="b" onclick="tinyMCE.execInstanceCommand(\'{$editor_id}\',\'wpAdv\',false);" />'
+ '</div>';
return buttons+hiddenControls;
case "wp_adv":
return tinyMCE.getButtonHTML(control_name, 'lang_wordpress_adv_button', '{$pluginurl}/images/toolbars.gif', 'wpAdv');
case "wp_adv_start":
return '<div id="wpadvbar" style="display:none;"><br />';
case "wp_adv_end":
return '</div>';
}
return '';
},
execCommand : function(editor_id, element, command, user_interface, value) {
var inst = tinyMCE.getInstanceById(editor_id);
var focusElm = inst.getFocusElement();
var doc = inst.getDoc();
function getAttrib(elm, name) {
return elm.getAttribute(name) ? elm.getAttribute(name) : "";
}
// Handle commands
switch (command) {
case "wpMore":
var flag = "";
var template = new Array();
var altMore = tinyMCE.getLang('lang_wordpress_more_alt');
// Is selection a image
if (focusElm != null && focusElm.nodeName.toLowerCase() == "img") {
flag = getAttrib(focusElm, 'class');
if (flag != 'mce_plugin_wordpress_more') // Not a wordpress
return true;
action = "update";
}
html = ''
+ '<img src="' + (tinyMCE.getParam("theme_href") + "/images/spacer.gif") + '" '
+ ' width="100%" height="10px" '
+ 'alt="'+altMore+'" title="'+altMore+'" class="mce_plugin_wordpress_more" name="mce_plugin_wordpress_more" />';
tinyMCE.execInstanceCommand(editor_id, 'mceInsertContent', false, html);
tinyMCE.selectedInstance.repaint();
return true;
case "wpPage":
var flag = "";
var template = new Array();
var altPage = tinyMCE.getLang('lang_wordpress_more_alt');
// Is selection a image
if (focusElm != null && focusElm.nodeName.toLowerCase() == "img") {
flag = getAttrib(focusElm, 'name');
if (flag != 'mce_plugin_wordpress_page') // Not a wordpress
return true;
action = "update";
}
html = ''
+ '<img src="' + (tinyMCE.getParam("theme_href") + "/images/spacer.gif") + '" '
+ ' width="100%" height="10px" '
+ 'alt="'+altPage+'" title="'+altPage+'" class="mce_plugin_wordpress_page" name="mce_plugin_wordpress_page" />';
tinyMCE.execCommand("mceInsertContent",true,html);
tinyMCE.selectedInstance.repaint();
return true;
case "wpHelp":
var template = new Array();
template['file'] = tinyMCE.baseURL + '/wp-mce-help.php';
template['width'] = 480;
template['height'] = 380;
args = {
resizable : 'yes',
scrollbars : 'yes'
};
tinyMCE.openWindow(template, args);
return true;
case "wpAdv":
var adv = document.getElementById('wpadvbar');
if ( adv.style.display == 'none' ) {
adv.style.display = 'block';
tinyMCE.switchClass(editor_id + '_wp_adv', 'mceButtonSelected');
} else {
adv.style.display = 'none';
tinyMCE.switchClass(editor_id + '_wp_adv', 'mceButtonNormal');
}
return true;
}
// Pass to next handler in chain
return false;
},
cleanup : function(type, content) {
switch (type) {
case "insert_to_editor":
var startPos = 0;
var altMore = tinyMCE.getLang('lang_wordpress_more_alt');
var altPage = tinyMCE.getLang('lang_wordpress_page_alt');
// Parse all <!--more--> tags and replace them with images
while ((startPos = content.indexOf('<!--more-->', startPos)) != -1) {
// Insert image
var contentAfter = content.substring(startPos + 11);
content = content.substring(0, startPos);
content += '<img src="' + (tinyMCE.getParam("theme_href") + "/images/spacer.gif") + '" ';
content += ' width="100%" height="10px" ';
content += 'alt="'+altMore+'" title="'+altMore+'" class="mce_plugin_wordpress_more" name="mce_plugin_wordpress_more" />';
content += contentAfter;
startPos++;
}
var startPos = 0;
// Parse all <!--page--> tags and replace them with images
while ((startPos = content.indexOf('<!--nextpage-->', startPos)) != -1) {
// Insert image
var contentAfter = content.substring(startPos + 15);
content = content.substring(0, startPos);
content += '<img src="' + (tinyMCE.getParam("theme_href") + "/images/spacer.gif") + '" ';
content += ' width="100%" height="10px" ';
content += 'alt="'+altPage+'" title="'+altPage+'" class="mce_plugin_wordpress_page" name="mce_plugin_wordpress_page" />';
content += contentAfter;
startPos++;
}
// Look for \n in <pre>, replace with <br>
var startPos = -1;
while ((startPos = content.indexOf('<pre', startPos+1)) != -1) {
var endPos = content.indexOf('</pre>', startPos+1);
var innerPos = content.indexOf('>', startPos+1);
var chunkBefore = content.substring(0, innerPos);
var chunkAfter = content.substring(endPos);
var innards = content.substring(innerPos, endPos);
innards = innards.replace(/\n/g, '<br />');
content = chunkBefore + innards + chunkAfter;
}
break;
case "get_from_editor":
// Parse all img tags and replace them with <!--more-->
var startPos = -1;
while ((startPos = content.indexOf('<img', startPos+1)) != -1) {
var endPos = content.indexOf('/>', startPos);
var attribs = this._parseAttributes(content.substring(startPos + 4, endPos));
if (attribs['class'] == "mce_plugin_wordpress_more" || attribs['name'] == "mce_plugin_wordpress_more") {
endPos += 2;
var embedHTML = '<!--more-->';
// Insert embed/object chunk
chunkBefore = content.substring(0, startPos);
chunkAfter = content.substring(endPos);
content = chunkBefore + embedHTML + chunkAfter;
}
if (attribs['class'] == "mce_plugin_wordpress_page" || attribs['name'] == "mce_plugin_wordpress_page") {
endPos += 2;
var embedHTML = '<!--nextpage-->';
// Insert embed/object chunk
chunkBefore = content.substring(0, startPos);
chunkAfter = content.substring(endPos);
content = chunkBefore + embedHTML + chunkAfter;
}
}
// Remove normal line breaks
content = content.replace(/\n|\r/g, ' ');
// Look for <br> in <pre>, replace with \n
var startPos = -1;
while ((startPos = content.indexOf('<pre', startPos+1)) != -1) {
var endPos = content.indexOf('</pre>', startPos+1);
var innerPos = content.indexOf('>', startPos+1);
var chunkBefore = content.substring(0, innerPos);
var chunkAfter = content.substring(endPos);
var innards = content.substring(innerPos, endPos);
innards = innards.replace(new RegExp('<br\\s?/?>', 'g'), '\n');
innards = innards.replace(new RegExp('\\s$', ''), '');
content = chunkBefore + innards + chunkAfter;
}
// Remove anonymous, empty paragraphs.
content = content.replace(new RegExp('<p>(\\s|&nbsp;)*</p>', 'mg'), '');
// Handle table badness.
content = content.replace(new RegExp('<(table( [^>]*)?)>.*?<((tr|thead)( [^>]*)?)>', 'mg'), '<$1><$3>');
content = content.replace(new RegExp('<(tr|thead|tfoot)>.*?<((td|th)( [^>]*)?)>', 'mg'), '<$1><$2>');
content = content.replace(new RegExp('</(td|th)>.*?<(td( [^>]*)?|th( [^>]*)?|/tr|/thead|/tfoot)>', 'mg'), '</$1><$2>');
content = content.replace(new RegExp('</tr>.*?<(tr|/table)>', 'mg'), '</tr><$1>');
content = content.replace(new RegExp('<(/?(table|tbody|tr|th|td)[^>]*)>(\\s*|(<br ?/?>)*)*', 'g'), '<$1>');
// Pretty it up for the source editor.
var blocklist = 'blockquote|ul|ol|li|table|thead|tr|th|td|div|h\\d|pre|p';
content = content.replace(new RegExp('\\s*</('+blocklist+')>\\s*', 'mg'), '</$1>\n');
content = content.replace(new RegExp('\\s*<(('+blocklist+')[^>]*)>\\s*', 'mg'), '\n<$1>');
content = content.replace(new RegExp('<((li|/?tr|/?thead|/?tfoot)( [^>]*)?)>', 'g'), '\t<$1>');
content = content.replace(new RegExp('<((td|th)( [^>]*)?)>', 'g'), '\t\t<$1>');
content = content.replace(new RegExp('\\s*<br ?/?>\\s*', 'mg'), '<br />\n');
content = content.replace(new RegExp('^\\s*', ''), '');
content = content.replace(new RegExp('\\s*$', ''), '');
break;
}
// Pass through to next handler in chain
return content;
},
handleNodeChange : function(editor_id, node, undo_index, undo_levels, visual_aid, any_selection) {
tinyMCE.switchClass(editor_id + '_wp_more', 'mceButtonNormal');
tinyMCE.switchClass(editor_id + '_wp_page', 'mceButtonNormal');
if (node == null)
return;
do {
if (node.nodeName.toLowerCase() == "img" && tinyMCE.getAttrib(node, 'class').indexOf('mce_plugin_wordpress_more') == 0)
tinyMCE.switchClass(editor_id + '_wp_more', 'mceButtonSelected');
if (node.nodeName.toLowerCase() == "img" && tinyMCE.getAttrib(node, 'class').indexOf('mce_plugin_wordpress_page') == 0)
tinyMCE.switchClass(editor_id + '_wp_page', 'mceButtonSelected');
} while ((node = node.parentNode));
return true;
},
saveCallback : function(el, content, body) {
// We have a TON of cleanup to do.
// Mark </p> if it has any attributes.
content = content.replace(new RegExp('(<p[^>]+>.*?)</p>', 'mg'), '$1</p#>');
// Decode the ampersands of time.
// content = content.replace(new RegExp('&amp;', 'g'), '&');
// Get it ready for wpautop.
content = content.replace(new RegExp('[\\s]*<p>[\\s]*', 'mgi'), '');
content = content.replace(new RegExp('[\\s]*</p>[\\s]*', 'mgi'), '\n\n');
content = content.replace(new RegExp('\\n\\s*\\n\\s*\\n*', 'mgi'), '\n\n');
content = content.replace(new RegExp('\\s*<br ?/?>\\s*', 'gi'), '\n');
// Fix some block element newline issues
var blocklist = 'blockquote|ul|ol|li|table|thead|tr|th|td|div|h\\d|pre';
content = content.replace(new RegExp('\\s*<(('+blocklist+') ?[^>]*)\\s*>', 'mg'), '\n<$1>');
content = content.replace(new RegExp('\\s*</('+blocklist+')>\\s*', 'mg'), '</$1>\n');
content = content.replace(new RegExp('<li>', 'g'), '\t<li>');
// Unmark special paragraph closing tags
content = content.replace(new RegExp('</p#>', 'g'), '</p>\n');
content = content.replace(new RegExp('\\s*(<p[^>]+>.*</p>)', 'mg'), '\n$1');
// Trim any whitespace
content = content.replace(new RegExp('^\\s*', ''), '');
content = content.replace(new RegExp('\\s*$', ''), '');
// Hope.
return content;
},
_parseAttributes : function(attribute_string) {
var attributeName = "";
var attributeValue = "";
var withInName;
var withInValue;
var attributes = new Array();
var whiteSpaceRegExp = new RegExp('^[ \n\r\t]+', 'g');
var titleText = tinyMCE.getLang('lang_wordpress_more');
var titleTextPage = tinyMCE.getLang('lang_wordpress_page');
if (attribute_string == null || attribute_string.length < 2)
return null;
withInName = withInValue = false;
for (var i=0; i<attribute_string.length; i++) {
var chr = attribute_string.charAt(i);
if ((chr == '"' || chr == "'") && !withInValue)
withInValue = true;
else if ((chr == '"' || chr == "'") && withInValue) {
withInValue = false;
var pos = attributeName.lastIndexOf(' ');
if (pos != -1)
attributeName = attributeName.substring(pos+1);
attributes[attributeName.toLowerCase()] = attributeValue.substring(1).toLowerCase();
attributeName = "";
attributeValue = "";
} else if (!whiteSpaceRegExp.test(chr) && !withInName && !withInValue)
withInName = true;
if (chr == '=' && withInName)
withInName = false;
if (withInName)
attributeName += chr;
if (withInValue)
attributeValue += chr;
}
return attributes;
}
};
tinyMCE.addPlugin("wordpress", TinyMCE_wordpressPlugin);
/* This little hack protects our More and Page placeholders from the removeformat command */
tinyMCE.orgExecCommand = tinyMCE.execCommand;
tinyMCE.execCommand = function (command, user_interface, value) {
re = this.orgExecCommand(command, user_interface, value);
if ( command == 'removeformat' ) {
var inst = tinyMCE.getInstanceById('mce_editor_0');
doc = inst.getDoc();
var imgs = doc.getElementsByTagName('img');
for (i=0;img=imgs[i];i++)
img.className = img.name;
}
return re;
};
tinyMCE.orgFixGeckoBaseHREFBug = tinyMCE.fixGeckoBaseHREFBug;
tinyMCE.fixGeckoBaseHREFBug = function(m, e, h) {
if ( tinyMCE.isGecko && m == 1 )
h = h.replace(new RegExp('<((a|img|select|area|iframe|base|input|script|embed|object|link)\\s([^>]*\\s)?)(src|href)\\s*=', 'gi'), '<$1 x$4=');
else
h = tinyMCE.orgFixGeckoBaseHREFBug(m, e, h);
return h;
};
tinyMCE.orgStoreAwayURLs = tinyMCE.storeAwayURLs;
tinyMCE.storeAwayURLs = function(s) {
// Remove all mce_src, mce_href and replace them with new ones
s = s.replace(new RegExp('mce_(href|src)\\s*=\\s*\"[^ >\"]*\"', 'gi'), '');
s = s.replace(new RegExp('<((a|img|select|area|iframe|base|input|script|embed|object|link)\\s([^>]*\\s)?)(src|href)\\s*=\\s*"([^"]*)"', 'gi'), '<$1 $4="$5" mce_$4="$5"');
return s;
};

Binary file not shown.

Before

Width:  |  Height:  |  Size: 92 B

After

Width:  |  Height:  |  Size: 295 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 260 B

View File

@@ -9,8 +9,25 @@ else {
}
tinyMCE.addToLang('',{
wordpress_more_button : 'Split post with More tag (' + metaKey + '-t)',
wordpress_more_button : 'Split post with More tag (' + metaKey + '+t)',
wordpress_page_button : 'Split post with Page tag',
wordpress_adv_button : 'Show/Hide Advanced Toolbar (' + metaKey + '+b)',
wordpress_more_alt : 'More...',
wordpress_page_alt : '...page...'
wordpress_page_alt : '...page...',
help_button_title : 'Help (' + metaKey + '+h)',
bold_desc : 'Bold (Ctrl+B)',
italic_desc : 'Italic (Ctrl+I)',
underline_desc : 'Underline (Ctrl+U)',
link_desc : 'Insert/edit link (' + metaKey + '+a)',
unlink_desc : 'Unlink (' + metaKey + '+s)',
image_desc : 'Insert/edit image (' + metaKey + '+m)',
striketrough_desc : 'Strikethrough (' + metaKey + '+k)',
justifyleft_desc : 'Align left (' + metaKey + '+f)',
justifycenter_desc : 'Align center (' + metaKey + '+c)',
justifyright_desc : 'Align right (' + metaKey + '+r)',
justifyfull_desc : 'Align full (' + metaKey + '+j)',
bullist_desc : 'Unordered list (' + metaKey + '+l)',
numlist_desc : 'Ordered list (' + metaKey + '+o)',
outdent_desc : 'Outdent (' + metaKey + '+w)',
indent_desc : 'Indent List/Blockquote (' + metaKey + '+q)'
});

View File

@@ -0,0 +1,354 @@
/* This file contains the CSS data for all popups in TinyMCE */
body {
background-color: #F0F0EE;
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 11px;
scrollbar-3dlight-color: #F0F0EE;
scrollbar-arrow-color: #676662;
scrollbar-base-color: #F0F0EE;
scrollbar-darkshadow-color: #DDDDDD;
scrollbar-face-color: #E0E0DD;
scrollbar-highlight-color: #F0F0EE;
scrollbar-shadow-color: #F0F0EE;
scrollbar-track-color: #F5F5F5;
margin: 8px;
}
td {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 11px;
}
input {
background: #FFFFFF;
border: 1px solid #cccccc;
}
td, input, select, textarea {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 10px;
}
input, select, textarea {
border: 1px solid #808080;
}
.input_noborder {
border: 0;
}
#insert, .updateButton {
font-weight: bold;
width: 90px;
height: 21px;
border: 0;
background-image: url('../images/insert_button_bg.gif');
cursor: pointer;
}
#cancel {
font-weight: bold;
width: 90px;
height: 21px;
border: 0;
background-image: url('../images/cancel_button_bg.gif');
cursor: pointer;
}
/* Mozilla only style */
html>body #insert, html>body #cancel {
padding-bottom: 2px;
}
.title {
display: block;
padding-top: 5px;
padding-bottom: 5px;
padding-left: 15px;
font-size: 15px;
}
table.charmap {
border-style: solid;
border-width: 1px;
border-color: #AAAAAA;
}
td.charmap, td.charmapOver {
color: #000000;
border-color: #AAAAAA;
border-style: solid;
border-width: 1px;
text-align: center;
font-size: 12px;
}
td.charmapOver {
background-color: #CCCCCC;
cursor: default;
}
a.charmap {
color: #000000;
text-decoration: none
}
.wordWrapCode {
vertical-align: middle;
border: 1px none #000000;
background-color: transparent;
}
input.radio {
border: 1px none #000000;
background-color: transparent;
vertical-align: middle;
}
input.checkbox {
border: 1px none #000000;
background-color: transparent;
vertical-align: middle;
}
.mceButtonNormal, .mceButtonOver, .mceButtonDown, .mceSeparator, .mceButtonDisabled, .mceButtonSelected {
margin-left: 1px;
}
.mceButtonNormal {
border-top: 1px solid;
border-left: 1px solid;
border-bottom: 1px solid;
border-right: 1px solid;
border-color: #F0F0EE;
cursor: default;
}
.mceButtonOver {
border: 1px solid #0A246A;
cursor: default;
background-color: #B6BDD2;
}
.mceButtonDown {
cursor: default;
border: 1px solid #0A246A;
background-color: #8592B5;
}
.mceButtonDisabled {
filter:progid:DXImageTransform.Microsoft.Alpha(opacity=30);
-moz-opacity:0.3;
opacity: 0.3;
border-top: 1px solid;
border-left: 1px solid;
border-bottom: 1px solid;
border-right: 1px solid;
border-color: #F0F0EE;
cursor: default;
}
.mceActionPanel {
margin-top: 5px;
}
/* Tabs classes */
.tabs {
float: left;
width: 100%;
line-height: normal;
background-image: url("../images/xp/tabs_bg.gif");
}
.tabs ul {
margin: 0;
padding: 0 0 0;
list-style: none;
}
.tabs li {
float: left;
background: url("../images/xp/tab_bg.gif") no-repeat left top;
margin: 0;
margin-left: 0;
margin-right: 2px;
padding: 0 0 0 10px;
line-height: 18px;
}
.tabs li.current {
background: url("../images/xp/tab_sel_bg.gif") no-repeat left top;
margin-right: 2px;
}
.tabs span {
float: left;
display: block;
background: url("../images/xp/tab_end.gif") no-repeat right top;
padding: 0px 10px 0 0;
}
.tabs .current span {
background: url("../images/xp/tab_sel_end.gif") no-repeat right top;
}
.tabs a {
text-decoration: none;
font-family: Verdana, Arial;
font-size: 10px;
}
.tabs a:link, .tabs a:visited, .tabs a:hover {
color: black;
}
.tabs a:hover {
}
.tabs .current {
}
.tabs .current a, .tabs .current a:link, .tabs .current a:visited {
}
.panel_wrapper div.panel {
display: none;
}
.panel_wrapper div.current {
display: block;
width: 100%;
height: 300px;
overflow: visible; /* Should be auto but that breaks Safari */
}
.panel_wrapper {
border: 1px solid #919B9C;
border-top: 0px;
padding: 10px;
padding-top: 5px;
clear: both;
background-color: white;
}
fieldset {
border: 1px solid #919B9C;
font-family: Verdana, Arial;
font-size: 10px;
padding: 0;
margin: 0;
padding: 4px;
}
legend {
color: #2B6FB6;
font-weight: bold;
}
.properties {
width: 100%;
}
.properties .column1 {
}
.properties .column2 {
text-align: left;
}
a:link, a:visited {
color: black;
}
a:hover {
color: #2B6FB6;
}
#plugintable thead {
font-weight: bold;
background-color: #DDDDDD;
}
#plugintable, #about #plugintable td {
border: 1px solid #919B9C;
}
#plugintable {
width: 99%;
margin-top: 10px;
}
#pluginscontainer {
height: 290px;
overflow: auto;
}
/* MSIE Specific styles */
* html .panel_wrapper {
width: 100%;
}
.column {
float: left;
}
h1, h2, h3, h4 {
color: #2B6FB6;
margin: 0;
padding: 0;
padding-top: 5px;
}
h3 {
font-size: 14px;
}
#link .panel_wrapper, #link div.current {
height: 125px;
}
#image .panel_wrapper, #image div.current {
height: 190px;
}
/* Disables the advanced tab in the table plugin. */
/*
#table #advanced_tab {
display: none;
}
*/
/* Disables the border input field and label in the table plugin. */
/*
#table #border, #table #borderlabel {
display: none;
}
*/
#insert, #cancel, .submitbutton {
font: 13px Verdana, Arial, Helvetica, sans-serif;
height: auto;
width: auto;
background-color: transparent;
background-image: url(../../../../../wp-admin/images/fade-butt.png);
background-repeat: repeat;
border: 3px double;
border-right-color: rgb(153, 153, 153);
border-bottom-color: rgb(153, 153, 153);
border-left-color: rgb(204, 204, 204);
border-top-color: rgb(204, 204, 204);
color: rgb(51, 51, 51);
padding: 0.25em 0.75em;
}
#insert:active, #cancel:active, .submitbutton:active {
background: #f4f4f4;
border-left-color: #999;
border-top-color: #999;
}

View File

@@ -19,3 +19,66 @@
background-repeat: no-repeat;
background-position: right top;
}
/* This file contains the CSS data for the editable area(iframe) of TinyMCE */
/* You can extend this CSS by adding your own CSS file with the the content_css option */
body {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 0.9em;
line-height: 1.2em;
padding: .3em;
background-color: #FFFFFF;
}
td {
font-size: 10px;
}
pre {
font-family: "Courier New", fixed;
font-size: 11px;
line-height: 13px;
}
.mceVisualAid {
border: 1px dashed #BBBBBB !important;
}
.mceItemAnchor {
width: 12px;
line-height: 6px;
overflow: hidden;
padding-left: 12px;
background-image: url('../images/anchor_symbol.gif');
background-position: bottom;
background-repeat: no-repeat;
}
/* Important is needed in Gecko browsers inorder to style links */
/*
a {
color: green !important;
}
*/
/* Style selection range colors in Gecko browsers */
/*
::-moz-selection {
background-color: red;
color: green;
}
*/
/* MSIE specific */
* html body {
scrollbar-3dlight-color: #F0F0EE;
scrollbar-arrow-color: #676662;
scrollbar-base-color: #F0F0EE;
scrollbar-darkshadow-color: #DDDDDD;
scrollbar-face-color: #E0E0DD;
scrollbar-highlight-color: #F0F0EE;
scrollbar-shadow-color: #F0F0EE;
scrollbar-track-color: #F5F5F5;
}