/*\r
-Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved.\r
+Copyright (c) 2003-2012, CKSource - Frederico Knabben. All rights reserved.\r
For licensing, see LICENSE.html or http://ckeditor.com/license\r
*/\r
\r
CKEDITOR.plugins.add( 'styles',\r
{\r
- requires : [ 'selection' ]\r
+ requires : [ 'selection' ],\r
+ init : function( editor )\r
+ {\r
+ // This doesn't look like correct, but it's the safest way to proper\r
+ // pass the disableReadonlyStyling configuration to the style system\r
+ // without having to change any method signature in the API. (#6103)\r
+ editor.on( 'contentDom', function()\r
+ {\r
+ editor.document.setCustomData( 'cke_includeReadonly', !editor.config.disableReadonlyStyling );\r
+ });\r
+ }\r
});\r
\r
/**\r
- * Registers a function to be called whenever a style changes its state in the\r
+ * Registers a function to be called whenever the selection position changes in the\r
* editing area. The current state is passed to the function. The possible\r
* states are {@link CKEDITOR.TRISTATE_ON} and {@link CKEDITOR.TRISTATE_OFF}.\r
- * @param {CKEDITOR.style} The style to be watched.\r
- * @param {Function} The function to be called when the style state changes.\r
+ * @param {CKEDITOR.style} style The style to be watched.\r
+ * @param {Function} callback The function to be called.\r
* @example\r
* // Create a style object for the <b> element.\r
* var style = new CKEDITOR.style( { element : 'b' } );\r
// callback.\r
var currentState = callback.style.checkActive( ev.data.path ) ? CKEDITOR.TRISTATE_ON : CKEDITOR.TRISTATE_OFF;\r
\r
- // If the state changed since the last check.\r
- if ( callback.state !== currentState )\r
- {\r
- // Call the callback function, passing the current\r
- // state to it.\r
- callback.fn.call( this, currentState );\r
-\r
- // Save the current state, so it can be compared next\r
- // time.\r
- callback.state !== currentState;\r
- }\r
+ // Call the callback function, passing the current\r
+ // state to it.\r
+ callback.fn.call( this, currentState );\r
}\r
});\r
}\r
\r
- // Save the callback info, so it can be checked on the next occurence of\r
+ // Save the callback info, so it can be checked on the next occurrence of\r
// selectionChange.\r
styleStateChangeCallbacks.push( { style : style, fn : callback } );\r
};\r
\r
(function()\r
{\r
- var blockElements = { address:1,div:1,h1:1,h2:1,h3:1,h4:1,h5:1,h6:1,p:1,pre:1 };\r
- var objectElements = { a:1,embed:1,hr:1,img:1,li:1,object:1,ol:1,table:1,td:1,tr:1,ul:1 };\r
+ var blockElements = { address:1,div:1,h1:1,h2:1,h3:1,h4:1,h5:1,h6:1,p:1,pre:1,section:1,header:1,footer:1,nav:1,article:1,aside:1,figure:1,dialog:1,hgroup:1,time:1,meter:1,menu:1,command:1,keygen:1,output:1,progress:1,details:1,datagrid:1,datalist:1 },\r
+ objectElements = { a:1,embed:1,hr:1,img:1,li:1,object:1,ol:1,table:1,td:1,tr:1,th:1,ul:1,dl:1,dt:1,dd:1,form:1,audio:1,video:1 };\r
\r
- var semicolonFixRegex = /\s*(?:;\s*|$)/;\r
+ var semicolonFixRegex = /\s*(?:;\s*|$)/,\r
+ varRegex = /#\((.+?)\)/g;\r
+\r
+ var notBookmark = CKEDITOR.dom.walker.bookmark( 0, 1 ),\r
+ nonWhitespaces = CKEDITOR.dom.walker.whitespaces( 1 );\r
\r
CKEDITOR.style = function( styleDefinition, variablesValues )\r
{\r
+ // Inline style text as attribute should be converted\r
+ // to styles object.\r
+ var attrs = styleDefinition.attributes;\r
+ if ( attrs && attrs.style )\r
+ {\r
+ styleDefinition.styles = CKEDITOR.tools.extend( {},\r
+ styleDefinition.styles, parseStyleText( attrs.style ) );\r
+ delete attrs.style;\r
+ }\r
+\r
if ( variablesValues )\r
{\r
styleDefinition = CKEDITOR.tools.clone( styleDefinition );\r
replaceVariables( styleDefinition.styles, variablesValues );\r
}\r
\r
- var element = this.element = ( styleDefinition.element || '*' ).toLowerCase();\r
+ var element = this.element = styleDefinition.element ?\r
+ ( typeof styleDefinition.element == 'string' ? styleDefinition.element.toLowerCase() : styleDefinition.element )\r
+ : '*';\r
\r
this.type =\r
- ( element == '#' || blockElements[ element ] ) ?\r
+ blockElements[ element ] ?\r
CKEDITOR.STYLE_BLOCK\r
: objectElements[ element ] ?\r
CKEDITOR.STYLE_OBJECT\r
:\r
CKEDITOR.STYLE_INLINE;\r
\r
+ // If the 'element' property is an object with a set of possible element, it will be applied like an object style: only to existing elements\r
+ if ( typeof this.element == 'object' )\r
+ this.type = CKEDITOR.STYLE_OBJECT;\r
+\r
this._ =\r
{\r
definition : styleDefinition\r
applyInlineStyle\r
: this.type == CKEDITOR.STYLE_BLOCK ?\r
applyBlockStyle\r
+ : this.type == CKEDITOR.STYLE_OBJECT ?\r
+ applyObjectStyle\r
: null ).call( this, range );\r
},\r
\r
return ( this.removeFromRange =\r
this.type == CKEDITOR.STYLE_INLINE ?\r
removeInlineStyle\r
+ : this.type == CKEDITOR.STYLE_BLOCK ?\r
+ removeBlockStyle\r
+ : this.type == CKEDITOR.STYLE_OBJECT ?\r
+ removeObjectStyle\r
: null ).call( this, range );\r
},\r
\r
case CKEDITOR.STYLE_BLOCK :\r
return this.checkElementRemovable( elementPath.block || elementPath.blockLimit, true );\r
\r
+ case CKEDITOR.STYLE_OBJECT :\r
case CKEDITOR.STYLE_INLINE :\r
\r
var elements = elementPath.elements;\r
\r
for ( var i = 0, element ; i < elements.length ; i++ )\r
{\r
- element = elements[i];\r
+ element = elements[ i ];\r
\r
- if ( element == elementPath.block || element == elementPath.blockLimit )\r
+ if ( this.type == CKEDITOR.STYLE_INLINE\r
+ && ( element == elementPath.block || element == elementPath.blockLimit ) )\r
continue;\r
\r
+ if( this.type == CKEDITOR.STYLE_OBJECT )\r
+ {\r
+ var name = element.getName();\r
+ if ( !( typeof this.element == 'string' ? name == this.element : name in this.element ) )\r
+ continue;\r
+ }\r
+\r
if ( this.checkElementRemovable( element, true ) )\r
return true;\r
}\r
return false;\r
},\r
\r
- // Checks if an element, or any of its attributes, is removable by the\r
- // current style definition.\r
- checkElementRemovable : function( element, fullMatch )\r
+ /**\r
+ * Whether this style can be applied at the element path.\r
+ * @param elementPath\r
+ */\r
+ checkApplicable : function( elementPath )\r
+ {\r
+ switch ( this.type )\r
+ {\r
+ case CKEDITOR.STYLE_INLINE :\r
+ case CKEDITOR.STYLE_BLOCK :\r
+ break;\r
+\r
+ case CKEDITOR.STYLE_OBJECT :\r
+ return elementPath.lastElement.getAscendant( this.element, true );\r
+ }\r
+\r
+ return true;\r
+ },\r
+\r
+ // Check if the element matches the current style definition.\r
+ checkElementMatch : function( element, fullMatch )\r
{\r
- if ( !element )\r
+ var def = this._.definition;\r
+\r
+ if ( !element || !def.ignoreReadonly && element.isReadOnly() )\r
return false;\r
\r
- var def = this._.definition,\r
- attribs;\r
+ var attribs,\r
+ name = element.getName();\r
\r
// If the element name is the same as the style name.\r
- if ( element.getName() == this.element )\r
+ if ( typeof this.element == 'string' ? name == this.element : name in this.element )\r
{\r
// If no attributes are defined in the element.\r
if ( !fullMatch && !element.hasAttributes() )\r
continue;\r
\r
var elementAttr = element.getAttribute( attName ) || '';\r
- if ( attribs[ attName ] ==\r
- ( attName == 'style' ?\r
- normalizeCssText( elementAttr, false ) : elementAttr ) )\r
+\r
+ // Special treatment for 'style' attribute is required.\r
+ if ( attName == 'style' ?\r
+ compareCssText( attribs[ attName ], normalizeCssText( elementAttr, false ) )\r
+ : attribs[ attName ] == elementAttr )\r
{\r
if ( !fullMatch )\r
return true;\r
return true;\r
}\r
\r
- // Check if the element can be somehow overriden.\r
+ return false;\r
+ },\r
+\r
+ // Checks if an element, or any of its attributes, is removable by the\r
+ // current style definition.\r
+ checkElementRemovable : function( element, fullMatch )\r
+ {\r
+ // Check element matches the style itself.\r
+ if ( this.checkElementMatch( element, fullMatch ) )\r
+ return true;\r
+\r
+ // Check if the element matches the style overrides.\r
var override = getOverrides( this )[ element.getName() ] ;\r
if ( override )\r
{\r
+ var attribs, attName;\r
+\r
// If no attributes have been defined, remove the element.\r
if ( !( attribs = override.attributes ) )\r
return true;\r
}\r
}\r
return false;\r
+ },\r
+\r
+ // Builds the preview HTML based on the styles definition.\r
+ buildPreview : function( label )\r
+ {\r
+ var styleDefinition = this._.definition,\r
+ html = [],\r
+ elementName = styleDefinition.element;\r
+\r
+ // Avoid <bdo> in the preview.\r
+ if ( elementName == 'bdo' )\r
+ elementName = 'span';\r
+\r
+ html = [ '<', elementName ];\r
+\r
+ // Assign all defined attributes.\r
+ var attribs = styleDefinition.attributes;\r
+ if ( attribs )\r
+ {\r
+ for ( var att in attribs )\r
+ {\r
+ html.push( ' ', att, '="', attribs[ att ], '"' );\r
+ }\r
+ }\r
+\r
+ // Assign the style attribute.\r
+ var cssStyle = CKEDITOR.style.getStyleText( styleDefinition );\r
+ if ( cssStyle )\r
+ html.push( ' style="', cssStyle, '"' );\r
+\r
+ html.push( '>', ( label || styleDefinition.name ), '</', elementName, '>' );\r
+\r
+ return html.join( '' );\r
}\r
};\r
\r
stylesDef = styleDefinition.styles;\r
\r
// Builds the StyleText.\r
-\r
- var stylesText = ( styleDefinition.attributes && styleDefinition.attributes[ 'style' ] ) || '';\r
+ var stylesText = ( styleDefinition.attributes && styleDefinition.attributes[ 'style' ] ) || '',\r
+ specialStylesText = '';\r
\r
if ( stylesText.length )\r
stylesText = stylesText.replace( semicolonFixRegex, ';' );\r
\r
for ( var style in stylesDef )\r
- stylesText += ( style + ':' + stylesDef[ style ] ).replace( semicolonFixRegex, ';' );\r
+ {\r
+ var styleVal = stylesDef[ style ],\r
+ text = ( style + ':' + styleVal ).replace( semicolonFixRegex, ';' );\r
+\r
+ // Some browsers don't support 'inherit' property value, leave them intact. (#5242)\r
+ if ( styleVal == 'inherit' )\r
+ specialStylesText += text;\r
+ else\r
+ stylesText += text;\r
+ }\r
\r
// Browsers make some changes to the style when applying them. So, here\r
// we normalize it to the browser format.\r
if ( stylesText.length )\r
stylesText = normalizeCssText( stylesText );\r
\r
+ stylesText += specialStylesText;\r
+\r
// Return it, saving it to the next request.\r
return ( styleDefinition._ST = stylesText );\r
};\r
\r
+ // Gets the parent element which blocks the styling for an element. This\r
+ // can be done through read-only elements (contenteditable=false) or\r
+ // elements with the "data-nostyle" attribute.\r
+ function getUnstylableParent( element )\r
+ {\r
+ var unstylable,\r
+ editable;\r
+\r
+ while ( ( element = element.getParent() ) )\r
+ {\r
+ if ( element.getName() == 'body' )\r
+ break;\r
+\r
+ if ( element.getAttribute( 'data-nostyle' ) )\r
+ unstylable = element;\r
+ else if ( !editable )\r
+ {\r
+ var contentEditable = element.getAttribute( 'contentEditable' );\r
+\r
+ if ( contentEditable == 'false' )\r
+ unstylable = element;\r
+ else if ( contentEditable == 'true' )\r
+ editable = 1;\r
+ }\r
+ }\r
+\r
+ return unstylable;\r
+ }\r
+\r
function applyInlineStyle( range )\r
{\r
var document = range.document;\r
var def = this._.definition;\r
var isUnknownElement;\r
\r
+ // Indicates that fully selected read-only elements are to be included in the styling range.\r
+ var ignoreReadonly = def.ignoreReadonly,\r
+ includeReadonly = ignoreReadonly || def.includeReadonly;\r
+\r
+ // If the read-only inclusion is not available in the definition, try\r
+ // to get it from the document data.\r
+ if ( includeReadonly == undefined )\r
+ includeReadonly = document.getCustomData( 'cke_includeReadonly' );\r
+\r
// Get the DTD definition for the element. Defaults to "span".\r
var dtd = CKEDITOR.dtd[ elementName ] || ( isUnknownElement = true, CKEDITOR.dtd.span );\r
\r
- // Bookmark the range so we can re-select it after processing.\r
- var bookmark = range.createBookmark();\r
-\r
// Expand the range.\r
- range.enlarge( CKEDITOR.ENLARGE_ELEMENT );\r
+ range.enlarge( CKEDITOR.ENLARGE_ELEMENT, 1 );\r
range.trim();\r
\r
// Get the first node to be processed and the last, which concludes the\r
// processing.\r
- var boundaryNodes = range.getBoundaryNodes();\r
- var firstNode = boundaryNodes.startNode;\r
- var lastNode = boundaryNodes.endNode.getNextSourceNode( true );\r
-\r
- // Probably the document end is reached, we need a marker node.\r
- if ( !lastNode )\r
- {\r
- var marker;\r
- lastNode = marker = document.createText( '' );\r
- lastNode.insertAfter( range.endContainer );\r
- }\r
- // The detection algorithm below skips the contents inside bookmark nodes, so\r
- // we'll need to make sure lastNode isn't the inside a bookmark node.\r
- var lastParent = lastNode.getParent();\r
- if ( lastParent && lastParent.getAttribute( '_fck_bookmark' ) )\r
- lastNode = lastParent;\r
-\r
- if ( lastNode.equals( firstNode ) )\r
- {\r
- // If the last node is the same as the the first one, we must move\r
- // it to the next one, otherwise the first one will not be\r
- // processed.\r
- lastNode = lastNode.getNextSourceNode( true );\r
-\r
- // It may happen that there are no more nodes after it (the end of\r
- // the document), so we must add something there to make our code\r
- // simpler.\r
- if ( !lastNode )\r
- {\r
- lastNode = marker = document.createText( '' );\r
- lastNode.insertAfter( firstNode );\r
- }\r
- }\r
+ var boundaryNodes = range.createBookmark(),\r
+ firstNode = boundaryNodes.startNode,\r
+ lastNode = boundaryNodes.endNode;\r
\r
var currentNode = firstNode;\r
\r
var styleRange;\r
\r
- // Indicates that that some useful inline content has been found, so\r
- // the style should be applied.\r
- var hasContents;\r
+ if ( !ignoreReadonly )\r
+ {\r
+ // Check if the boundaries are inside non stylable elements.\r
+ var firstUnstylable = getUnstylableParent( firstNode ),\r
+ lastUnstylable = getUnstylableParent( lastNode );\r
+\r
+ // If the first element can't be styled, we'll start processing right\r
+ // after its unstylable root.\r
+ if ( firstUnstylable )\r
+ currentNode = firstUnstylable.getNextSourceNode( true );\r
+\r
+ // If the last element can't be styled, we'll stop processing on its\r
+ // unstylable root.\r
+ if ( lastUnstylable )\r
+ lastNode = lastUnstylable;\r
+ }\r
+\r
+ // Do nothing if the current node now follows the last node to be processed.\r
+ if ( currentNode.getPosition( lastNode ) == CKEDITOR.POSITION_FOLLOWING )\r
+ currentNode = 0;\r
\r
while ( currentNode )\r
{\r
{\r
var nodeType = currentNode.type;\r
var nodeName = nodeType == CKEDITOR.NODE_ELEMENT ? currentNode.getName() : null;\r
+ var nodeIsReadonly = nodeName && ( currentNode.getAttribute( 'contentEditable' ) == 'false' );\r
+ var nodeIsNoStyle = nodeName && currentNode.getAttribute( 'data-nostyle' );\r
\r
- if ( nodeName && currentNode.getAttribute( '_fck_bookmark' ) )\r
+ if ( nodeName && currentNode.data( 'cke-bookmark' ) )\r
{\r
currentNode = currentNode.getNextSourceNode( true );\r
continue;\r
\r
// Check if the current node can be a child of the style element.\r
if ( !nodeName || ( dtd[ nodeName ]\r
+ && !nodeIsNoStyle\r
+ && ( !nodeIsReadonly || includeReadonly )\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
styleRange.setStartBefore( currentNode );\r
}\r
\r
- // Non element nodes, or empty elements can be added\r
- // completely to the range.\r
- if ( nodeType == CKEDITOR.NODE_TEXT || ( nodeType == CKEDITOR.NODE_ELEMENT && !currentNode.getChildCount() ) )\r
+ // Non element nodes, readonly elements, or empty\r
+ // elements can be added completely to the range.\r
+ if ( nodeType == CKEDITOR.NODE_TEXT || nodeIsReadonly || ( nodeType == CKEDITOR.NODE_ELEMENT && !currentNode.getChildCount() ) )\r
{\r
var includedNode = currentNode;\r
var parentNode;\r
// This node is about to be included completelly, but,\r
// if this is the last node in its parent, we must also\r
// check if the parent itself can be added completelly\r
- // to the range.\r
- while ( !includedNode.$.nextSibling\r
+ // to the range, otherwise apply the style immediately.\r
+ while ( ( applyStyle = !includedNode.getNext( notBookmark ) )\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
&& ( !def.childRule || def.childRule( parentNode ) ) )\r
\r
styleRange.setEndAfter( includedNode );\r
\r
- // If the included node still is the last node in its\r
- // parent, it means that the parent can't be included\r
- // in this style DTD, so apply the style immediately.\r
- if ( !includedNode.$.nextSibling )\r
- applyStyle = true;\r
-\r
- if ( !hasContents )\r
- hasContents = ( nodeType != CKEDITOR.NODE_TEXT || (/[^\s\ufeff]/).test( currentNode.getText() ) );\r
}\r
}\r
else\r
applyStyle = true;\r
\r
// Get the next node to be processed.\r
- currentNode = currentNode.getNextSourceNode();\r
+ currentNode = currentNode.getNextSourceNode( nodeIsNoStyle || nodeIsReadonly );\r
}\r
\r
// Apply the style if we have something to which apply it.\r
- if ( applyStyle && hasContents && styleRange && !styleRange.collapsed )\r
+ if ( applyStyle && styleRange && !styleRange.collapsed )\r
{\r
// Build the style element, based on the style object definition.\r
- var styleNode = getElement( this, document );\r
+ var styleNode = getElement( this, document ),\r
+ styleHasAttrs = styleNode.hasAttributes();\r
\r
// Get the element that holds the entire range.\r
var parent = styleRange.getCommonAncestor();\r
\r
+ var removeList = {\r
+ styles : {},\r
+ attrs : {},\r
+ // Styles cannot be removed.\r
+ blockedStyles : {},\r
+ // Attrs cannot be removed.\r
+ blockedAttrs : {}\r
+ };\r
+\r
+ var attName, styleName, value;\r
+\r
// Loop through the parents, removing the redundant attributes\r
// from the element to be applied.\r
while ( styleNode && parent )\r
{\r
if ( parent.getName() == elementName )\r
{\r
- for ( var attName in def.attributes )\r
+ for ( attName in def.attributes )\r
{\r
- if ( styleNode.getAttribute( attName ) == parent.getAttribute( attName ) )\r
- styleNode.removeAttribute( attName );\r
- }\r
+ if ( removeList.blockedAttrs[ attName ] || !( value = parent.getAttribute( styleName ) ) )\r
+ continue;\r
\r
- for ( var styleName in def.styles )\r
- {\r
- if ( styleNode.getStyle( styleName ) == parent.getStyle( styleName ) )\r
- styleNode.removeStyle( styleName );\r
+ if ( styleNode.getAttribute( attName ) == value )\r
+ removeList.attrs[ attName ] = 1;\r
+ else\r
+ removeList.blockedAttrs[ attName ] = 1;\r
}\r
\r
- if ( !styleNode.hasAttributes() )\r
+ for ( styleName in def.styles )\r
{\r
- styleNode = null;\r
- break;\r
+ if ( removeList.blockedStyles[ styleName ] || !( value = parent.getStyle( styleName ) ) )\r
+ continue;\r
+\r
+ if ( styleNode.getStyle( styleName ) == value )\r
+ removeList.styles[ styleName ] = 1;\r
+ else\r
+ removeList.blockedStyles[ styleName ] = 1;\r
}\r
}\r
\r
parent = parent.getParent();\r
}\r
\r
+ for ( attName in removeList.attrs )\r
+ styleNode.removeAttribute( attName );\r
+\r
+ for ( styleName in removeList.styles )\r
+ styleNode.removeStyle( styleName );\r
+\r
+ if ( styleHasAttrs && !styleNode.hasAttributes() )\r
+ styleNode = null;\r
+\r
if ( styleNode )\r
{\r
// Move the contents of the range to the style element.\r
styleRange.insertNode( styleNode );\r
\r
// Let's merge our new style with its neighbors, if possible.\r
- mergeSiblings( styleNode );\r
+ styleNode.mergeSiblings();\r
\r
// As the style system breaks text nodes constantly, let's normalize\r
// things for performance.\r
if ( !CKEDITOR.env.ie )\r
styleNode.$.normalize();\r
}\r
+ // Style already inherit from parents, left just to clear up any internal overrides. (#5931)\r
+ else\r
+ {\r
+ styleNode = new CKEDITOR.dom.element( 'span' );\r
+ styleRange.extractContents().appendTo( styleNode );\r
+ styleRange.insertNode( styleNode );\r
+ removeFromInsideElement( this, styleNode );\r
+ styleNode.remove( true );\r
+ }\r
\r
// Style applied, let's release the range, so it gets\r
// re-initialization in the next loop.\r
}\r
}\r
\r
- // Remove the temporary marking node.(#4111)\r
- marker && marker.remove();\r
- range.moveToBookmark( bookmark );\r
+ // Remove the bookmark nodes.\r
+ range.moveToBookmark( boundaryNodes );\r
+\r
+ // Minimize the result range to exclude empty text nodes. (#5374)\r
+ range.shrink( CKEDITOR.SHRINK_TEXT );\r
}\r
\r
function removeInlineStyle( range )\r
* Make sure our range has included all "collpased" parent inline nodes so\r
* that our operation logic can be simpler.\r
*/\r
- range.enlarge( CKEDITOR.ENLARGE_ELEMENT );\r
+ range.enlarge( CKEDITOR.ENLARGE_ELEMENT, 1 );\r
\r
var bookmark = range.createBookmark(),\r
startNode = bookmark.startNode;\r
\r
if ( this.checkElementRemovable( element ) )\r
{\r
- var endOfElement = range.checkBoundaryOfElement( element, CKEDITOR.END ),\r
- startOfElement = !endOfElement && range.checkBoundaryOfElement( element, CKEDITOR.START );\r
- if ( startOfElement || endOfElement )\r
+ var isStart;\r
+\r
+ if ( range.collapsed && (\r
+ range.checkBoundaryOfElement( element, CKEDITOR.END ) ||\r
+ ( isStart = range.checkBoundaryOfElement( element, CKEDITOR.START ) ) ) )\r
{\r
boundaryElement = element;\r
- boundaryElement.match = startOfElement ? 'start' : 'end';\r
+ boundaryElement.match = isStart ? 'start' : 'end';\r
}\r
else\r
{\r
* no difference that they're separate entities in the DOM tree. So, merge\r
* them before removal.\r
*/\r
- mergeSiblings( element );\r
- removeFromElement( this, element );\r
-\r
+ element.mergeSiblings();\r
+ if ( element.getName() == this.element )\r
+ removeFromElement( this, element );\r
+ else\r
+ removeOverrides( element, getOverrides( this )[ element.getName() ] );\r
}\r
}\r
}\r
breakNodes();\r
\r
// Now, do the DFS walk.\r
- var currentNode = startNode.getNext();\r
+ var currentNode = startNode;\r
while ( !currentNode.equals( endNode ) )\r
{\r
/*\r
}\r
\r
range.moveToBookmark( bookmark );\r
-}\r
+ }\r
+\r
+ function applyObjectStyle( range )\r
+ {\r
+ var root = range.getCommonAncestor( true, true ),\r
+ element = root.getAscendant( this.element, true );\r
+ element && !element.isReadOnly() && setupElement( element, this );\r
+ }\r
+\r
+ function removeObjectStyle( range )\r
+ {\r
+ var root = range.getCommonAncestor( true, true ),\r
+ element = root.getAscendant( this.element, true );\r
+\r
+ if ( !element )\r
+ return;\r
+\r
+ var style = this,\r
+ def = style._.definition,\r
+ attributes = def.attributes;\r
+\r
+ // Remove all defined attributes.\r
+ if ( attributes )\r
+ {\r
+ for ( var att in attributes )\r
+ {\r
+ element.removeAttribute( att, attributes[ att ] );\r
+ }\r
+ }\r
+\r
+ // Assign all defined styles.\r
+ if ( def.styles )\r
+ {\r
+ for ( var i in def.styles )\r
+ {\r
+ if ( !def.styles.hasOwnProperty( i ) )\r
+ continue;\r
+\r
+ element.removeStyle( i );\r
+ }\r
+ }\r
+ }\r
\r
function applyBlockStyle( range )\r
{\r
var iterator = range.createIterator();\r
iterator.enforceRealBlocks = true;\r
\r
+ // make recognize <br /> tag as a separator in ENTER_BR mode (#5121)\r
+ if ( this._.enterMode )\r
+ iterator.enlargeBr = ( this._.enterMode != CKEDITOR.ENTER_BR );\r
+\r
var block;\r
var doc = range.document;\r
var previousPreBlock;\r
\r
while ( ( block = iterator.getNextParagraph() ) ) // Only one =\r
{\r
- var newBlock = getElement( this, doc );\r
- replaceBlock( block, newBlock );\r
+ if ( !block.isReadOnly() )\r
+ {\r
+ var newBlock = getElement( this, doc, block );\r
+ replaceBlock( block, newBlock );\r
+ }\r
+ }\r
+\r
+ range.moveToBookmark( bookmark );\r
+ }\r
+\r
+ function removeBlockStyle( range )\r
+ {\r
+ // Serializible bookmarks is needed here since\r
+ // elements may be merged.\r
+ var bookmark = range.createBookmark( 1 );\r
+\r
+ var iterator = range.createIterator();\r
+ iterator.enforceRealBlocks = true;\r
+ iterator.enlargeBr = this._.enterMode != CKEDITOR.ENTER_BR;\r
+\r
+ var block;\r
+ while ( ( block = iterator.getNextParagraph() ) )\r
+ {\r
+ if ( this.checkElementRemovable( block ) )\r
+ {\r
+ // <pre> get special treatment.\r
+ if ( block.is( 'pre' ) )\r
+ {\r
+ var newBlock = this._.enterMode == CKEDITOR.ENTER_BR ?\r
+ null : range.document.createElement(\r
+ this._.enterMode == CKEDITOR.ENTER_P ? 'p' : 'div' );\r
+\r
+ newBlock && block.copyAttributes( newBlock );\r
+ replaceBlock( block, newBlock );\r
+ }\r
+ else\r
+ removeFromElement( this, block, 1 );\r
+ }\r
}\r
\r
range.moveToBookmark( bookmark );\r
// when necessary.(#3188)\r
function replaceBlock( block, newBlock )\r
{\r
- var newBlockIsPre = newBlock.is( 'pre' );\r
- var blockIsPre = block.is( 'pre' );\r
+ // Block is to be removed, create a temp element to\r
+ // save contents.\r
+ var removeBlock = !newBlock;\r
+ if ( removeBlock )\r
+ {\r
+ newBlock = block.getDocument().createElement( 'div' );\r
+ block.copyAttributes( newBlock );\r
+ }\r
+\r
+ var newBlockIsPre = newBlock && newBlock.is( 'pre' );\r
+ var blockIsPre = block.is( 'pre' );\r
\r
var isToPre = newBlockIsPre && !blockIsPre;\r
var isFromPre = !newBlockIsPre && blockIsPre;\r
newBlock = toPre( block, newBlock );\r
else if ( isFromPre )\r
// Split big <pre> into pieces before start to convert.\r
- newBlock = fromPres( splitIntoPres( block ), newBlock );\r
+ newBlock = fromPres( removeBlock ?\r
+ [ block.getHtml() ] : splitIntoPres( block ), newBlock );\r
else\r
block.moveChildren( newBlock );\r
\r
// Merge previous <pre> blocks.\r
mergePre( newBlock );\r
}\r
+ else if ( removeBlock )\r
+ removeNoAttribsElement( newBlock );\r
}\r
\r
/**\r
function mergePre( preBlock )\r
{\r
var previousBlock;\r
- if ( !( ( previousBlock = preBlock.getPreviousSourceNode( true, CKEDITOR.NODE_ELEMENT ) )\r
+ if ( !( ( previousBlock = preBlock.getPrevious( nonWhitespaces ) )\r
&& previousBlock.is\r
&& previousBlock.is( 'pre') ) )\r
return;\r
{\r
// Exclude the ones at header OR at tail,\r
// and ignore bookmark content between them.\r
- var duoBrRegex = /(\S\s*)\n(?:\s|(<span[^>]+_fck_bookmark.*?\/span>))*\n(?!$)/gi,\r
+ var duoBrRegex = /(\S\s*)\n(?:\s|(<span[^>]+data-cke-bookmark.*?\/span>))*\n(?!$)/gi,\r
blockName = preBlock.getName(),\r
splitedHtml = replace( preBlock.getOuterHtml(),\r
duoBrRegex,\r
} );\r
\r
var pres = [];\r
- splitedHtml.replace( /<pre>([\s\S]*?)<\/pre>/gi, function( match, preContent ){\r
+ splitedHtml.replace( /<pre\b.*?>([\s\S]*?)<\/pre>/gi, function( match, preContent ){\r
pres.push( preContent );\r
} );\r
return pres;\r
var headBookmark = '',\r
tailBookmark = '';\r
\r
- str = str.replace( /(^<span[^>]+_fck_bookmark.*?\/span>)|(<span[^>]+_fck_bookmark.*?\/span>$)/gi,\r
+ str = str.replace( /(^<span[^>]+data-cke-bookmark.*?\/span>)|(<span[^>]+data-cke-bookmark.*?\/span>$)/gi,\r
function( str, m1, m2 ){\r
m1 && ( headBookmark = m1 );\r
m2 && ( tailBookmark = m2 );\r
} );\r
return headBookmark + str.replace( regexp, replacement ) + tailBookmark;\r
}\r
+\r
/**\r
* Converting a list of <pre> into blocks with format well preserved.\r
*/\r
function fromPres( preHtmls, newBlock )\r
{\r
- var docFrag = new CKEDITOR.dom.documentFragment( newBlock.getDocument() );\r
+ var docFrag;\r
+ if ( preHtmls.length > 1 )\r
+ docFrag = new CKEDITOR.dom.documentFragment( newBlock.getDocument() );\r
+\r
for ( var i = 0 ; i < preHtmls.length ; i++ )\r
{\r
var blockHtml = preHtmls[ i ];\r
return CKEDITOR.tools.repeat( ' ', match.length - 1 ) + ' ' ;\r
} ) ;\r
\r
- var newBlockClone = newBlock.clone();\r
- newBlockClone.setHtml( blockHtml );\r
- docFrag.append( newBlockClone );\r
+ if ( docFrag )\r
+ {\r
+ var newBlockClone = newBlock.clone();\r
+ newBlockClone.setHtml( blockHtml );\r
+ docFrag.append( newBlockClone );\r
+ }\r
+ else\r
+ newBlock.setHtml( blockHtml );\r
}\r
- return docFrag;\r
+\r
+ return docFrag || newBlock;\r
}\r
\r
/**\r
*/\r
function toPre( block, newBlock )\r
{\r
+ var bogus = block.getBogus();\r
+ bogus && bogus.remove();\r
+\r
// First trim the block content.\r
var preHtml = block.getHtml();\r
\r
var temp = block.getDocument().createElement( 'div' );\r
temp.append( newBlock );\r
newBlock.$.outerHTML = '<pre>' + preHtml + '</pre>';\r
+ newBlock.copyAttributes( temp.getFirst() );\r
newBlock = temp.getFirst().remove();\r
}\r
else\r
var def = style._.definition,\r
attributes = def.attributes,\r
styles = def.styles,\r
- overrides = getOverrides( style );\r
+ overrides = getOverrides( style )[ element.getName() ],\r
+ // If the style is only about the element itself, we have to remove the element.\r
+ removeEmpty = CKEDITOR.tools.isEmpty( attributes ) && CKEDITOR.tools.isEmpty( styles );\r
\r
- function removeAttrs()\r
+ // Remove definition attributes/style from the elemnt.\r
+ for ( var attName in attributes )\r
{\r
- for ( var attName in attributes )\r
- {\r
- // The 'class' element value must match (#1318).\r
- if ( attName == 'class' && element.getAttribute( attName ) != attributes[ attName ] )\r
- continue;\r
- element.removeAttribute( attName );\r
- }\r
+ // The 'class' element value must match (#1318).\r
+ if ( ( attName == 'class' || style._.definition.fullMatch )\r
+ && element.getAttribute( attName ) != normalizeProperty( attName, attributes[ attName ] ) )\r
+ continue;\r
+ removeEmpty = element.hasAttribute( attName );\r
+ element.removeAttribute( attName );\r
}\r
\r
- // Remove definition attributes/style from the elemnt.\r
- removeAttrs();\r
for ( var styleName in styles )\r
+ {\r
+ // Full match style insist on having fully equivalence. (#5018)\r
+ if ( style._.definition.fullMatch\r
+ && element.getStyle( styleName ) != normalizeProperty( styleName, styles[ styleName ], true ) )\r
+ continue;\r
+\r
+ removeEmpty = removeEmpty || !!element.getStyle( styleName );\r
element.removeStyle( styleName );\r
+ }\r
\r
- // Now remove override styles on the element.\r
- attributes = overrides[ element.getName() ];\r
- if ( attributes )\r
- removeAttrs();\r
- removeNoAttribsElement( element );\r
+ // Remove overrides, but don't remove the element if it's a block element\r
+ removeOverrides( element, overrides, blockElements[ element.getName() ] ) ;\r
+\r
+ if ( removeEmpty )\r
+ {\r
+ !CKEDITOR.dtd.$block[ element.getName() ] || style._.enterMode == CKEDITOR.ENTER_BR && !element.hasAttributes() ?\r
+ removeNoAttribsElement( element ) :\r
+ element.renameNode( style._.enterMode == CKEDITOR.ENTER_P ? 'p' : 'div' );\r
+ }\r
}\r
\r
// Removes a style from inside an element.\r
var def = style._.definition,\r
attribs = def.attributes,\r
styles = def.styles,\r
- overrides = getOverrides( style );\r
-\r
- var innerElements = element.getElementsByTag( style.element );\r
+ overrides = getOverrides( style ),\r
+ innerElements = element.getElementsByTag( style.element );\r
\r
for ( var i = innerElements.count(); --i >= 0 ; )\r
removeFromElement( style, innerElements.getItem( i ) );\r
}\r
}\r
}\r
-\r
}\r
\r
/**\r
* Note: Remove the element if no attributes remain.\r
* @param {Object} element\r
* @param {Object} overrides\r
+ * @param {Boolean} Don't remove the element\r
*/\r
- function removeOverrides( element, overrides )\r
+ function removeOverrides( element, overrides, dontRemove )\r
{\r
var attributes = overrides && overrides.attributes ;\r
\r
}\r
}\r
\r
- removeNoAttribsElement( element );\r
+ if ( !dontRemove )\r
+ removeNoAttribsElement( element );\r
}\r
\r
// If the element has no more attributes, remove it.\r
// leaving its children.\r
if ( !element.hasAttributes() )\r
{\r
- // Removing elements may open points where merging is possible,\r
- // so let's cache the first and last nodes for later checking.\r
- var firstChild = element.getFirst();\r
- var lastChild = element.getLast();\r
-\r
- element.remove( true );\r
-\r
- if ( firstChild )\r
+ if ( CKEDITOR.dtd.$block[ element.getName() ] )\r
{\r
- // Check the cached nodes for merging.\r
- mergeSiblings( firstChild );\r
+ var previous = element.getPrevious( nonWhitespaces ),\r
+ next = element.getNext( nonWhitespaces );\r
\r
- if ( lastChild && !firstChild.equals( lastChild ) )\r
- mergeSiblings( lastChild );\r
- }\r
- }\r
- }\r
-\r
- function mergeSiblings( element )\r
- {\r
- if ( !element || element.type != CKEDITOR.NODE_ELEMENT || !CKEDITOR.dtd.$removeEmpty[ element.getName() ] )\r
- return;\r
-\r
- mergeElements( element, element.getNext(), true );\r
- mergeElements( element, element.getPrevious() );\r
- }\r
-\r
- function mergeElements( element, sibling, isNext )\r
- {\r
- if ( sibling && sibling.type == CKEDITOR.NODE_ELEMENT )\r
- {\r
- var hasBookmark = sibling.getAttribute( '_fck_bookmark' );\r
+ if ( previous && ( previous.type == CKEDITOR.NODE_TEXT || !previous.isBlockBoundary( { br : 1 } ) ) )\r
+ element.append( 'br', 1 );\r
+ if ( next && ( next.type == CKEDITOR.NODE_TEXT || !next.isBlockBoundary( { br : 1 } ) ) )\r
+ element.append( 'br' );\r
\r
- if ( hasBookmark )\r
- sibling = isNext ? sibling.getNext() : sibling.getPrevious();\r
-\r
- if ( sibling && sibling.type == CKEDITOR.NODE_ELEMENT && element.isIdentical( sibling ) )\r
+ element.remove( true );\r
+ }\r
+ else\r
{\r
- // Save the last child to be checked too, to merge things like\r
- // <b><i></i></b><b><i></i></b> => <b><i></i></b>\r
- var innerSibling = isNext ? element.getLast() : element.getFirst();\r
+ // Removing elements may open points where merging is possible,\r
+ // so let's cache the first and last nodes for later checking.\r
+ var firstChild = element.getFirst();\r
+ var lastChild = element.getLast();\r
+\r
+ element.remove( true );\r
\r
- if ( hasBookmark )\r
- ( isNext ? sibling.getPrevious() : sibling.getNext() ).move( element, !isNext );\r
+ if ( firstChild )\r
+ {\r
+ // Check the cached nodes for merging.\r
+ firstChild.type == CKEDITOR.NODE_ELEMENT && firstChild.mergeSiblings();\r
\r
- sibling.moveChildren( element, !isNext );\r
- sibling.remove();\r
+ if ( lastChild && !firstChild.equals( lastChild )\r
+ && lastChild.type == CKEDITOR.NODE_ELEMENT )\r
+ lastChild.mergeSiblings();\r
+ }\r
\r
- // Now check the last inner child (see two comments above).\r
- if ( innerSibling )\r
- mergeSiblings( innerSibling );\r
}\r
}\r
}\r
\r
- function getElement( style, targetDocument )\r
+ function getElement( style, targetDocument, element )\r
{\r
- var el;\r
-\r
- var def = style._.definition;\r
-\r
- var elementName = style.element;\r
+ var el,\r
+ def = style._.definition,\r
+ elementName = style.element;\r
\r
// The "*" element name will always be a span for this function.\r
if ( elementName == '*' )\r
// Create the element.\r
el = new CKEDITOR.dom.element( elementName, targetDocument );\r
\r
- return setupElement( el, style );\r
+ // #6226: attributes should be copied before the new ones are applied\r
+ if ( element )\r
+ element.copyAttributes( el );\r
+\r
+ el = setupElement( el, style );\r
+\r
+ // Avoid ID duplication.\r
+ if ( targetDocument.getCustomData( 'doc_processing_style' ) && el.hasAttribute( 'id' ) )\r
+ el.removeAttribute( 'id' );\r
+ else\r
+ targetDocument.setCustomData( 'doc_processing_style', 1 );\r
+\r
+ return el;\r
}\r
\r
function setupElement( el, style )\r
{\r
- var def = style._.definition;\r
- var attributes = def.attributes;\r
- var styles = CKEDITOR.style.getStyleText( def );\r
+ var def = style._.definition,\r
+ attributes = def.attributes,\r
+ styles = CKEDITOR.style.getStyleText( def );\r
\r
// Assign all defined attributes.\r
if ( attributes )\r
}\r
\r
// Assign all defined styles.\r
- if ( styles )\r
+ if( styles )\r
el.setAttribute( 'style', styles );\r
\r
return el;\r
}\r
\r
- var varRegex = /#\((.+?)\)/g;\r
function replaceVariables( list, variablesValues )\r
{\r
for ( var item in list )\r
}\r
}\r
\r
-\r
// Returns an object that can be used for style matching comparison.\r
// Attributes names and values are all lowercased, and the styles get\r
// merged with the style attribute.\r
return overrides;\r
}\r
\r
+ // Make the comparison of attribute value easier by standardizing it.\r
+ function normalizeProperty( name, value, isStyle )\r
+ {\r
+ var temp = new CKEDITOR.dom.element( 'span' );\r
+ temp [ isStyle ? 'setStyle' : 'setAttribute' ]( name, value );\r
+ return temp[ isStyle ? 'getStyle' : 'getAttribute' ]( name );\r
+ }\r
+\r
+ // Make the comparison of style text easier by standardizing it.\r
function normalizeCssText( unparsedCssText, nativeNormalize )\r
{\r
var styleText;\r
else\r
styleText = unparsedCssText;\r
\r
+ // Normalize font-family property, ignore quotes and being case insensitive. (#7322)\r
+ // http://www.w3.org/TR/css3-fonts/#font-family-the-font-family-property\r
+ styleText = styleText.replace( /(font-family:)(.*?)(?=;|$)/, function ( match, prop, val )\r
+ {\r
+ var names = val.split( ',' );\r
+ for ( var i = 0; i < names.length; i++ )\r
+ names[ i ] = CKEDITOR.tools.trim( names[ i ].replace( /["']/g, '' ) );\r
+ return prop + names.join( ',' );\r
+ });\r
+\r
// Shrinking white-spaces around colon and semi-colon (#4147).\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
+ // Trimming spaces after comma(#4107),\r
+ // remove quotations(#6403),\r
+ // mostly for differences on "font-family".\r
+ .replace( /,\s+/g, ',' )\r
+ .replace( /\"/g,'' )\r
.toLowerCase();\r
}\r
\r
- function applyStyle( document, remove )\r
+ // Turn inline style text properties into one hash.\r
+ function parseStyleText( styleText )\r
{\r
- // Get all ranges from the selection.\r
- var selection = document.getSelection();\r
- var ranges = selection.getRanges();\r
- var func = remove ? this.removeFromRange : this.applyToRange;\r
+ var retval = {};\r
+ styleText\r
+ .replace( /"/g, '"' )\r
+ .replace( /\s*([^ :;]+)\s*:\s*([^;]+)\s*(?=;|$)/g, function( match, name, value )\r
+ {\r
+ retval[ name ] = value;\r
+ } );\r
+ return retval;\r
+ }\r
\r
- // Apply the style to the ranges.\r
- for ( var i = 0 ; i < ranges.length ; i++ )\r
- func.call( this, ranges[ i ] );\r
+ /**\r
+ * Compare two bunch of styles, with the speciality that value 'inherit'\r
+ * is treated as a wildcard which will match any value.\r
+ * @param {Object|String} source\r
+ * @param {Object|String} target\r
+ */\r
+ function compareCssText( source, target )\r
+ {\r
+ typeof source == 'string' && ( source = parseStyleText( source ) );\r
+ typeof target == 'string' && ( target = parseStyleText( target ) );\r
+ for( var name in source )\r
+ {\r
+ if ( !( name in target &&\r
+ ( target[ name ] == source[ name ]\r
+ || source[ name ] == 'inherit'\r
+ || target[ name ] == 'inherit' ) ) )\r
+ {\r
+ return false;\r
+ }\r
+ }\r
+ return true;\r
+ }\r
\r
- // Select the ranges again.\r
- selection.selectRanges( ranges );\r
+ function applyStyle( document, remove )\r
+ {\r
+ var selection = document.getSelection(),\r
+ // Bookmark the range so we can re-select it after processing.\r
+ bookmarks = selection.createBookmarks( 1 ),\r
+ ranges = selection.getRanges(),\r
+ func = remove ? this.removeFromRange : this.applyToRange,\r
+ range;\r
+\r
+ var iterator = ranges.createIterator();\r
+ while ( ( range = iterator.getNextRange() ) )\r
+ func.call( this, range );\r
+\r
+ if ( bookmarks.length == 1 && bookmarks[ 0 ].collapsed )\r
+ {\r
+ selection.selectRanges( ranges );\r
+ document.getById( bookmarks[ 0 ].startNode ).remove();\r
+ }\r
+ else\r
+ selection.selectBookmarks( bookmarks );\r
+\r
+ document.removeCustomData( 'doc_processing_style' );\r
}\r
})();\r
\r
return !!doc;\r
};\r
\r
+/**\r
+ * Manages styles registration and loading. See also {@link CKEDITOR.config.stylesSet}.\r
+ * @namespace\r
+ * @augments CKEDITOR.resourceManager\r
+ * @constructor\r
+ * @since 3.2\r
+ * @example\r
+ * // The set of styles for the <b>Styles</b> combo\r
+ * CKEDITOR.stylesSet.add( 'default',\r
+ * [\r
+ * // Block Styles\r
+ * { name : 'Blue Title' , element : 'h3', styles : { 'color' : 'Blue' } },\r
+ * { name : 'Red Title' , element : 'h3', styles : { 'color' : 'Red' } },\r
+ *\r
+ * // Inline Styles\r
+ * { name : 'Marker: Yellow' , element : 'span', styles : { 'background-color' : 'Yellow' } },\r
+ * { name : 'Marker: Green' , element : 'span', styles : { 'background-color' : 'Lime' } },\r
+ *\r
+ * // Object Styles\r
+ * {\r
+ * name : 'Image on Left',\r
+ * element : 'img',\r
+ * attributes :\r
+ * {\r
+ * 'style' : 'padding: 5px; margin-right: 5px',\r
+ * 'border' : '2',\r
+ * 'align' : 'left'\r
+ * }\r
+ * }\r
+ * ]);\r
+ */\r
CKEDITOR.stylesSet = new CKEDITOR.resourceManager( '', 'stylesSet' );\r
\r
// Backward compatibility (#5025).\r
CKEDITOR.stylesSet.addExternal( name, url, '' );\r
CKEDITOR.stylesSet.load( name, callback );\r
};\r
+\r
+\r
+/**\r
+ * Gets the current styleSet for this instance\r
+ * @param {Function} callback The function to be called with the styles data.\r
+ * @example\r
+ * editor.getStylesSet( function( stylesDefinitions ) {} );\r
+ */\r
+CKEDITOR.editor.prototype.getStylesSet = function( callback )\r
+{\r
+ if ( !this._.stylesDefinitions )\r
+ {\r
+ var editor = this,\r
+ // Respect the backwards compatible definition entry\r
+ configStyleSet = editor.config.stylesCombo_stylesSet || editor.config.stylesSet || 'default';\r
+\r
+ // #5352 Allow to define the styles directly in the config object\r
+ if ( configStyleSet instanceof Array )\r
+ {\r
+ editor._.stylesDefinitions = configStyleSet;\r
+ callback( configStyleSet );\r
+ return;\r
+ }\r
+\r
+ var partsStylesSet = configStyleSet.split( ':' ),\r
+ styleSetName = partsStylesSet[ 0 ],\r
+ externalPath = partsStylesSet[ 1 ],\r
+ pluginPath = CKEDITOR.plugins.registered.styles.path;\r
+\r
+ CKEDITOR.stylesSet.addExternal( styleSetName,\r
+ externalPath ?\r
+ partsStylesSet.slice( 1 ).join( ':' ) :\r
+ pluginPath + 'styles/' + styleSetName + '.js', '' );\r
+\r
+ CKEDITOR.stylesSet.load( styleSetName, function( stylesSet )\r
+ {\r
+ editor._.stylesDefinitions = stylesSet[ styleSetName ];\r
+ callback( editor._.stylesDefinitions );\r
+ } ) ;\r
+ }\r
+ else\r
+ callback( this._.stylesDefinitions );\r
+};\r
+\r
+/**\r
+ * Indicates that fully selected read-only elements will be included when\r
+ * applying the style (for inline styles only).\r
+ * @name CKEDITOR.style.includeReadonly\r
+ * @type Boolean\r
+ * @default false\r
+ * @since 3.5\r
+ */\r
+\r
+ /**\r
+ * Disables inline styling on read-only elements.\r
+ * @name CKEDITOR.config.disableReadonlyStyling\r
+ * @type Boolean\r
+ * @default false\r
+ * @since 3.5\r
+ */\r
+\r
+/**\r
+ * The "styles definition set" to use in the editor. They will be used in the\r
+ * styles combo and the Style selector of the div container. <br>\r
+ * The styles may be defined in the page containing the editor, or can be\r
+ * loaded on demand from an external file. In the second case, if this setting\r
+ * contains only a name, the styles definition file will be loaded from the\r
+ * "styles" folder inside the styles plugin folder.\r
+ * Otherwise, this setting has the "name:url" syntax, making it\r
+ * possible to set the URL from which loading the styles file.<br>\r
+ * Previously this setting was available as config.stylesCombo_stylesSet<br>\r
+ * @name CKEDITOR.config.stylesSet\r
+ * @type String|Array\r
+ * @default 'default'\r
+ * @since 3.3\r
+ * @example\r
+ * // Load from the styles' styles folder (mystyles.js file).\r
+ * config.stylesSet = 'mystyles';\r
+ * @example\r
+ * // Load from a relative URL.\r
+ * config.stylesSet = 'mystyles:/editorstyles/styles.js';\r
+ * @example\r
+ * // Load from a full URL.\r
+ * config.stylesSet = 'mystyles:http://www.example.com/editorstyles/styles.js';\r
+ * @example\r
+ * // Load from a list of definitions.\r
+ * config.stylesSet = [\r
+ * { name : 'Strong Emphasis', element : 'strong' },\r
+ * { name : 'Emphasis', element : 'em' }, ... ];\r
+ */\r