Fixing several problems with TiynMCE, triggering of autosave() on an empty post in Safari 3.1, <br> tags in FF, <object> tag may break if switching from Visual to HTML mode and back several times, little cleanup of the compressor and others. Props azaozz. fixes #6384

git-svn-id: http://svn.automattic.com/wordpress/trunk@7513 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2008-03-26 03:22:53 +00:00
parent e05db09acb
commit 8895454664
9 changed files with 60 additions and 42 deletions

View File

@ -32,7 +32,7 @@ switchEditors = {
content = content.replace(new RegExp('\\s*<(('+blocklist1+')[^>]*)>', 'mg'), '\n<$1>'); content = content.replace(new RegExp('\\s*<(('+blocklist1+')[^>]*)>', 'mg'), '\n<$1>');
// Mark </p> if it has any attributes. // Mark </p> if it has any attributes.
content = content.replace(new RegExp('(<p[^>]+>.*?)</p>', 'mg'), '$1</p#>'); content = content.replace(new RegExp('(<p [^>]+>.*?)</p>', 'mg'), '$1</p#>');
// Sepatate <div> containing <p> // Sepatate <div> containing <p>
content = content.replace(new RegExp('<div([^>]*)>\\s*<p>', 'mgi'), '<div$1>\n\n'); content = content.replace(new RegExp('<div([^>]*)>\\s*<p>', 'mgi'), '<div$1>\n\n');
@ -59,7 +59,7 @@ switchEditors = {
// Unmark special paragraph closing tags // Unmark special paragraph closing tags
content = content.replace(new RegExp('</p#>', 'g'), '</p>\n'); content = content.replace(new RegExp('</p#>', 'g'), '</p>\n');
content = content.replace(new RegExp('\\s*(<p[^>]+>.*</p>)', 'mg'), '\n$1'); content = content.replace(new RegExp('\\s*(<p [^>]+>.*</p>)', 'mg'), '\n$1');
// Trim whitespace // Trim whitespace
content = content.replace(new RegExp('^\\s*', ''), ''); content = content.replace(new RegExp('^\\s*', ''), '');

File diff suppressed because one or more lines are too long

View File

@ -1,6 +1,6 @@
/* Clearlooks 2 */ /* Clearlooks 2 */
/* Reset */ /* Reset */
.clearlooks2 div, .clearlooks2 span, .clearlooks2 a {vertical-align:baseline; text-align:left; position:absolute; border:0; padding:0; margin:0; background:transparent; font-family:Arial,Verdana; font-size:11px; color:#000; text-decoration:none; font-weight:normal; width:auto; height:auto; overflow:hidden; display:block;} .clearlooks2, .clearlooks2 div, .clearlooks2 span, .clearlooks2 a {vertical-align:baseline; text-align:left; position:absolute; border:0; padding:0; margin:0; background:transparent; font-family:Arial,Verdana; font-size:11px; color:#000; text-decoration:none; font-weight:normal; width:auto; height:auto; overflow:hidden; display:block;}
/* General */ /* General */
.clearlooks2 div, .clearlooks2 span, .clearlooks2 a {position:absolute; border:0; padding:0; margin:0; background:transparent; font-family:Arial,Verdana; font-size:11px; color:#000; text-decoration:none; font-weight:normal; width:auto; height:auto; overflow:hidden; display:block;} .clearlooks2 div, .clearlooks2 span, .clearlooks2 a {position:absolute; border:0; padding:0; margin:0; background:transparent; font-family:Arial,Verdana; font-size:11px; color:#000; text-decoration:none; font-weight:normal; width:auto; height:auto; overflow:hidden; display:block;}

File diff suppressed because one or more lines are too long

View File

@ -8,8 +8,10 @@ var AnchorDialog = {
elm = ed.dom.getParent(ed.selection.getNode(), 'A,IMG'); elm = ed.dom.getParent(ed.selection.getNode(), 'A,IMG');
v = ed.dom.getAttrib(elm, 'name'); v = ed.dom.getAttrib(elm, 'name');
if (v) if (v) {
this.action = 'update';
f.anchorName.value = v; f.anchorName.value = v;
}
f.insert.value = ed.getLang(elm ? 'update' : 'insert'); f.insert.value = ed.getLang(elm ? 'update' : 'insert');
}, },
@ -18,7 +20,9 @@ var AnchorDialog = {
var ed = this.editor; var ed = this.editor;
tinyMCEPopup.restoreSelection(); tinyMCEPopup.restoreSelection();
ed.selection.collapse(1);
if (this.action != 'update')
ed.selection.collapse(1);
// Webkit acts weird if empty inline element is inserted so we need to use a image instead // Webkit acts weird if empty inline element is inserted so we need to use a image instead
if (tinymce.isWebKit) if (tinymce.isWebKit)

File diff suppressed because one or more lines are too long

View File

@ -57,16 +57,6 @@ if ( $https ) str_replace('http://', 'https://', $mce_css);
$mce_locale = ( '' == get_locale() ) ? 'en' : strtolower( substr(get_locale(), 0, 2) ); // only ISO 639-1 $mce_locale = ( '' == get_locale() ) ? 'en' : strtolower( substr(get_locale(), 0, 2) ); // only ISO 639-1
/*
Setting mce_valid_elements to *[*] skips all of the internal cleanup and can cause problems.
The minimal setting would be -strong/-b[*],-em/-i[*],*[*].
Best is to use the default cleanup by not specifying mce_valid_elements. It contains full set of XHTML 1.0.
If others are needed, mce_extended_valid_elements can be used to add to it, or mce_invalid_elements to remove.
*/
$valid_elements = apply_filters('mce_valid_elements', '');
$invalid_elements = apply_filters('mce_invalid_elements', '');
$extended_valid_elements = apply_filters('mce_extended_valid_elements', '');
/* /*
The following filter allows localization scripts to change the languages displayed in the spellchecker's drop-down menu. The following filter allows localization scripts to change the languages displayed in the spellchecker's drop-down menu.
By default it uses Google's spellchecker API, but can be configured to use PSpell/ASpell if installed on the server. By default it uses Google's spellchecker API, but can be configured to use PSpell/ASpell if installed on the server.
@ -104,7 +94,7 @@ if ( ! empty($mce_external_plugins) ) {
if ( ! empty($mce_external_languages) ) { if ( ! empty($mce_external_languages) ) {
foreach ( $mce_external_languages as $name => $path ) { foreach ( $mce_external_languages as $name => $path ) {
if ( is_readable($path) ) { if ( is_file($path) && is_readable($path) ) {
include_once($path); include_once($path);
$ext_plugins .= $strings; $ext_plugins .= $strings;
$loaded_langs[] = $name; $loaded_langs[] = $name;
@ -162,6 +152,11 @@ $initArray = array (
'remove_script_host' => false, 'remove_script_host' => false,
'apply_source_formatting' => false, 'apply_source_formatting' => false,
'remove_linebreaks' => true, 'remove_linebreaks' => true,
'paste_auto_cleanup_on_paste' => true,
'paste_convert_middot_lists' => true,
'paste_remove_spans' => true,
'paste_remove_styles' => true,
'paste_strip_class_attributes' => 'all',
'gecko_spellcheck' => true, 'gecko_spellcheck' => true,
'entities' => '38,amp,60,lt,62,gt', 'entities' => '38,amp,60,lt,62,gt',
'accessibility_focus' => false, 'accessibility_focus' => false,
@ -175,13 +170,12 @@ $initArray = array (
'old_cache_max' => '1' // number of cache files to keep 'old_cache_max' => '1' // number of cache files to keep
); );
if ( $valid_elements ) $initArray['valid_elements'] = $valid_elements;
if ( $extended_valid_elements ) $initArray['extended_valid_elements'] = $extended_valid_elements;
if ( $invalid_elements ) $initArray['invalid_elements'] = $invalid_elements;
// For people who really REALLY know what they're doing with TinyMCE // For people who really REALLY know what they're doing with TinyMCE
// You can modify initArray to add, remove, change elements of the config before tinyMCE.init // You can modify initArray to add, remove, change elements of the config before tinyMCE.init (changed from action to filter)
$initArray = apply_filters('tiny_mce_before_init', $initArray); // changed from action to filter $initArray = apply_filters('tiny_mce_before_init', $initArray);
// Setting "valid_elements", "invalid_elements" and "extended_valid_elements" can be done through "tiny_mce_before_init".
// Best is to use the default cleanup by not specifying valid_elements, as TinyMCE contains full set of XHTML 1.0.
// support for deprecated actions // support for deprecated actions
ob_start(); ob_start();
@ -228,7 +222,7 @@ if ( $compress && isset($_SERVER['HTTP_ACCEPT_ENCODING']) ) {
// Setup cache info // Setup cache info
if ( $disk_cache ) { if ( $disk_cache ) {
$cacheKey = apply_filters('tiny_mce_version', '20080323'); $cacheKey = apply_filters('tiny_mce_version', '20080325');
foreach ( $initArray as $v ) foreach ( $initArray as $v )
$cacheKey .= $v; $cacheKey .= $v;
@ -308,6 +302,10 @@ if ( '.gz' == $cache_ext ) {
$content = gzencode( $content, 9, FORCE_GZIP ); $content = gzencode( $content, 9, FORCE_GZIP );
} }
// Stream to client
header( 'Content-Length: ' . strlen($content) );
echo $content;
// Write file // Write file
if ( '' != $cacheKey && is_dir($cache_path) && is_readable($cache_path) ) { if ( '' != $cacheKey && is_dir($cache_path) && is_readable($cache_path) ) {
@ -327,14 +325,7 @@ if ( '' != $cacheKey && is_dir($cache_path) && is_readable($cache_path) ) {
foreach ( $del_cache as $key ) foreach ( $del_cache as $key )
@unlink("$cache_path/$key"); @unlink("$cache_path/$key");
if ( putFileContents( $cache_file, $content ) && is_readable($cache_file) ) { putFileContents( $cache_file, $content );
$mtime = gmdate( "D, d M Y H:i:s", filemtime($cache_file) ) . " GMT";
header( 'Last-Modified: ' . $mtime );
header( 'Cache-Control: must-revalidate', false );
}
} }
// Stream to client
header( 'Content-Length: ' . strlen($content) );
echo $content;
?> ?>

View File

@ -4,7 +4,29 @@ body.mceContentBody {
background: #fff; background: #fff;
color: #000; color: #000;
font: 13px/19px "Lucida Grande","Lucida Sans Unicode",Tahoma,Verdana,sans-serif; font: 13px/19px "Lucida Grande","Lucida Sans Unicode",Tahoma,Verdana,sans-serif;
padding: .2em; padding: 0.6em;
margin: 0;
text-align: left;
}
body.mceForceColors {
background:#fff;
color:#000;
}
h1 {font-size: 2em}
h2 {font-size: 1.5em}
h3 {font-size: 1.17em}
h4 {font-size: 1em}
h5 {font-size: .83em}
h6 {font-size: .75em}
.mceItemTable, .mceItemTable td, .mceItemTable th, .mceItemTable caption, .mceItemVisualAid {
border: 1px dashed #BBB;
}
img {
border:0;
} }
td { td {
@ -15,15 +37,16 @@ pre {
font: 12px/18px "Courier New", monospace; font: 12px/18px "Courier New", monospace;
} }
.mceVisualAid { img.mceItemAnchor {
border: 1px dashed #BBBBBB !important; width: 12px;
height: 12px;
background: url(img/items.gif) no-repeat;
} }
.mceItemAnchor { a.mceItemAnchor {
width: 12px; width: 12px;
line-height: 6px; line-height: 6px;
overflow: hidden; overflow: hidden;
padding-left: 12px; padding-left: 12px;
background-position: bottom; background: url(img/items.gif) no-repeat bottom left;
background-repeat: no-repeat;
} }

View File

@ -33,10 +33,10 @@ class WP_Scripts {
$visual_editor = apply_filters('visual_editor', array('tiny_mce')); $visual_editor = apply_filters('visual_editor', array('tiny_mce'));
$this->add( 'editor', false, $visual_editor, '20080321' ); $this->add( 'editor', false, $visual_editor, '20080321' );
$this->add( 'editor_functions', '/wp-admin/js/editor.js', false, '20080321' ); $this->add( 'editor_functions', '/wp-admin/js/editor.js', false, '20080325' );
// Modify this version when tinyMCE plugins are changed. // Modify this version when tinyMCE plugins are changed.
$mce_version = apply_filters('tiny_mce_version', '20080323'); $mce_version = apply_filters('tiny_mce_version', '20080325');
$this->add( 'tiny_mce', '/wp-includes/js/tinymce/tiny_mce_config.php', array('editor_functions'), $mce_version ); $this->add( 'tiny_mce', '/wp-includes/js/tinymce/tiny_mce_config.php', array('editor_functions'), $mce_version );
$this->add( 'prototype', '/wp-includes/js/prototype.js', false, '1.6'); $this->add( 'prototype', '/wp-includes/js/prototype.js', false, '1.6');