Ticket #6103: 6103_5.patch
File 6103_5.patch, 7.3 KB (added by , 13 years ago) |
---|
-
_source/plugins/colorbutton/plugin.js
100 100 var colorStyle = config['colorButton_' + type + 'Style']; 101 101 102 102 colorStyle.childRule = type == 'back' ? 103 // It's better to apply background color as the innermost style. (#3599) 104 function(){ return false; } : 105 // Fore color style must be applied inside links instead of around it. 106 function( element ){ return element.getName() != 'a'; }; 103 function( element ) 104 { 105 // It's better to apply background color as the innermost style. (#3599) 106 // Except for "unstylable elements". (#6103) 107 return isUnstylable( element ); 108 } 109 : 110 function( element ) 111 { 112 // Fore color style must be applied inside links instead of around it. 113 return element.getName() != 'a' || isUnstylable( element ); 114 }; 107 115 116 if ( colorStyle.includeReadonly == undefined ) 117 colorStyle.includeReadonly = !editor.config.disableReadonlyStyling; 118 108 119 new CKEDITOR.style( colorStyle, { color : color } ).apply( editor.document ); 109 120 } 110 121 … … 181 192 182 193 return output.join( '' ); 183 194 } 195 196 function isUnstylable( ele ) 197 { 198 return ( ele.getAttribute( 'contentEditable' ) == 'false' ) || ele.getAttribute( 'data-cke-nostyle' ); 199 } 184 200 } 185 201 }); 186 202 -
_source/plugins/styles/plugin.js
353 353 return ( styleDefinition._ST = stylesText ); 354 354 }; 355 355 356 // Gets the parent element which blocks the styling for an element. This 357 // can be done through read-only elements (contenteditable=false) or 358 // elements with the "data-cke-nostyle" attribute. 359 function getUnstylableParent( element ) 360 { 361 var unstylable, 362 editable; 363 364 while ( ( element = element.getParent() ) ) 365 { 366 if ( element.getName() == 'body' ) 367 break; 368 369 if ( element.getAttribute( 'data-cke-nostyle' ) ) 370 unstylable = element; 371 else if ( !editable ) 372 { 373 var contentEditable = element.getAttribute( 'contentEditable' ); 374 375 if ( contentEditable == 'false' ) 376 unstylable = element; 377 else if ( contentEditable == 'true' ) 378 editable = 1; 379 } 380 } 381 382 return unstylable; 383 } 384 356 385 function applyInlineStyle( range ) 357 386 { 358 387 var document = range.document; … … 375 404 var def = this._.definition; 376 405 var isUnknownElement; 377 406 407 // Indicates that fully selected read-only elements are to be included in the styling range. 408 var includeReadonly = def.includeReadonly; 409 410 if ( includeReadonly == undefined ) 411 includeReadonly = this._.includeReadonly; 412 378 413 // Get the DTD definition for the element. Defaults to "span". 379 414 var dtd = CKEDITOR.dtd[ elementName ] || ( isUnknownElement = true, CKEDITOR.dtd.span ); 380 415 … … 392 427 393 428 var styleRange; 394 429 430 // Check if the boundaries are inside non stylable elements. 431 var firstUnstylable = getUnstylableParent( firstNode ), 432 lastUnstylable = getUnstylableParent( lastNode ); 433 434 // If the first element can't be styled, we'll start processing right 435 // after its unstylable root. 436 if ( firstUnstylable ) 437 currentNode = firstUnstylable.getNextSourceNode( true ); 438 439 // If the last element can't be styled, we'll stop processing on its 440 // unstylable root. 441 if ( lastUnstylable ) 442 lastNode = lastUnstylable; 443 444 // Do nothing if the current node now follows the last node to be processed. 445 if ( currentNode.getPosition( lastNode ) == CKEDITOR.POSITION_FOLLOWING ) 446 currentNode = 0; 447 395 448 while ( currentNode ) 396 449 { 397 450 var applyStyle = false; … … 405 458 { 406 459 var nodeType = currentNode.type; 407 460 var nodeName = nodeType == CKEDITOR.NODE_ELEMENT ? currentNode.getName() : null; 461 var nodeIsReadonly = nodeName && ( currentNode.getAttribute( 'contentEditable' ) == 'false' ); 462 var nodeIsNoStyle = nodeName && currentNode.getAttribute( 'data-cke-nostyle' ); 408 463 409 464 if ( nodeName && currentNode.getAttribute( '_cke_bookmark' ) ) 410 465 { … … 414 469 415 470 // Check if the current node can be a child of the style element. 416 471 if ( !nodeName || ( dtd[ nodeName ] 472 && !nodeIsNoStyle 473 && ( !nodeIsReadonly || includeReadonly ) 417 474 && ( currentNode.getPosition( lastNode ) | CKEDITOR.POSITION_PRECEDING | CKEDITOR.POSITION_IDENTICAL | CKEDITOR.POSITION_IS_CONTAINED ) == ( CKEDITOR.POSITION_PRECEDING + CKEDITOR.POSITION_IDENTICAL + CKEDITOR.POSITION_IS_CONTAINED ) 418 475 && ( !def.childRule || def.childRule( currentNode ) ) ) ) 419 476 { … … 435 492 styleRange.setStartBefore( currentNode ); 436 493 } 437 494 438 // Non element nodes, or empty elements can be added439 // completely to the range.440 if ( nodeType == CKEDITOR.NODE_TEXT || ( nodeType == CKEDITOR.NODE_ELEMENT && !currentNode.getChildCount() ) )495 // Non element nodes, readonly elements, or empty 496 // elements can be added completely to the range. 497 if ( nodeType == CKEDITOR.NODE_TEXT || nodeIsReadonly || ( nodeType == CKEDITOR.NODE_ELEMENT && !currentNode.getChildCount() ) ) 441 498 { 442 499 var includedNode = currentNode; 443 500 var parentNode; … … 461 518 // in this style DTD, so apply the style immediately. 462 519 if ( !includedNode.$.nextSibling ) 463 520 applyStyle = true; 464 465 521 } 466 522 } 467 523 else … … 471 527 applyStyle = true; 472 528 473 529 // Get the next node to be processed. 474 currentNode = currentNode.getNextSourceNode( );530 currentNode = currentNode.getNextSourceNode( nodeIsNoStyle || nodeIsReadonly ); 475 531 } 476 532 477 533 // Apply the style if we have something to which apply it. … … 1355 1411 var selection = document.getSelection(), 1356 1412 // Bookmark the range so we can re-select it after processing. 1357 1413 bookmarks = selection.createBookmarks( 1 ), 1358 ranges = selection.getRanges( 1),1414 ranges = selection.getRanges(), 1359 1415 func = remove ? this.removeFromRange : this.applyToRange, 1360 1416 range; 1361 1417 … … 1386 1442 1387 1443 if ( doc ) 1388 1444 { 1445 // Set the includeReadonly priv property as a backup if the it's not 1446 // available in the style definition. 1447 this.style._.includeReadonly = !editor.config.disableReadonlyStyling; 1448 1389 1449 if ( this.state == CKEDITOR.TRISTATE_OFF ) 1390 1450 this.style.apply( doc ); 1391 1451 else if ( this.state == CKEDITOR.TRISTATE_ON ) … … 1449 1509 }; 1450 1510 1451 1511 /** 1512 * Indicates that fully selected read-only elements will be included when 1513 * applying the style (for inline styles only). 1514 * @name CKEDITOR.style.includeReadonly 1515 * @type Boolean 1516 * @default false 1517 * @since 3.5 1518 */ 1519 1520 /** 1521 * Disables inline styling on read-only elements. 1522 * @name CKEDITOR.config.disableReadonlyStyling 1523 * @type Boolean 1524 * @default false 1525 * @since 3.5 1526 */ 1527 1528 /** 1452 1529 * The "styles definition set" to use in the editor. They will be used in the 1453 1530 * styles combo and the Style selector of the div container. <br> 1454 1531 * The styles may be defined in the page containing the editor, or can be