Ticket #6103: 6103.patch
File 6103.patch, 4.0 KB (added by , 14 years ago) |
---|
-
_source/plugins/styles/plugin.js
110 110 111 111 CKEDITOR.style.prototype = 112 112 { 113 apply : function( document )113 apply : function( document, config ) 114 114 { 115 applyStyle.call( this, document, false );115 applyStyle.call( this, document, false, config ); 116 116 }, 117 117 118 remove : function( document )118 remove : function( document, config ) 119 119 { 120 applyStyle.call( this, document, true );120 applyStyle.call( this, document, true, config ); 121 121 }, 122 122 123 123 applyToRange : function( range ) … … 1316 1316 return true; 1317 1317 } 1318 1318 1319 function applyStyle( document, remove )1319 function applyStyle( document, remove, config ) 1320 1320 { 1321 1321 var selection = document.getSelection(), 1322 1322 // Bookmark the range so we can re-select it after processing. 1323 1323 bookmarks = selection.createBookmarks(), 1324 ranges = selection.getRanges( true),1324 ranges = selection.getRanges( config.disableReadonlyStyling || this.type != CKEDITOR.STYLE_INLINE ), 1325 1325 func = remove ? this.removeFromRange : this.applyToRange, 1326 range ;1326 range, node; 1327 1327 1328 // Search for cke_nostyle elements and not fully selected readonly elements. 1329 if ( !config.disableReadonlyStyling && this.type == CKEDITOR.STYLE_INLINE ) 1330 { 1331 for ( var i = 0; i < ranges.length; i++ ) 1332 { 1333 range = ranges[ i ]; 1334 1335 var startContainer = range.startContainer, 1336 endContainer = range.endContainer, 1337 walkerRange = range.clone(); 1338 1339 // Use only fully selected readonly elements. 1340 var readOnly; 1341 if ( ( readOnly = startContainer.isReadOnly() ) ) 1342 { 1343 node = startContainer; 1344 1345 while ( readOnly.$ != parent.$ ) 1346 { 1347 if ( node.getPrevious() ) 1348 { 1349 range.setStartAfter( readOnly ); 1350 break; 1351 } 1352 node = node.getParent(); 1353 } 1354 } 1355 1356 if ( ( readOnly = endContainer.isReadOnly() ) ) 1357 { 1358 node = endContainer; 1359 1360 while ( readOnly.$ != parent.$ ) 1361 { 1362 if ( node.getNext() ) 1363 { 1364 range.setStartBefore( readOnly ); 1365 break; 1366 } 1367 node = node.getParent(); 1368 } 1369 } 1370 1371 if ( range.collapsed ) 1372 continue; 1373 1374 // Looking for non-stylable element inside the range. 1375 var walker = new CKEDITOR.dom.walker( walkerRange ); 1376 walker.evaluator = function( node ) 1377 { 1378 if ( node.type == CKEDITOR.NODE_ELEMENT 1379 && node.hasAttribute( 'cke_nostyle' ) ) 1380 { 1381 var newRange = range.clone(); 1382 range.setEndBefore( node ); 1383 1384 // Drop collapsed range around read-only elements, 1385 // it make sure the range list empty when selecting 1386 // only non-editable elements. 1387 if ( range.collapsed ) 1388 ranges.splice( i--, 1 ); 1389 1390 // Avoid creating invalid range. 1391 if ( !( node.getPosition( walkerRange.endContainer ) & CKEDITOR.POSITION_CONTAINS ) ) 1392 { 1393 newRange.setStartAfter( node ); 1394 if ( !newRange.collapsed ) 1395 ranges.splice( i + 1, 0, newRange ); 1396 } 1397 1398 return true; 1399 } 1400 1401 return false; 1402 }; 1403 1404 walker.next(); 1405 } 1406 } 1407 1328 1408 var iterator = ranges.createIterator(); 1329 1409 while ( ( range = iterator.getNextRange() ) ) 1330 1410 func.call( this, range ); … … 1353 1433 if ( doc ) 1354 1434 { 1355 1435 if ( this.state == CKEDITOR.TRISTATE_OFF ) 1356 this.style.apply( doc );1436 this.style.apply( doc, editor.config ); 1357 1437 else if ( this.state == CKEDITOR.TRISTATE_ON ) 1358 this.style.remove( doc );1438 this.style.remove( doc, editor.config ); 1359 1439 } 1360 1440 1361 1441 return !!doc; … … 1415 1495 }; 1416 1496 1417 1497 /** 1498 * Disables styling of read only inline elements. 1499 * @type Boolean 1500 * @default false 1501 * @example 1502 * config.disableReadonlyStyling = true; 1503 */ 1504 CKEDITOR.config.disableReadonlyStyling = false; 1505 1506 /** 1418 1507 * The "styles definition set" to use in the editor. They will be used in the 1419 1508 * styles combo and the Style selector of the div container. <br> 1420 1509 * The styles may be defined in the page containing the editor, or can be