Changeset 4546
- Timestamp:
- 11/26/09 19:38:36 (3 years ago)
- Location:
- CKEditor/trunk
- Files:
-
- 6 edited
-
CHANGES.html (modified) (1 diff)
-
_source/core/dom/element.js (modified) (2 diffs)
-
_source/core/dom/walker.js (modified) (1 diff)
-
_source/plugins/enterkey/plugin.js (modified) (1 diff)
-
_source/plugins/list/plugin.js (modified) (2 diffs)
-
_source/plugins/selection/plugin.js (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
CKEditor/trunk/CHANGES.html
r4542 r4546 81 81 <li><a href="http://dev.fckeditor.net/ticket/4455">#4455</a> : Fixed unable to start editing when image inside document not loaded.</li> 82 82 <li><a href="http://dev.fckeditor.net/ticket/4517">#4517</a> : Fixed 'dialog_backgroundCoverColor' doesn't work on IE6.</li> 83 <li><a href="http://dev.fckeditor.net/ticket/3165">#3165</a> : Fixed enter key in empty list item before nested one result in collapsed line.</li> 83 84 <h3> 84 85 CKEditor 3.0.1</h3> -
CKEditor/trunk/_source/core/dom/element.js
r4534 r4546 628 628 /** 629 629 * Gets the first child node of this element. 630 * @param {Function} evaluator Filtering the result node. 630 631 * @returns {CKEDITOR.dom.node} The first child node or null if not 631 632 * available. … … 635 636 * alert( first.getName() ); // "b" 636 637 */ 637 getFirst : function() 638 { 639 var $ = this.$.firstChild; 640 return $ ? new CKEDITOR.dom.node( $ ) : null; 638 getFirst : function( evaluator ) 639 { 640 var first = this.$.firstChild, 641 retval = first && new CKEDITOR.dom.node( first ); 642 if ( retval && evaluator && !evaluator( retval ) ) 643 retval = retval.getNext( evaluator ); 644 645 return retval; 641 646 }, 642 647 -
CKEditor/trunk/_source/core/dom/walker.js
r4034 r4546 409 409 }; 410 410 }; 411 412 /** 413 * Whether the node is invisible in wysiwyg mode. 414 * @param isReject 415 */ 416 CKEDITOR.dom.walker.invisible = function( isReject ) 417 { 418 var whitespace = CKEDITOR.dom.walker.whitespaces(); 419 return function( node ) 420 { 421 // Nodes that take no spaces in wysiwyg: 422 // 1. White-spaces but not including NBSP; 423 // 2. Empty inline elements, e.g. <b></b> we're checking here 424 // 'offsetHeight' instead of 'offsetWidth' for properly excluding 425 // all sorts of empty paragraph, e.g. <br />. 426 var isInvisible = whitespace( node ) || node.is && !node.$.offsetHeight; 427 return isReject ^ isInvisible; 428 }; 429 }; 430 411 431 })(); -
CKEditor/trunk/_source/plugins/enterkey/plugin.js
r3978 r4546 102 102 { 103 103 // If the next block is an <li> with another list tree as the first 104 // child, we'll need to append a placeholderor the list item104 // child, we'll need to append a filler (<br>/NBSP) or the list item 105 105 // wouldn't be editable. (#1420) 106 if ( nextBlock.is( 'li' ) && ( node = nextBlock.getFirst() ) 107 && node.is && node.is( 'ul', 'ol') ) 108 nextBlock.insertBefore( doc.createText( '\xa0' ), node ); 106 if ( nextBlock.is( 'li' ) 107 && ( node = nextBlock.getFirst( CKEDITOR.dom.walker.invisible( true ) ) ) 108 && node.is && node.is( 'ul', 'ol' ) ) 109 ( CKEDITOR.env.ie ? doc.createText( '\xa0' ) : doc.createElement( 'br' ) ).insertBefore( node ); 109 110 110 111 // Move the selection to the end block. -
CKEditor/trunk/_source/plugins/list/plugin.js
r4523 r4546 540 540 }; 541 541 542 var dtd = CKEDITOR.dtd; 543 var tailNbspRegex = /[\t\r\n ]*(?: |\xa0)$/; 544 545 function indexOfFirstChildElement( element, tagNameList ) 546 { 547 var children = element.children, 548 child, 549 length = children.length; 550 for ( var i = 0; i < length; i++ ) 551 { 552 child = children[ i ]; 553 if( child.name && ( child.name in tagNameList ) ) 554 return i; 555 } 556 } 557 558 function getExtendNestedListFilter( isHtmlFilter ) 559 { 560 // An element filter function that corrects nested list start in an empty 561 // list item for better displaying/outputting. (#3165) 562 return function( listItem ) 563 { 564 var children = listItem.children, 565 firstNestedListIndex = indexOfFirstChildElement( listItem, dtd.$list ), 566 firstNestedList = children[ firstNestedListIndex ], 567 nodeBefore = firstNestedList && firstNestedList.previous, 568 tailNbspmatch; 569 570 if( nodeBefore 571 && ( nodeBefore.name && nodeBefore.name == 'br' 572 || nodeBefore.value && ( tailNbspmatch = nodeBefore.value.match( tailNbspRegex ) ) ) ) 573 { 574 var fillerNode = nodeBefore; 575 576 // Always use 'nbsp' as filler node if we found a nested list appear 577 // in front of a list item. 578 if ( !( tailNbspmatch && tailNbspmatch.index ) && fillerNode == children[ 0 ] ) 579 children[ 0 ] = ( isHtmlFilter || CKEDITOR.env.ie ) ? 580 new CKEDITOR.htmlParser.text( '\xa0' ) : 581 new CKEDITOR.htmlParser.element( 'br', {} ); 582 583 // Otherwise the filler is not needed anymore. 584 else if ( fillerNode.name == 'br' ) 585 children.splice( firstNestedListIndex - 1, 1 ); 586 else 587 fillerNode.value = fillerNode.value.replace( tailNbspRegex, '' ); 588 } 589 590 }; 591 } 592 593 var defaultListDataFilterRules = { elements : {} }; 594 for( var i in dtd.$listItem ) 595 defaultListDataFilterRules.elements[ i ] = getExtendNestedListFilter(); 596 597 var defaultListHtmlFilterRules = { elements : {} }; 598 for( i in dtd.$listItem ) 599 defaultListHtmlFilterRules.elements[ i ] = getExtendNestedListFilter( true ); 600 542 601 CKEDITOR.plugins.add( 'list', 543 602 { … … 567 626 }, 568 627 628 afterInit : function ( editor ) 629 { 630 var dataProcessor = editor.dataProcessor; 631 if( dataProcessor ) 632 { 633 dataProcessor.dataFilter.addRules( defaultListDataFilterRules ); 634 dataProcessor.htmlFilter.addRules( defaultListHtmlFilterRules ); 635 } 636 }, 637 569 638 requires : [ 'domiterator' ] 570 639 } ); -
CKEditor/trunk/_source/plugins/selection/plugin.js
r4521 r4546 953 953 }; 954 954 })(); 955 ( function() 956 { 957 var notWhitespaces = CKEDITOR.dom.walker.whitespaces( true ); 958 var fillerTextRegex = /\ufeff|\u00a0/; 955 959 956 960 CKEDITOR.dom.range.prototype.select = … … 997 1001 // Actually, we are using this flag just to avoid using this hack in all 998 1002 // situations, but just on those needed. 999 isStartMarkerAlone = forceExpand || !startNode.hasPrevious() || ( startNode.getPrevious().is && startNode.getPrevious().is( 'br' ) ); 1003 var next = startNode.getNext( notWhitespaces ); 1004 isStartMarkerAlone = ( !( next && next.getText && next.getText().match( fillerTextRegex ) ) // already a filler there? 1005 && ( forceExpand || !startNode.hasPrevious() || ( startNode.getPrevious().is && startNode.getPrevious().is( 'br' ) ) ) ); 1000 1006 1001 1007 // Append a temporary <span></span> before the selection. … … 1081 1087 selection.addRange( nativeRange ); 1082 1088 }; 1089 } )();
Note: See TracChangeset
for help on using the changeset viewer.
