2 Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved.
\r
3 For licensing, see LICENSE.html or http://ckeditor.com/license
\r
6 CKEDITOR.plugins.add( 'styles',
\r
8 requires : [ 'selection' ],
\r
9 init : function( editor )
\r
11 // This doesn't look like correct, but it's the safest way to proper
\r
12 // pass the disableReadonlyStyling configuration to the style system
\r
13 // without having to change any method signature in the API. (#6103)
\r
14 editor.on( 'contentDom', function()
\r
16 editor.document.setCustomData( 'cke_includeReadonly', !editor.config.disableReadonlyStyling );
\r
22 * Registers a function to be called whenever a style changes its state in the
\r
23 * editing area. The current state is passed to the function. The possible
\r
24 * states are {@link CKEDITOR.TRISTATE_ON} and {@link CKEDITOR.TRISTATE_OFF}.
\r
25 * @param {CKEDITOR.style} style The style to be watched.
\r
26 * @param {Function} callback The function to be called when the style state changes.
\r
28 * // Create a style object for the <b> element.
\r
29 * var style = new CKEDITOR.style( { element : 'b' } );
\r
30 * var editor = CKEDITOR.instances.editor1;
\r
31 * editor.attachStyleStateChange( style, function( state )
\r
33 * if ( state == CKEDITOR.TRISTATE_ON )
\r
34 * alert( 'The current state for the B element is ON' );
\r
36 * alert( 'The current state for the B element is OFF' );
\r
39 CKEDITOR.editor.prototype.attachStyleStateChange = function( style, callback )
\r
41 // Try to get the list of attached callbacks.
\r
42 var styleStateChangeCallbacks = this._.styleStateChangeCallbacks;
\r
44 // If it doesn't exist, it means this is the first call. So, let's create
\r
45 // all the structure to manage the style checks and the callback calls.
\r
46 if ( !styleStateChangeCallbacks )
\r
48 // Create the callbacks array.
\r
49 styleStateChangeCallbacks = this._.styleStateChangeCallbacks = [];
\r
51 // Attach to the selectionChange event, so we can check the styles at
\r
53 this.on( 'selectionChange', function( ev )
\r
55 // Loop throw all registered callbacks.
\r
56 for ( var i = 0 ; i < styleStateChangeCallbacks.length ; i++ )
\r
58 var callback = styleStateChangeCallbacks[ i ];
\r
60 // Check the current state for the style defined for that
\r
62 var currentState = callback.style.checkActive( ev.data.path ) ? CKEDITOR.TRISTATE_ON : CKEDITOR.TRISTATE_OFF;
\r
64 // If the state changed since the last check.
\r
65 if ( callback.state !== currentState )
\r
67 // Call the callback function, passing the current
\r
69 callback.fn.call( this, currentState );
\r
71 // Save the current state, so it can be compared next
\r
73 callback.state = currentState;
\r
79 // Save the callback info, so it can be checked on the next occurrence of
\r
81 styleStateChangeCallbacks.push( { style : style, fn : callback } );
\r
84 CKEDITOR.STYLE_BLOCK = 1;
\r
85 CKEDITOR.STYLE_INLINE = 2;
\r
86 CKEDITOR.STYLE_OBJECT = 3;
\r
90 var blockElements = { address:1,div:1,h1:1,h2:1,h3:1,h4:1,h5:1,h6:1,p:1,pre:1 };
\r
91 var 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};
\r
93 var semicolonFixRegex = /\s*(?:;\s*|$)/;
\r
95 CKEDITOR.style = function( styleDefinition, variablesValues )
\r
97 if ( variablesValues )
\r
99 styleDefinition = CKEDITOR.tools.clone( styleDefinition );
\r
101 replaceVariables( styleDefinition.attributes, variablesValues );
\r
102 replaceVariables( styleDefinition.styles, variablesValues );
\r
105 var element = this.element = ( styleDefinition.element || '*' ).toLowerCase();
\r
108 ( element == '#' || blockElements[ element ] ) ?
\r
109 CKEDITOR.STYLE_BLOCK
\r
110 : objectElements[ element ] ?
\r
111 CKEDITOR.STYLE_OBJECT
\r
113 CKEDITOR.STYLE_INLINE;
\r
117 definition : styleDefinition
\r
121 CKEDITOR.style.prototype =
\r
123 apply : function( document )
\r
125 applyStyle.call( this, document, false );
\r
128 remove : function( document )
\r
130 applyStyle.call( this, document, true );
\r
133 applyToRange : function( range )
\r
135 return ( this.applyToRange =
\r
136 this.type == CKEDITOR.STYLE_INLINE ?
\r
138 : this.type == CKEDITOR.STYLE_BLOCK ?
\r
140 : this.type == CKEDITOR.STYLE_OBJECT ?
\r
142 : null ).call( this, range );
\r
145 removeFromRange : function( range )
\r
147 return ( this.removeFromRange =
\r
148 this.type == CKEDITOR.STYLE_INLINE ?
\r
150 : this.type == CKEDITOR.STYLE_OBJECT ?
\r
152 : null ).call( this, range );
\r
155 applyToObject : function( element )
\r
157 setupElement( element, this );
\r
161 * Get the style state inside an element path. Returns "true" if the
\r
162 * element is active in the path.
\r
164 checkActive : function( elementPath )
\r
166 switch ( this.type )
\r
168 case CKEDITOR.STYLE_BLOCK :
\r
169 return this.checkElementRemovable( elementPath.block || elementPath.blockLimit, true );
\r
171 case CKEDITOR.STYLE_OBJECT :
\r
172 case CKEDITOR.STYLE_INLINE :
\r
174 var elements = elementPath.elements;
\r
176 for ( var i = 0, element ; i < elements.length ; i++ )
\r
178 element = elements[ i ];
\r
180 if ( this.type == CKEDITOR.STYLE_INLINE
\r
181 && ( element == elementPath.block || element == elementPath.blockLimit ) )
\r
184 if( this.type == CKEDITOR.STYLE_OBJECT
\r
185 && !( element.getName() in objectElements ) )
\r
188 if ( this.checkElementRemovable( element, true ) )
\r
196 * Whether this style can be applied at the element path.
\r
197 * @param elementPath
\r
199 checkApplicable : function( elementPath )
\r
201 switch ( this.type )
\r
203 case CKEDITOR.STYLE_INLINE :
\r
204 case CKEDITOR.STYLE_BLOCK :
\r
207 case CKEDITOR.STYLE_OBJECT :
\r
208 return elementPath.lastElement.getAscendant( this.element, true );
\r
214 // Checks if an element, or any of its attributes, is removable by the
\r
215 // current style definition.
\r
216 checkElementRemovable : function( element, fullMatch )
\r
221 var def = this._.definition,
\r
224 // If the element name is the same as the style name.
\r
225 if ( element.getName() == this.element )
\r
227 // If no attributes are defined in the element.
\r
228 if ( !fullMatch && !element.hasAttributes() )
\r
231 attribs = getAttributesForComparison( def );
\r
233 if ( attribs._length )
\r
235 for ( var attName in attribs )
\r
237 if ( attName == '_length' )
\r
240 var elementAttr = element.getAttribute( attName ) || '';
\r
242 // Special treatment for 'style' attribute is required.
\r
243 if ( attName == 'style' ?
\r
244 compareCssText( attribs[ attName ], normalizeCssText( elementAttr, false ) )
\r
245 : attribs[ attName ] == elementAttr )
\r
250 else if ( fullMatch )
\r
260 // Check if the element can be somehow overriden.
\r
261 var override = getOverrides( this )[ element.getName() ] ;
\r
264 // If no attributes have been defined, remove the element.
\r
265 if ( !( attribs = override.attributes ) )
\r
268 for ( var i = 0 ; i < attribs.length ; i++ )
\r
270 attName = attribs[i][0];
\r
271 var actualAttrValue = element.getAttribute( attName );
\r
272 if ( actualAttrValue )
\r
274 var attValue = attribs[i][1];
\r
276 // Remove the attribute if:
\r
277 // - The override definition value is null;
\r
278 // - The override definition value is a string that
\r
279 // matches the attribute value exactly.
\r
280 // - The override definition value is a regex that
\r
281 // has matches in the attribute value.
\r
282 if ( attValue === null ||
\r
283 ( typeof attValue == 'string' && actualAttrValue == attValue ) ||
\r
284 attValue.test( actualAttrValue ) )
\r
292 // Builds the preview HTML based on the styles definition.
\r
293 buildPreview : function()
\r
295 var styleDefinition = this._.definition,
\r
297 elementName = styleDefinition.element;
\r
299 // Avoid <bdo> in the preview.
\r
300 if ( elementName == 'bdo' )
\r
301 elementName = 'span';
\r
303 html = [ '<', elementName ];
\r
305 // Assign all defined attributes.
\r
306 var attribs = styleDefinition.attributes;
\r
309 for ( var att in attribs )
\r
311 html.push( ' ', att, '="', attribs[ att ], '"' );
\r
315 // Assign the style attribute.
\r
316 var cssStyle = CKEDITOR.style.getStyleText( styleDefinition );
\r
318 html.push( ' style="', cssStyle, '"' );
\r
320 html.push( '>', styleDefinition.name, '</', elementName, '>' );
\r
322 return html.join( '' );
\r
326 // Build the cssText based on the styles definition.
\r
327 CKEDITOR.style.getStyleText = function( styleDefinition )
\r
329 // If we have already computed it, just return it.
\r
330 var stylesDef = styleDefinition._ST;
\r
334 stylesDef = styleDefinition.styles;
\r
336 // Builds the StyleText.
\r
337 var stylesText = ( styleDefinition.attributes && styleDefinition.attributes[ 'style' ] ) || '',
\r
338 specialStylesText = '';
\r
340 if ( stylesText.length )
\r
341 stylesText = stylesText.replace( semicolonFixRegex, ';' );
\r
343 for ( var style in stylesDef )
\r
345 var styleVal = stylesDef[ style ],
\r
346 text = ( style + ':' + styleVal ).replace( semicolonFixRegex, ';' );
\r
348 // Some browsers don't support 'inherit' property value, leave them intact. (#5242)
\r
349 if ( styleVal == 'inherit' )
\r
350 specialStylesText += text;
\r
352 stylesText += text;
\r
355 // Browsers make some changes to the style when applying them. So, here
\r
356 // we normalize it to the browser format.
\r
357 if ( stylesText.length )
\r
358 stylesText = normalizeCssText( stylesText );
\r
360 stylesText += specialStylesText;
\r
362 // Return it, saving it to the next request.
\r
363 return ( styleDefinition._ST = stylesText );
\r
366 // Gets the parent element which blocks the styling for an element. This
\r
367 // can be done through read-only elements (contenteditable=false) or
\r
368 // elements with the "data-cke-nostyle" attribute.
\r
369 function getUnstylableParent( element )
\r
374 while ( ( element = element.getParent() ) )
\r
376 if ( element.getName() == 'body' )
\r
379 if ( element.getAttribute( 'data-cke-nostyle' ) )
\r
380 unstylable = element;
\r
381 else if ( !editable )
\r
383 var contentEditable = element.getAttribute( 'contentEditable' );
\r
385 if ( contentEditable == 'false' )
\r
386 unstylable = element;
\r
387 else if ( contentEditable == 'true' )
\r
395 function applyInlineStyle( range )
\r
397 var document = range.document;
\r
399 if ( range.collapsed )
\r
401 // Create the element to be inserted in the DOM.
\r
402 var collapsedElement = getElement( this, document );
\r
404 // Insert the empty element into the DOM at the range position.
\r
405 range.insertNode( collapsedElement );
\r
407 // Place the selection right inside the empty element.
\r
408 range.moveToPosition( collapsedElement, CKEDITOR.POSITION_BEFORE_END );
\r
413 var elementName = this.element;
\r
414 var def = this._.definition;
\r
415 var isUnknownElement;
\r
417 // Indicates that fully selected read-only elements are to be included in the styling range.
\r
418 var includeReadonly = def.includeReadonly;
\r
420 // If the read-only inclusion is not available in the definition, try
\r
421 // to get it from the document data.
\r
422 if ( includeReadonly == undefined )
\r
423 includeReadonly = document.getCustomData( 'cke_includeReadonly' );
\r
425 // Get the DTD definition for the element. Defaults to "span".
\r
426 var dtd = CKEDITOR.dtd[ elementName ] || ( isUnknownElement = true, CKEDITOR.dtd.span );
\r
428 // Expand the range.
\r
429 range.enlarge( CKEDITOR.ENLARGE_ELEMENT );
\r
432 // Get the first node to be processed and the last, which concludes the
\r
434 var boundaryNodes = range.createBookmark(),
\r
435 firstNode = boundaryNodes.startNode,
\r
436 lastNode = boundaryNodes.endNode;
\r
438 var currentNode = firstNode;
\r
442 // Check if the boundaries are inside non stylable elements.
\r
443 var firstUnstylable = getUnstylableParent( firstNode ),
\r
444 lastUnstylable = getUnstylableParent( lastNode );
\r
446 // If the first element can't be styled, we'll start processing right
\r
447 // after its unstylable root.
\r
448 if ( firstUnstylable )
\r
449 currentNode = firstUnstylable.getNextSourceNode( true );
\r
451 // If the last element can't be styled, we'll stop processing on its
\r
452 // unstylable root.
\r
453 if ( lastUnstylable )
\r
454 lastNode = lastUnstylable;
\r
456 // Do nothing if the current node now follows the last node to be processed.
\r
457 if ( currentNode.getPosition( lastNode ) == CKEDITOR.POSITION_FOLLOWING )
\r
460 while ( currentNode )
\r
462 var applyStyle = false;
\r
464 if ( currentNode.equals( lastNode ) )
\r
466 currentNode = null;
\r
471 var nodeType = currentNode.type;
\r
472 var nodeName = nodeType == CKEDITOR.NODE_ELEMENT ? currentNode.getName() : null;
\r
473 var nodeIsReadonly = nodeName && ( currentNode.getAttribute( 'contentEditable' ) == 'false' );
\r
474 var nodeIsNoStyle = nodeName && currentNode.getAttribute( 'data-cke-nostyle' );
\r
476 if ( nodeName && currentNode.data( 'cke-bookmark' ) )
\r
478 currentNode = currentNode.getNextSourceNode( true );
\r
482 // Check if the current node can be a child of the style element.
\r
483 if ( !nodeName || ( dtd[ nodeName ]
\r
485 && ( !nodeIsReadonly || includeReadonly )
\r
486 && ( currentNode.getPosition( lastNode ) | CKEDITOR.POSITION_PRECEDING | CKEDITOR.POSITION_IDENTICAL | CKEDITOR.POSITION_IS_CONTAINED ) == ( CKEDITOR.POSITION_PRECEDING + CKEDITOR.POSITION_IDENTICAL + CKEDITOR.POSITION_IS_CONTAINED )
\r
487 && ( !def.childRule || def.childRule( currentNode ) ) ) )
\r
489 var currentParent = currentNode.getParent();
\r
491 // Check if the style element can be a child of the current
\r
492 // node parent or if the element is not defined in the DTD.
\r
494 && ( ( currentParent.getDtd() || CKEDITOR.dtd.span )[ elementName ] || isUnknownElement )
\r
495 && ( !def.parentRule || def.parentRule( currentParent ) ) )
\r
497 // This node will be part of our range, so if it has not
\r
498 // been started, place its start right before the node.
\r
499 // In the case of an element node, it will be included
\r
500 // only if it is entirely inside the range.
\r
501 if ( !styleRange && ( !nodeName || !CKEDITOR.dtd.$removeEmpty[ 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
503 styleRange = new CKEDITOR.dom.range( document );
\r
504 styleRange.setStartBefore( currentNode );
\r
507 // Non element nodes, readonly elements, or empty
\r
508 // elements can be added completely to the range.
\r
509 if ( nodeType == CKEDITOR.NODE_TEXT || nodeIsReadonly || ( nodeType == CKEDITOR.NODE_ELEMENT && !currentNode.getChildCount() ) )
\r
511 var includedNode = currentNode;
\r
514 // This node is about to be included completelly, but,
\r
515 // if this is the last node in its parent, we must also
\r
516 // check if the parent itself can be added completelly
\r
518 while ( !includedNode.$.nextSibling
\r
519 && ( parentNode = includedNode.getParent(), dtd[ parentNode.getName() ] )
\r
520 && ( parentNode.getPosition( firstNode ) | CKEDITOR.POSITION_FOLLOWING | CKEDITOR.POSITION_IDENTICAL | CKEDITOR.POSITION_IS_CONTAINED ) == ( CKEDITOR.POSITION_FOLLOWING + CKEDITOR.POSITION_IDENTICAL + CKEDITOR.POSITION_IS_CONTAINED )
\r
521 && ( !def.childRule || def.childRule( parentNode ) ) )
\r
523 includedNode = parentNode;
\r
526 styleRange.setEndAfter( includedNode );
\r
528 // If the included node still is the last node in its
\r
529 // parent, it means that the parent can't be included
\r
530 // in this style DTD, so apply the style immediately.
\r
531 if ( !includedNode.$.nextSibling )
\r
541 // Get the next node to be processed.
\r
542 currentNode = currentNode.getNextSourceNode( nodeIsNoStyle || nodeIsReadonly );
\r
545 // Apply the style if we have something to which apply it.
\r
546 if ( applyStyle && styleRange && !styleRange.collapsed )
\r
548 // Build the style element, based on the style object definition.
\r
549 var styleNode = getElement( this, document ),
\r
550 styleHasAttrs = styleNode.hasAttributes();
\r
552 // Get the element that holds the entire range.
\r
553 var parent = styleRange.getCommonAncestor();
\r
558 // Styles cannot be removed.
\r
559 blockedStyles : {},
\r
560 // Attrs cannot be removed.
\r
564 var attName, styleName, value;
\r
566 // Loop through the parents, removing the redundant attributes
\r
567 // from the element to be applied.
\r
568 while ( styleNode && parent )
\r
570 if ( parent.getName() == elementName )
\r
572 for ( attName in def.attributes )
\r
574 if ( removeList.blockedAttrs[ attName ] || !( value = parent.getAttribute( styleName ) ) )
\r
577 if ( styleNode.getAttribute( attName ) == value )
\r
578 removeList.attrs[ attName ] = 1;
\r
580 removeList.blockedAttrs[ attName ] = 1;
\r
583 for ( styleName in def.styles )
\r
585 if ( removeList.blockedStyles[ styleName ] || !( value = parent.getStyle( styleName ) ) )
\r
588 if ( styleNode.getStyle( styleName ) == value )
\r
589 removeList.styles[ styleName ] = 1;
\r
591 removeList.blockedStyles[ styleName ] = 1;
\r
595 parent = parent.getParent();
\r
598 for ( attName in removeList.attrs )
\r
599 styleNode.removeAttribute( attName );
\r
601 for ( styleName in removeList.styles )
\r
602 styleNode.removeStyle( styleName );
\r
604 if ( styleHasAttrs && !styleNode.hasAttributes() )
\r
609 // Move the contents of the range to the style element.
\r
610 styleRange.extractContents().appendTo( styleNode );
\r
612 // Here we do some cleanup, removing all duplicated
\r
613 // elements from the style element.
\r
614 removeFromInsideElement( this, styleNode );
\r
616 // Insert it into the range position (it is collapsed after
\r
617 // extractContents.
\r
618 styleRange.insertNode( styleNode );
\r
620 // Let's merge our new style with its neighbors, if possible.
\r
621 styleNode.mergeSiblings();
\r
623 // As the style system breaks text nodes constantly, let's normalize
\r
624 // things for performance.
\r
625 // With IE, some paragraphs get broken when calling normalize()
\r
626 // repeatedly. Also, for IE, we must normalize body, not documentElement.
\r
627 // IE is also known for having a "crash effect" with normalize().
\r
628 // We should try to normalize with IE too in some way, somewhere.
\r
629 if ( !CKEDITOR.env.ie )
\r
630 styleNode.$.normalize();
\r
632 // Style already inherit from parents, left just to clear up any internal overrides. (#5931)
\r
635 styleNode = new CKEDITOR.dom.element( 'span' );
\r
636 styleRange.extractContents().appendTo( styleNode );
\r
637 styleRange.insertNode( styleNode );
\r
638 removeFromInsideElement( this, styleNode );
\r
639 styleNode.remove( true );
\r
642 // Style applied, let's release the range, so it gets
\r
643 // re-initialization in the next loop.
\r
648 // Remove the bookmark nodes.
\r
649 range.moveToBookmark( boundaryNodes );
\r
651 // Minimize the result range to exclude empty text nodes. (#5374)
\r
652 range.shrink( CKEDITOR.SHRINK_TEXT );
\r
655 function removeInlineStyle( range )
\r
658 * Make sure our range has included all "collpased" parent inline nodes so
\r
659 * that our operation logic can be simpler.
\r
661 range.enlarge( CKEDITOR.ENLARGE_ELEMENT );
\r
663 var bookmark = range.createBookmark(),
\r
664 startNode = bookmark.startNode;
\r
666 if ( range.collapsed )
\r
669 var startPath = new CKEDITOR.dom.elementPath( startNode.getParent() ),
\r
670 // The topmost element in elementspatch which we should jump out of.
\r
674 for ( var i = 0, element ; i < startPath.elements.length
\r
675 && ( element = startPath.elements[i] ) ; i++ )
\r
678 * 1. If it's collaped inside text nodes, try to remove the style from the whole element.
\r
680 * 2. Otherwise if it's collapsed on element boundaries, moving the selection
\r
681 * outside the styles instead of removing the whole tag,
\r
682 * also make sure other inner styles were well preserverd.(#3309)
\r
684 if ( element == startPath.block || element == startPath.blockLimit )
\r
687 if ( this.checkElementRemovable( element ) )
\r
691 if ( range.collapsed && (
\r
692 range.checkBoundaryOfElement( element, CKEDITOR.END ) ||
\r
693 ( isStart = range.checkBoundaryOfElement( element, CKEDITOR.START ) ) ) )
\r
695 boundaryElement = element;
\r
696 boundaryElement.match = isStart ? 'start' : 'end';
\r
701 * Before removing the style node, there may be a sibling to the style node
\r
702 * that's exactly the same to the one to be removed. To the user, it makes
\r
703 * no difference that they're separate entities in the DOM tree. So, merge
\r
704 * them before removal.
\r
706 element.mergeSiblings();
\r
707 removeFromElement( this, element );
\r
713 // Re-create the style tree after/before the boundary element,
\r
714 // the replication start from bookmark start node to define the
\r
716 if ( boundaryElement )
\r
718 var clonedElement = startNode;
\r
719 for ( i = 0 ;; i++ )
\r
721 var newElement = startPath.elements[ i ];
\r
722 if ( newElement.equals( boundaryElement ) )
\r
724 // Avoid copying any matched element.
\r
725 else if ( newElement.match )
\r
728 newElement = newElement.clone();
\r
729 newElement.append( clonedElement );
\r
730 clonedElement = newElement;
\r
732 clonedElement[ boundaryElement.match == 'start' ?
\r
733 'insertBefore' : 'insertAfter' ]( boundaryElement );
\r
739 * Now our range isn't collapsed. Lets walk from the start node to the end
\r
740 * node via DFS and remove the styles one-by-one.
\r
742 var endNode = bookmark.endNode,
\r
746 * Find out the style ancestor that needs to be broken down at startNode
\r
749 function breakNodes()
\r
751 var startPath = new CKEDITOR.dom.elementPath( startNode.getParent() ),
\r
752 endPath = new CKEDITOR.dom.elementPath( endNode.getParent() ),
\r
755 for ( var i = 0 ; i < startPath.elements.length ; i++ )
\r
757 var element = startPath.elements[ i ];
\r
759 if ( element == startPath.block || element == startPath.blockLimit )
\r
762 if ( me.checkElementRemovable( element ) )
\r
763 breakStart = element;
\r
765 for ( i = 0 ; i < endPath.elements.length ; i++ )
\r
767 element = endPath.elements[ i ];
\r
769 if ( element == endPath.block || element == endPath.blockLimit )
\r
772 if ( me.checkElementRemovable( element ) )
\r
773 breakEnd = element;
\r
777 endNode.breakParent( breakEnd );
\r
779 startNode.breakParent( breakStart );
\r
783 // Now, do the DFS walk.
\r
784 var currentNode = startNode.getNext();
\r
785 while ( !currentNode.equals( endNode ) )
\r
788 * Need to get the next node first because removeFromElement() can remove
\r
789 * the current node from DOM tree.
\r
791 var nextNode = currentNode.getNextSourceNode();
\r
792 if ( currentNode.type == CKEDITOR.NODE_ELEMENT && this.checkElementRemovable( currentNode ) )
\r
794 // Remove style from element or overriding element.
\r
795 if ( currentNode.getName() == this.element )
\r
796 removeFromElement( this, currentNode );
\r
798 removeOverrides( currentNode, getOverrides( this )[ currentNode.getName() ] );
\r
801 * removeFromElement() may have merged the next node with something before
\r
802 * the startNode via mergeSiblings(). In that case, the nextNode would
\r
803 * contain startNode and we'll have to call breakNodes() again and also
\r
804 * reassign the nextNode to something after startNode.
\r
806 if ( nextNode.type == CKEDITOR.NODE_ELEMENT && nextNode.contains( startNode ) )
\r
809 nextNode = startNode.getNext();
\r
812 currentNode = nextNode;
\r
816 range.moveToBookmark( bookmark );
\r
819 function applyObjectStyle( range )
\r
821 var root = range.getCommonAncestor( true, true ),
\r
822 element = root.getAscendant( this.element, true );
\r
823 element && setupElement( element, this );
\r
826 function removeObjectStyle( range )
\r
828 var root = range.getCommonAncestor( true, true ),
\r
829 element = root.getAscendant( this.element, true );
\r
835 var def = style._.definition;
\r
836 var attributes = def.attributes;
\r
837 var styles = CKEDITOR.style.getStyleText( def );
\r
839 // Remove all defined attributes.
\r
842 for ( var att in attributes )
\r
844 element.removeAttribute( att, attributes[ att ] );
\r
848 // Assign all defined styles.
\r
851 for ( var i in def.styles )
\r
853 if ( !def.styles.hasOwnProperty( i ) )
\r
856 element.removeStyle( i );
\r
861 function applyBlockStyle( range )
\r
863 // Serializible bookmarks is needed here since
\r
864 // elements may be merged.
\r
865 var bookmark = range.createBookmark( true );
\r
867 var iterator = range.createIterator();
\r
868 iterator.enforceRealBlocks = true;
\r
870 // make recognize <br /> tag as a separator in ENTER_BR mode (#5121)
\r
871 if ( this._.enterMode )
\r
872 iterator.enlargeBr = ( this._.enterMode != CKEDITOR.ENTER_BR );
\r
875 var doc = range.document;
\r
876 var previousPreBlock;
\r
878 while ( ( block = iterator.getNextParagraph() ) ) // Only one =
\r
880 var newBlock = getElement( this, doc, block );
\r
881 replaceBlock( block, newBlock );
\r
884 range.moveToBookmark( bookmark );
\r
887 // Replace the original block with new one, with special treatment
\r
888 // for <pre> blocks to make sure content format is well preserved, and merging/splitting adjacent
\r
889 // when necessary.(#3188)
\r
890 function replaceBlock( block, newBlock )
\r
892 var newBlockIsPre = newBlock.is( 'pre' );
\r
893 var blockIsPre = block.is( 'pre' );
\r
895 var isToPre = newBlockIsPre && !blockIsPre;
\r
896 var isFromPre = !newBlockIsPre && blockIsPre;
\r
899 newBlock = toPre( block, newBlock );
\r
900 else if ( isFromPre )
\r
901 // Split big <pre> into pieces before start to convert.
\r
902 newBlock = fromPres( splitIntoPres( block ), newBlock );
\r
904 block.moveChildren( newBlock );
\r
906 newBlock.replace( block );
\r
908 if ( newBlockIsPre )
\r
910 // Merge previous <pre> blocks.
\r
911 mergePre( newBlock );
\r
915 var nonWhitespaces = CKEDITOR.dom.walker.whitespaces( true );
\r
917 * Merge a <pre> block with a previous sibling if available.
\r
919 function mergePre( preBlock )
\r
922 if ( !( ( previousBlock = preBlock.getPrevious( nonWhitespaces ) )
\r
923 && previousBlock.is
\r
924 && previousBlock.is( 'pre') ) )
\r
927 // Merge the previous <pre> block contents into the current <pre>
\r
930 // Another thing to be careful here is that currentBlock might contain
\r
931 // a '\n' at the beginning, and previousBlock might contain a '\n'
\r
932 // towards the end. These new lines are not normally displayed but they
\r
933 // become visible after merging.
\r
934 var mergedHtml = replace( previousBlock.getHtml(), /\n$/, '' ) + '\n\n' +
\r
935 replace( preBlock.getHtml(), /^\n/, '' ) ;
\r
937 // Krugle: IE normalizes innerHTML from <pre>, breaking whitespaces.
\r
938 if ( CKEDITOR.env.ie )
\r
939 preBlock.$.outerHTML = '<pre>' + mergedHtml + '</pre>';
\r
941 preBlock.setHtml( mergedHtml );
\r
943 previousBlock.remove();
\r
947 * Split into multiple <pre> blocks separated by double line-break.
\r
950 function splitIntoPres( preBlock )
\r
952 // Exclude the ones at header OR at tail,
\r
953 // and ignore bookmark content between them.
\r
954 var duoBrRegex = /(\S\s*)\n(?:\s|(<span[^>]+data-cke-bookmark.*?\/span>))*\n(?!$)/gi,
\r
955 blockName = preBlock.getName(),
\r
956 splitedHtml = replace( preBlock.getOuterHtml(),
\r
958 function( match, charBefore, bookmark )
\r
960 return charBefore + '</pre>' + bookmark + '<pre>';
\r
964 splitedHtml.replace( /<pre\b.*?>([\s\S]*?)<\/pre>/gi, function( match, preContent ){
\r
965 pres.push( preContent );
\r
970 // Wrapper function of String::replace without considering of head/tail bookmarks nodes.
\r
971 function replace( str, regexp, replacement )
\r
973 var headBookmark = '',
\r
976 str = str.replace( /(^<span[^>]+data-cke-bookmark.*?\/span>)|(<span[^>]+data-cke-bookmark.*?\/span>$)/gi,
\r
977 function( str, m1, m2 ){
\r
978 m1 && ( headBookmark = m1 );
\r
979 m2 && ( tailBookmark = m2 );
\r
982 return headBookmark + str.replace( regexp, replacement ) + tailBookmark;
\r
985 * Converting a list of <pre> into blocks with format well preserved.
\r
987 function fromPres( preHtmls, newBlock )
\r
989 var docFrag = new CKEDITOR.dom.documentFragment( newBlock.getDocument() );
\r
990 for ( var i = 0 ; i < preHtmls.length ; i++ )
\r
992 var blockHtml = preHtmls[ i ];
\r
994 // 1. Trim the first and last line-breaks immediately after and before <pre>,
\r
995 // they're not visible.
\r
996 blockHtml = blockHtml.replace( /(\r\n|\r)/g, '\n' ) ;
\r
997 blockHtml = replace( blockHtml, /^[ \t]*\n/, '' ) ;
\r
998 blockHtml = replace( blockHtml, /\n$/, '' ) ;
\r
999 // 2. Convert spaces or tabs at the beginning or at the end to
\r
1000 blockHtml = replace( blockHtml, /^[ \t]+|[ \t]+$/g, function( match, offset, s )
\r
1002 if ( match.length == 1 ) // one space, preserve it
\r
1004 else if ( !offset ) // beginning of block
\r
1005 return CKEDITOR.tools.repeat( ' ', match.length - 1 ) + ' ';
\r
1006 else // end of block
\r
1007 return ' ' + CKEDITOR.tools.repeat( ' ', match.length - 1 );
\r
1010 // 3. Convert \n to <BR>.
\r
1011 // 4. Convert contiguous (i.e. non-singular) spaces or tabs to
\r
1012 blockHtml = blockHtml.replace( /\n/g, '<br>' ) ;
\r
1013 blockHtml = blockHtml.replace( /[ \t]{2,}/g,
\r
1014 function ( match )
\r
1016 return CKEDITOR.tools.repeat( ' ', match.length - 1 ) + ' ' ;
\r
1019 var newBlockClone = newBlock.clone();
\r
1020 newBlockClone.setHtml( blockHtml );
\r
1021 docFrag.append( newBlockClone );
\r
1027 * Converting from a non-PRE block to a PRE block in formatting operations.
\r
1029 function toPre( block, newBlock )
\r
1031 // First trim the block content.
\r
1032 var preHtml = block.getHtml();
\r
1034 // 1. Trim head/tail spaces, they're not visible.
\r
1035 preHtml = replace( preHtml, /(?:^[ \t\n\r]+)|(?:[ \t\n\r]+$)/g, '' );
\r
1036 // 2. Delete ANSI whitespaces immediately before and after <BR> because
\r
1037 // they are not visible.
\r
1038 preHtml = preHtml.replace( /[ \t\r\n]*(<br[^>]*>)[ \t\r\n]*/gi, '$1' );
\r
1039 // 3. Compress other ANSI whitespaces since they're only visible as one
\r
1040 // single space previously.
\r
1041 // 4. Convert to spaces since is no longer needed in <PRE>.
\r
1042 preHtml = preHtml.replace( /([ \t\n\r]+| )/g, ' ' );
\r
1043 // 5. Convert any <BR /> to \n. This must not be done earlier because
\r
1044 // the \n would then get compressed.
\r
1045 preHtml = preHtml.replace( /<br\b[^>]*>/gi, '\n' );
\r
1047 // Krugle: IE normalizes innerHTML to <pre>, breaking whitespaces.
\r
1048 if ( CKEDITOR.env.ie )
\r
1050 var temp = block.getDocument().createElement( 'div' );
\r
1051 temp.append( newBlock );
\r
1052 newBlock.$.outerHTML = '<pre>' + preHtml + '</pre>';
\r
1053 newBlock = temp.getFirst().remove();
\r
1056 newBlock.setHtml( preHtml );
\r
1061 // Removes a style from an element itself, don't care about its subtree.
\r
1062 function removeFromElement( style, element )
\r
1064 var def = style._.definition,
\r
1065 attributes = CKEDITOR.tools.extend( {}, def.attributes, getOverrides( style )[ element.getName() ] ),
\r
1066 styles = def.styles,
\r
1067 // If the style is only about the element itself, we have to remove the element.
\r
1068 removeEmpty = CKEDITOR.tools.isEmpty( attributes ) && CKEDITOR.tools.isEmpty( styles );
\r
1070 // Remove definition attributes/style from the elemnt.
\r
1071 for ( var attName in attributes )
\r
1073 // The 'class' element value must match (#1318).
\r
1074 if ( ( attName == 'class' || style._.definition.fullMatch )
\r
1075 && element.getAttribute( attName ) != normalizeProperty( attName, attributes[ attName ] ) )
\r
1077 removeEmpty = element.hasAttribute( attName );
\r
1078 element.removeAttribute( attName );
\r
1081 for ( var styleName in styles )
\r
1083 // Full match style insist on having fully equivalence. (#5018)
\r
1084 if ( style._.definition.fullMatch
\r
1085 && element.getStyle( styleName ) != normalizeProperty( styleName, styles[ styleName ], true ) )
\r
1088 removeEmpty = removeEmpty || !!element.getStyle( styleName );
\r
1089 element.removeStyle( styleName );
\r
1092 removeEmpty && removeNoAttribsElement( element );
\r
1095 // Removes a style from inside an element.
\r
1096 function removeFromInsideElement( style, element )
\r
1098 var def = style._.definition,
\r
1099 attribs = def.attributes,
\r
1100 styles = def.styles,
\r
1101 overrides = getOverrides( style );
\r
1103 var innerElements = element.getElementsByTag( style.element );
\r
1105 for ( var i = innerElements.count(); --i >= 0 ; )
\r
1106 removeFromElement( style, innerElements.getItem( i ) );
\r
1108 // Now remove any other element with different name that is
\r
1109 // defined to be overriden.
\r
1110 for ( var overrideElement in overrides )
\r
1112 if ( overrideElement != style.element )
\r
1114 innerElements = element.getElementsByTag( overrideElement ) ;
\r
1115 for ( i = innerElements.count() - 1 ; i >= 0 ; i-- )
\r
1117 var innerElement = innerElements.getItem( i );
\r
1118 removeOverrides( innerElement, overrides[ overrideElement ] ) ;
\r
1126 * Remove overriding styles/attributes from the specific element.
\r
1127 * Note: Remove the element if no attributes remain.
\r
1128 * @param {Object} element
\r
1129 * @param {Object} overrides
\r
1131 function removeOverrides( element, overrides )
\r
1133 var attributes = overrides && overrides.attributes ;
\r
1137 for ( var i = 0 ; i < attributes.length ; i++ )
\r
1139 var attName = attributes[i][0], actualAttrValue ;
\r
1141 if ( ( actualAttrValue = element.getAttribute( attName ) ) )
\r
1143 var attValue = attributes[i][1] ;
\r
1145 // Remove the attribute if:
\r
1146 // - The override definition value is null ;
\r
1147 // - The override definition valie is a string that
\r
1148 // matches the attribute value exactly.
\r
1149 // - The override definition value is a regex that
\r
1150 // has matches in the attribute value.
\r
1151 if ( attValue === null ||
\r
1152 ( attValue.test && attValue.test( actualAttrValue ) ) ||
\r
1153 ( typeof attValue == 'string' && actualAttrValue == attValue ) )
\r
1154 element.removeAttribute( attName ) ;
\r
1159 removeNoAttribsElement( element );
\r
1162 // If the element has no more attributes, remove it.
\r
1163 function removeNoAttribsElement( element )
\r
1165 // If no more attributes remained in the element, remove it,
\r
1166 // leaving its children.
\r
1167 if ( !element.hasAttributes() )
\r
1169 // Removing elements may open points where merging is possible,
\r
1170 // so let's cache the first and last nodes for later checking.
\r
1171 var firstChild = element.getFirst();
\r
1172 var lastChild = element.getLast();
\r
1174 element.remove( true );
\r
1178 // Check the cached nodes for merging.
\r
1179 firstChild.type == CKEDITOR.NODE_ELEMENT && firstChild.mergeSiblings();
\r
1181 if ( lastChild && !firstChild.equals( lastChild )
\r
1182 && lastChild.type == CKEDITOR.NODE_ELEMENT )
\r
1183 lastChild.mergeSiblings();
\r
1188 function getElement( style, targetDocument, element )
\r
1192 var def = style._.definition;
\r
1194 var elementName = style.element;
\r
1196 // The "*" element name will always be a span for this function.
\r
1197 if ( elementName == '*' )
\r
1198 elementName = 'span';
\r
1200 // Create the element.
\r
1201 el = new CKEDITOR.dom.element( elementName, targetDocument );
\r
1203 // #6226: attributes should be copied before the new ones are applied
\r
1205 element.copyAttributes( el );
\r
1207 return setupElement( el, style );
\r
1210 function setupElement( el, style )
\r
1212 var def = style._.definition;
\r
1213 var attributes = def.attributes;
\r
1214 var styles = CKEDITOR.style.getStyleText( def );
\r
1216 // Assign all defined attributes.
\r
1219 for ( var att in attributes )
\r
1221 el.setAttribute( att, attributes[ att ] );
\r
1225 // Assign all defined styles.
\r
1227 el.setAttribute( 'style', styles );
\r
1232 var varRegex = /#\((.+?)\)/g;
\r
1233 function replaceVariables( list, variablesValues )
\r
1235 for ( var item in list )
\r
1237 list[ item ] = list[ item ].replace( varRegex, function( match, varName )
\r
1239 return variablesValues[ varName ];
\r
1245 // Returns an object that can be used for style matching comparison.
\r
1246 // Attributes names and values are all lowercased, and the styles get
\r
1247 // merged with the style attribute.
\r
1248 function getAttributesForComparison( styleDefinition )
\r
1250 // If we have already computed it, just return it.
\r
1251 var attribs = styleDefinition._AC;
\r
1259 // Loop through all defined attributes.
\r
1260 var styleAttribs = styleDefinition.attributes;
\r
1261 if ( styleAttribs )
\r
1263 for ( var styleAtt in styleAttribs )
\r
1266 attribs[ styleAtt ] = styleAttribs[ styleAtt ];
\r
1270 // Includes the style definitions.
\r
1271 var styleText = CKEDITOR.style.getStyleText( styleDefinition );
\r
1274 if ( !attribs[ 'style' ] )
\r
1276 attribs[ 'style' ] = styleText;
\r
1279 // Appends the "length" information to the object.
\r
1280 attribs._length = length;
\r
1282 // Return it, saving it to the next request.
\r
1283 return ( styleDefinition._AC = attribs );
\r
1287 * Get the the collection used to compare the elements and attributes,
\r
1288 * defined in this style overrides, with other element. All information in
\r
1289 * it is lowercased.
\r
1290 * @param {CKEDITOR.style} style
\r
1292 function getOverrides( style )
\r
1294 if ( style._.overrides )
\r
1295 return style._.overrides;
\r
1297 var overrides = ( style._.overrides = {} ),
\r
1298 definition = style._.definition.overrides;
\r
1302 // The override description can be a string, object or array.
\r
1303 // Internally, well handle arrays only, so transform it if needed.
\r
1304 if ( !CKEDITOR.tools.isArray( definition ) )
\r
1305 definition = [ definition ];
\r
1307 // Loop through all override definitions.
\r
1308 for ( var i = 0 ; i < definition.length ; i++ )
\r
1310 var override = definition[i];
\r
1315 // If can be a string with the element name.
\r
1316 if ( typeof override == 'string' )
\r
1317 elementName = override.toLowerCase();
\r
1321 elementName = override.element ? override.element.toLowerCase() : style.element;
\r
1322 attrs = override.attributes;
\r
1325 // We can have more than one override definition for the same
\r
1326 // element name, so we attempt to simply append information to
\r
1327 // it if it already exists.
\r
1328 overrideEl = overrides[ elementName ] || ( overrides[ elementName ] = {} );
\r
1332 // The returning attributes list is an array, because we
\r
1333 // could have different override definitions for the same
\r
1334 // attribute name.
\r
1335 var overrideAttrs = ( overrideEl.attributes = overrideEl.attributes || new Array() );
\r
1336 for ( var attName in attrs )
\r
1338 // Each item in the attributes array is also an array,
\r
1339 // where [0] is the attribute name and [1] is the
\r
1340 // override value.
\r
1341 overrideAttrs.push( [ attName.toLowerCase(), attrs[ attName ] ] );
\r
1350 // Make the comparison of attribute value easier by standardizing it.
\r
1351 function normalizeProperty( name, value, isStyle )
\r
1353 var temp = new CKEDITOR.dom.element( 'span' );
\r
1354 temp [ isStyle ? 'setStyle' : 'setAttribute' ]( name, value );
\r
1355 return temp[ isStyle ? 'getStyle' : 'getAttribute' ]( name );
\r
1358 // Make the comparison of style text easier by standardizing it.
\r
1359 function normalizeCssText( unparsedCssText, nativeNormalize )
\r
1362 if ( nativeNormalize !== false )
\r
1364 // Injects the style in a temporary span object, so the browser parses it,
\r
1365 // retrieving its final format.
\r
1366 var temp = new CKEDITOR.dom.element( 'span' );
\r
1367 temp.setAttribute( 'style', unparsedCssText );
\r
1368 styleText = temp.getAttribute( 'style' ) || '';
\r
1371 styleText = unparsedCssText;
\r
1373 // Shrinking white-spaces around colon and semi-colon (#4147).
\r
1374 // Compensate tail semi-colon.
\r
1375 return styleText.replace( /\s*([;:])\s*/, '$1' )
\r
1376 .replace( /([^\s;])$/, '$1;')
\r
1377 // Trimming spaces after comma(#4107),
\r
1378 // remove quotations(#6403),
\r
1379 // mostly for differences on "font-family".
\r
1380 .replace( /,\s+/g, ',' )
\r
1381 .replace( /\"/g,'' )
\r
1385 // Turn inline style text properties into one hash.
\r
1386 function parseStyleText( styleText )
\r
1390 .replace( /"/g, '"' )
\r
1391 .replace( /\s*([^ :;]+)\s*:\s*([^;]+)\s*(?=;|$)/g, function( match, name, value )
\r
1393 retval[ name ] = value;
\r
1399 * Compare two bunch of styles, with the speciality that value 'inherit'
\r
1400 * is treated as a wildcard which will match any value.
\r
1401 * @param {Object|String} source
\r
1402 * @param {Object|String} target
\r
1404 function compareCssText( source, target )
\r
1406 typeof source == 'string' && ( source = parseStyleText( source ) );
\r
1407 typeof target == 'string' && ( target = parseStyleText( target ) );
\r
1408 for( var name in source )
\r
1410 if ( !( name in target &&
\r
1411 ( target[ name ] == source[ name ]
\r
1412 || source[ name ] == 'inherit'
\r
1413 || target[ name ] == 'inherit' ) ) )
\r
1421 function applyStyle( document, remove )
\r
1423 var selection = document.getSelection(),
\r
1424 // Bookmark the range so we can re-select it after processing.
\r
1425 bookmarks = selection.createBookmarks( 1 ),
\r
1426 ranges = selection.getRanges(),
\r
1427 func = remove ? this.removeFromRange : this.applyToRange,
\r
1430 var iterator = ranges.createIterator();
\r
1431 while ( ( range = iterator.getNextRange() ) )
\r
1432 func.call( this, range );
\r
1434 if ( bookmarks.length == 1 && bookmarks[0].collapsed )
\r
1436 selection.selectRanges( ranges );
\r
1437 document.getById( bookmarks[ 0 ].startNode ).remove();
\r
1440 selection.selectBookmarks( bookmarks );
\r
1444 CKEDITOR.styleCommand = function( style )
\r
1446 this.style = style;
\r
1449 CKEDITOR.styleCommand.prototype.exec = function( editor )
\r
1453 var doc = editor.document;
\r
1457 if ( this.state == CKEDITOR.TRISTATE_OFF )
\r
1458 this.style.apply( doc );
\r
1459 else if ( this.state == CKEDITOR.TRISTATE_ON )
\r
1460 this.style.remove( doc );
\r
1466 CKEDITOR.stylesSet = new CKEDITOR.resourceManager( '', 'stylesSet' );
\r
1468 // Backward compatibility (#5025).
\r
1469 CKEDITOR.addStylesSet = CKEDITOR.tools.bind( CKEDITOR.stylesSet.add, CKEDITOR.stylesSet );
\r
1470 CKEDITOR.loadStylesSet = function( name, url, callback )
\r
1472 CKEDITOR.stylesSet.addExternal( name, url, '' );
\r
1473 CKEDITOR.stylesSet.load( name, callback );
\r
1478 * Gets the current styleSet for this instance
\r
1479 * @param {Function} callback The function to be called with the styles data.
\r
1481 * editor.getStylesSet( function( stylesDefinitions ) {} );
\r
1483 CKEDITOR.editor.prototype.getStylesSet = function( callback )
\r
1485 if ( !this._.stylesDefinitions )
\r
1487 var editor = this,
\r
1488 // Respect the backwards compatible definition entry
\r
1489 configStyleSet = editor.config.stylesCombo_stylesSet || editor.config.stylesSet || 'default';
\r
1491 // #5352 Allow to define the styles directly in the config object
\r
1492 if ( configStyleSet instanceof Array )
\r
1494 editor._.stylesDefinitions = configStyleSet;
\r
1495 callback( configStyleSet );
\r
1499 var partsStylesSet = configStyleSet.split( ':' ),
\r
1500 styleSetName = partsStylesSet[ 0 ],
\r
1501 externalPath = partsStylesSet[ 1 ],
\r
1502 pluginPath = CKEDITOR.plugins.registered.styles.path;
\r
1504 CKEDITOR.stylesSet.addExternal( styleSetName,
\r
1506 partsStylesSet.slice( 1 ).join( ':' ) :
\r
1507 pluginPath + 'styles/' + styleSetName + '.js', '' );
\r
1509 CKEDITOR.stylesSet.load( styleSetName, function( stylesSet )
\r
1511 editor._.stylesDefinitions = stylesSet[ styleSetName ];
\r
1512 callback( editor._.stylesDefinitions );
\r
1516 callback( this._.stylesDefinitions );
\r
1520 * Indicates that fully selected read-only elements will be included when
\r
1521 * applying the style (for inline styles only).
\r
1522 * @name CKEDITOR.style.includeReadonly
\r
1529 * Disables inline styling on read-only elements.
\r
1530 * @name CKEDITOR.config.disableReadonlyStyling
\r
1537 * The "styles definition set" to use in the editor. They will be used in the
\r
1538 * styles combo and the Style selector of the div container. <br>
\r
1539 * The styles may be defined in the page containing the editor, or can be
\r
1540 * loaded on demand from an external file. In the second case, if this setting
\r
1541 * contains only a name, the styles definition file will be loaded from the
\r
1542 * "styles" folder inside the styles plugin folder.
\r
1543 * Otherwise, this setting has the "name:url" syntax, making it
\r
1544 * possible to set the URL from which loading the styles file.<br>
\r
1545 * Previously this setting was available as config.stylesCombo_stylesSet<br>
\r
1546 * @name CKEDITOR.config.stylesSet
\r
1547 * @type String|Array
\r
1548 * @default 'default'
\r
1551 * // Load from the styles' styles folder (mystyles.js file).
\r
1552 * config.stylesSet = 'mystyles';
\r
1554 * // Load from a relative URL.
\r
1555 * config.stylesSet = 'mystyles:/editorstyles/styles.js';
\r
1557 * // Load from a full URL.
\r
1558 * config.stylesSet = 'mystyles:http://www.example.com/editorstyles/styles.js';
\r
1560 * // Load from a list of definitions.
\r
1561 * config.stylesSet = [
\r
1562 * { name : 'Strong Emphasis', element : 'strong' },
\r
1563 * { name : 'Emphasis', element : 'em' }, ... ];
\r