From: <com...@fc...> - 2010-03-22 16:04:14
|
Author: garry.yao Date: 2010-03-22 17:04:40 +0100 (Mon, 22 Mar 2010) New Revision: 5265 Modified: CKEditor/trunk/CHANGES.html CKEditor/trunk/_source/plugins/colorbutton/plugin.js CKEditor/trunk/_source/plugins/styles/plugin.js Log: #5242: More robust way of removing styles with same property name. Modified: CKEditor/trunk/CHANGES.html =================================================================== --- CKEditor/trunk/CHANGES.html 2010-03-22 15:57:04 UTC (rev 5264) +++ CKEditor/trunk/CHANGES.html 2010-03-22 16:04:40 UTC (rev 5265) @@ -82,6 +82,7 @@ <li><a href="http://dev.fckeditor.net/ticket/5238">#5238</a> : Menu button doesn't display arrow icon in high-contrast mode.</li> <li><a href="http://dev.fckeditor.net/ticket/3576">#3576</a> : Non-attributed element of the same name with the applied style is correctly removed.</li> <li><a href="http://dev.fckeditor.net/ticket/5221">#5221</a> : Insert table into empty document cause JavaScript error thrown.</li> + <li><a href="http://dev.fckeditor.net/ticket/5242">#5242</a> : Apply 'automatic' color option of text color incorrectly removes background-color style.</li> </ul> <h3> CKEditor 3.2</h3> Modified: CKEditor/trunk/_source/plugins/colorbutton/plugin.js =================================================================== --- CKEditor/trunk/_source/plugins/colorbutton/plugin.js 2010-03-22 15:57:04 UTC (rev 5264) +++ CKEditor/trunk/_source/plugins/colorbutton/plugin.js 2010-03-22 16:04:40 UTC (rev 5265) @@ -86,7 +86,7 @@ panel.hide(); - var style = new CKEDITOR.style( config['colorButton_' + type + 'Style'], color && { color : color } ); + var style = new CKEDITOR.style( config['colorButton_' + type + 'Style'], { color : color || 'inherit' } ); editor.fire( 'saveSnapshot' ); if ( color ) Modified: CKEditor/trunk/_source/plugins/styles/plugin.js =================================================================== --- CKEditor/trunk/_source/plugins/styles/plugin.js 2010-03-22 15:57:04 UTC (rev 5264) +++ CKEditor/trunk/_source/plugins/styles/plugin.js 2010-03-22 16:04:40 UTC (rev 5265) @@ -1,4 +1,4 @@ -/* +/* Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved. For licensing, see LICENSE.html or http://ckeditor.com/license */ @@ -251,9 +251,9 @@ continue; var elementAttr = element.getAttribute( attName ) || ''; - if ( attribs[ attName ] == - ( attName == 'style' ? - normalizeCssText( elementAttr, false ) : elementAttr ) ) + if ( attName == 'style' ? + compareCssText( attribs[ attName ], normalizeCssText( elementAttr, false ) ) + : attribs[ attName ] == elementAttr ) { if ( !fullMatch ) return true; @@ -1230,7 +1230,39 @@ .replace( /,\s+/g, ',' ) // Trimming spaces after comma (e.g. font-family name)(#4107). .toLowerCase(); } + + // Turn inline style text properties into one hash. + function parseStyleText( styleText ) + { + var retval = {}; + styleText + .replace( /"/g, '"' ) + .replace( /\s*([^ :;]+)\s*:\s*([^;]+)\s*(?=;|$)/g, function( match, name, value ) + { + retval[ name ] = value; + } ); + return retval; + } + function compareCssText( source, target ) + { + typeof source == 'string' && ( source = parseStyleText( source ) ); + typeof target == 'string' && ( target = parseStyleText( target ) ); + for( var name in source ) + { + // Value 'inheirt' is treated as a wildcard, + // which will matches any value. + if ( !( name in target && + ( target[ name ] == source[ name ] + || source[ name ] == 'inherit' + || target[ name ] == 'inherit' ) ) ) + { + return false; + } + } + return true; + } + function applyStyle( document, remove ) { // Get all ranges from the selection. |