/*\r
-Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.\r
+Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved.\r
For licensing, see LICENSE.html or http://ckeditor.com/license\r
*/\r
\r
if ( attName == '_length' )\r
continue;\r
\r
- var elementAttr = element.getAttribute( attName );\r
- if ( attribs[attName] ==\r
+ var elementAttr = element.getAttribute( attName ) || '';\r
+ if ( attribs[ attName ] ==\r
( attName == 'style' ?\r
normalizeCssText( elementAttr, false ) : elementAttr ) )\r
{\r
else if ( fullMatch )\r
return false;\r
}\r
- if( fullMatch )\r
+ if ( fullMatch )\r
return true;\r
}\r
else\r
stylesText = stylesText.replace( semicolonFixRegex, ';' );\r
\r
for ( var style in stylesDef )\r
- stylesText += style + ':' + stylesDef[ style ] + ';';\r
+ stylesText += ( style + ':' + stylesDef[ style ] ).replace( semicolonFixRegex, ';' );\r
\r
// Browsers make some changes to the style when applying them. So, here\r
// we normalize it to the browser format.\r
}\r
\r
// Check if the current node can be a child of the style element.\r
- if ( !nodeName || ( dtd[ nodeName ] && ( currentNode.getPosition( lastNode ) | CKEDITOR.POSITION_PRECEDING | CKEDITOR.POSITION_IDENTICAL | CKEDITOR.POSITION_IS_CONTAINED ) == ( CKEDITOR.POSITION_PRECEDING + CKEDITOR.POSITION_IDENTICAL + CKEDITOR.POSITION_IS_CONTAINED ) ) )\r
+ if ( !nodeName || ( dtd[ nodeName ]\r
+ && ( currentNode.getPosition( lastNode ) | CKEDITOR.POSITION_PRECEDING | CKEDITOR.POSITION_IDENTICAL | CKEDITOR.POSITION_IS_CONTAINED ) == ( CKEDITOR.POSITION_PRECEDING + CKEDITOR.POSITION_IDENTICAL + CKEDITOR.POSITION_IS_CONTAINED )\r
+ && ( !def.childRule || def.childRule( currentNode ) ) ) )\r
{\r
var currentParent = currentNode.getParent();\r
\r
// Check if the style element can be a child of the current\r
// node parent or if the element is not defined in the DTD.\r
- if ( currentParent && ( ( currentParent.getDtd() || CKEDITOR.dtd.span )[ elementName ] || isUnknownElement ) )\r
+ if ( currentParent\r
+ && ( ( currentParent.getDtd() || CKEDITOR.dtd.span )[ elementName ] || isUnknownElement )\r
+ && ( !def.parentRule || def.parentRule( currentParent ) ) )\r
{\r
// This node will be part of our range, so if it has not\r
// been started, place its start right before the node.\r
// to the range.\r
while ( !includedNode.$.nextSibling\r
&& ( parentNode = includedNode.getParent(), dtd[ parentNode.getName() ] )\r
- && ( parentNode.getPosition( firstNode ) | CKEDITOR.POSITION_FOLLOWING | CKEDITOR.POSITION_IDENTICAL | CKEDITOR.POSITION_IS_CONTAINED ) == ( CKEDITOR.POSITION_FOLLOWING + CKEDITOR.POSITION_IDENTICAL + CKEDITOR.POSITION_IS_CONTAINED ) )\r
+ && ( parentNode.getPosition( firstNode ) | CKEDITOR.POSITION_FOLLOWING | CKEDITOR.POSITION_IDENTICAL | CKEDITOR.POSITION_IS_CONTAINED ) == ( CKEDITOR.POSITION_FOLLOWING + CKEDITOR.POSITION_IDENTICAL + CKEDITOR.POSITION_IS_CONTAINED )\r
+ && ( !def.childRule || def.childRule( parentNode ) ) )\r
{\r
includedNode = parentNode;\r
}\r
if ( newElement.equals( boundaryElement ) )\r
break;\r
// Avoid copying any matched element.\r
- else if( newElement.match )\r
+ else if ( newElement.match )\r
continue;\r
else\r
newElement = newElement.clone();\r
if ( currentNode.type == CKEDITOR.NODE_ELEMENT && this.checkElementRemovable( currentNode ) )\r
{\r
// Remove style from element or overriding element.\r
- if( currentNode.getName() == this.element )\r
+ if ( currentNode.getName() == this.element )\r
removeFromElement( this, currentNode );\r
else\r
removeOverrides( currentNode, getOverrides( this )[ currentNode.getName() ] );\r
var doc = range.document;\r
var previousPreBlock;\r
\r
- while( ( block = iterator.getNextParagraph() ) ) // Only one =\r
+ while ( ( block = iterator.getNextParagraph() ) ) // Only one =\r
{\r
var newBlock = getElement( this, doc );\r
replaceBlock( block, newBlock );\r
\r
// Now remove override styles on the element.\r
attributes = overrides[ element.getName() ];\r
- if( attributes )\r
+ if ( attributes )\r
removeAttrs();\r
removeNoAttribsElement( element );\r
}\r
*/\r
function getOverrides( style )\r
{\r
- if( style._.overrides )\r
+ if ( style._.overrides )\r
return style._.overrides;\r
\r
var overrides = ( style._.overrides = {} ),\r
// retrieving its final format.\r
var temp = new CKEDITOR.dom.element( 'span' );\r
temp.setAttribute( 'style', unparsedCssText );\r
- styleText = temp.getAttribute( 'style' );\r
+ styleText = temp.getAttribute( 'style' ) || '';\r
}\r
else\r
styleText = unparsedCssText;\r
// Compensate tail semi-colon.\r
return styleText.replace( /\s*([;:])\s*/, '$1' )\r
.replace( /([^\s;])$/, '$1;')\r
+ .replace( /,\s+/g, ',' ) // Trimming spaces after comma (e.g. font-family name)(#4107).\r
.toLowerCase();\r
}\r
\r
\r
return !!doc;\r
};\r
+\r
+CKEDITOR.stylesSet = new CKEDITOR.resourceManager( '', 'stylesSet' );\r
+\r
+// Backward compatibility (#5025).\r
+CKEDITOR.addStylesSet = CKEDITOR.tools.bind( CKEDITOR.stylesSet.add, CKEDITOR.stylesSet );\r
+CKEDITOR.loadStylesSet = function( name, url, callback )\r
+ {\r
+ CKEDITOR.stylesSet.addExternal( name, url, '' );\r
+ CKEDITOR.stylesSet.load( name, callback );\r
+ };\r