mirror of
https://github.com/WordPress/WordPress.git
synced 2024-12-23 01:27:36 +01:00
tinyMCE updates from skeltoac. fixes #1991
git-svn-id: http://svn.automattic.com/wordpress/trunk@3265 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
38fbb47e77
commit
57ce56e8f4
@ -99,7 +99,7 @@ tinyMCE.init({
|
||||
theme_advanced_toolbar_align : "left",
|
||||
theme_advanced_path_location : "bottom",
|
||||
theme_advanced_resizing : true,
|
||||
browsers : "msie,gecko",
|
||||
browsers : "msie,gecko,opera",
|
||||
dialog_type : "modal",
|
||||
theme_advanced_resize_horizontal : false,
|
||||
entity_encoding : "raw",
|
||||
@ -110,7 +110,7 @@ tinyMCE.init({
|
||||
convert_newlines_to_brs : false,
|
||||
remove_linebreaks : true,
|
||||
save_callback : "wp_save_callback",
|
||||
valid_elements : "-a[id|href|title|rel],-strong/b,-em/i,-strike,-del,-u,p[class|align|dir],-ol,-ul,-li,br,img[class|src|alt|title|width|height|align],-sub,-sup,-blockquote[dir],-table[border=0|cellspacing|cellpadding|width|height|class|align|dir],tr[class|rowspan|width|height|align|valign|dir],td[dir|class|colspan|rowspan|width|height|align|valign],-div[dir|class|align],-span[class|align],-pre[class],-code[class],-address,-h1[class|align|dir],-h2[class|align|dir],-h3[class|align|dir],-h4[class|align|dir],-h5[class|align|dir],-h6[class|align|dir],hr",
|
||||
valid_elements : "-a[id|href|title|rel],-strong/b,-em/i,-strike,-del,-u,p[class|align|dir],-ol,-ul,-li,br,img[class|src|alt|title|width|height|align],-sub,-sup,-blockquote[dir],-table[border=0|cellspacing|cellpadding|width|height|class|align|dir],thead[class|rowspan|width|height|align|valign|dir],tr[class|rowspan|width|height|align|valign|dir],th[dir|class|colspan|rowspan|width|height|align|valign|scope],td[dir|class|colspan|rowspan|width|height|align|valign],-div[dir|class|align],-span[class|align],-pre[class],-code[class],-address,-h1[class|align|dir],-h2[class|align|dir],-h3[class|align|dir],-h4[class|align|dir],-h5[class|align|dir],-h6[class|align|dir],hr",
|
||||
plugins : "<?php echo $mce_plugins; ?>"
|
||||
<?php do_action('mce_options'); ?>
|
||||
});
|
||||
|
@ -200,15 +200,28 @@ function TinyMCE_wordpress_cleanup(type, content) {
|
||||
|
||||
// If it says & in the WYSIWYG editor, it should say & in the html.
|
||||
content = content.replace(new RegExp('&', 'g'), '&');
|
||||
content = content.replace(new RegExp('&nbsp;', 'g'), ' ');
|
||||
|
||||
// Remove anonymous, empty paragraphs.
|
||||
content = content.replace(new RegExp('<p>(\\s| )*</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';
|
||||
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>', 'g'), '\t<li>');
|
||||
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;
|
||||
}
|
||||
|
||||
|
6076
wp-includes/js/tinymce/tiny_mce.js
vendored
6076
wp-includes/js/tinymce/tiny_mce.js
vendored
File diff suppressed because one or more lines are too long
@ -37,6 +37,34 @@
|
||||
}
|
||||
}
|
||||
|
||||
function wp_compact_tinymce_js($text) {
|
||||
// This function was custom-made for TinyMCE 2.0, not expected to work with any other JS.
|
||||
|
||||
echo "\n//" . strlen(gzdeflate($text)) . " bytes gzdeflated\n";
|
||||
echo "//" . microtime() . " " . strlen($text) . " Micro Time Length\n";
|
||||
|
||||
// Strip comments
|
||||
$text = preg_replace("!(^|\s+)//.*$!m", '', $text);
|
||||
echo "//" . microtime() . " " . strlen($text) . " Stripped // comments\n";
|
||||
$text = preg_replace("!/\*.*?\*/!s", '', $text);
|
||||
echo "//" . microtime() . " " . strlen($text) . " Stripped /* */ comments\n";
|
||||
|
||||
// Strip leading tabs, carriage returns and unnecessary line breaks.
|
||||
$text = preg_replace("!^\t+!m", '', $text);
|
||||
echo "//" . microtime() . " " . strlen($text) . " Stripped leading tabs\n";
|
||||
$text = str_replace("\r", '', $text);
|
||||
echo "//" . microtime() . " " . strlen($text) . " Stripped returns\n";
|
||||
$text = preg_replace("!(^|{|}|;|:|\))\n!m", '\\1', $text);
|
||||
echo "//" . microtime() . " " . strlen($text) . " Stripped safe linebreaks\n";
|
||||
|
||||
// Strip spaces. This one is not generally economical.
|
||||
//$text = preg_replace("!\s*(\=|\=\=|\!\=|\<\=|\>\=|\+=|\+|\s|:|,)\s*!", '\\1', $text);
|
||||
//echo "//" . microtime() . " " . strlen($text) . " Stripped safe spaces\n";
|
||||
|
||||
echo "//" . strlen(gzdeflate($text)) . " bytes gzdeflated\n";
|
||||
return $text;
|
||||
}
|
||||
|
||||
// General options
|
||||
$suffix = ""; // Set to "_src" to use source version
|
||||
$expiresOffset = 3600 * 24 * 10; // 10 days util client cache expires
|
||||
@ -51,7 +79,7 @@
|
||||
// Only gzip the contents if clients and server support it
|
||||
$encodings = explode(',', strtolower($_SERVER['HTTP_ACCEPT_ENCODING']));
|
||||
if (in_array('gzip', $encodings) && function_exists('ob_gzhandler'))
|
||||
ob_start("ob_gzhandler");
|
||||
@ ob_start("ob_gzhandler"); // Don't let warnings foul up the JS
|
||||
|
||||
// Output rest of headers
|
||||
header("Content-type: text/javascript; charset: UTF-8");
|
||||
@ -62,7 +90,9 @@
|
||||
if ($index > -1) {
|
||||
// Write main script and patch some things
|
||||
if ($index == 0) {
|
||||
echo file_get_contents(realpath("tiny_mce" . $suffix . ".js"));
|
||||
// WP echo file_get_contents(realpath("tiny_mce" . $suffix . ".js"));
|
||||
$tinymce = file_get_contents(realpath("tiny_mce.js"));
|
||||
echo wp_compact_tinymce_js($tinymce);
|
||||
echo "\n\n";
|
||||
echo "TinyMCE.prototype.loadScript = function() {};\n";
|
||||
}
|
||||
|
0
wp-includes/js/tinymce/tiny_mce_src.js
vendored
0
wp-includes/js/tinymce/tiny_mce_src.js
vendored
Loading…
Reference in New Issue
Block a user