Index: _source/plugins/wysiwygarea/plugin.js =================================================================== --- _source/plugins/wysiwygarea/plugin.js (revision 6934) +++ _source/plugins/wysiwygarea/plugin.js (revision ) @@ -758,7 +758,7 @@ // Delete any element that 'hasLayout' (e.g. hr,table) in IE8 will // break up the selection, safely manage it here. (#4795) - var bookmark = sel.getRanges()[ 0 ].createBookmark(); + var bookmark = range.createBookmark(); // Remove the control manually. control.remove(); sel.selectBookmarks( [ bookmark ] ); @@ -767,6 +767,11 @@ evt.data.preventDefault(); } + + // A fully selected table/list produces a range anchors only at inner boundaries, enlarge it here. (#7645) + var range = sel.getRanges()[ 0 ]; + if ( range.enlarge( CKEDITOR.ENLARGE_LIST_TABLE ) ) + range.select(); } } ); Index: _source/core/dom/walker.js =================================================================== --- _source/core/dom/walker.js (revision 6684) +++ _source/core/dom/walker.js (revision ) @@ -446,6 +446,9 @@ // Check if there's a filler node at the end of an element, and return it. CKEDITOR.dom.element.prototype.getBogus = function() { + if ( !this.isBlockBoundary() ) + return null; + // Bogus are not always at the end, e.g.
(#7070). var tail = this; do { tail = tail.getPreviousSourceNode(); } Index: _source/core/dom/range.js =================================================================== --- _source/core/dom/range.js (revision 6904) +++ _source/core/dom/range.js (revision ) @@ -386,10 +386,9 @@ { // Reject any text node unless it's being bookmark // OR it's spaces. (#3883) - return node.type != CKEDITOR.NODE_TEXT - && node.getName() in CKEDITOR.dtd.$removeEmpty - || !CKEDITOR.tools.trim( node.getText() ) - || !!node.getParent().data( 'cke-bookmark' ); + return node.type == CKEDITOR.NODE_TEXT ? + !CKEDITOR.tools.trim( node.getText() ) || node.getParent().data( 'cke-bookmark' ) + : node.getName() in CKEDITOR.dtd.$removeEmpty; } var whitespaceEval = new CKEDITOR.dom.walker.whitespaces(), @@ -1349,7 +1348,73 @@ // one and we're expanding list item contents if ( tailBr ) this.setEndAfter( tailBr ); + break; + + case CKEDITOR.ENLARGE_LIST_TABLE: + + var ancestor = this.getCommonAncestor( 1, 1 ), + root; + + var tags = { table:1,ul:1,ol:1,dl:1}; + for ( var t in tags ) + { + root = ancestor.getAscendant( t, 1 ); + if ( root ) break; - } + } + + if ( !root ) + return false; + + // Enlarging the start boundary. + walkerRange = new CKEDITOR.dom.range( this.document ); + walkerRange.setStartAt( root, CKEDITOR.POSITION_AFTER_START ); + walkerRange.setEnd( this.startContainer, this.startOffset ); + + var enlargeables = CKEDITOR.tools.extend( tags, CKEDITOR.dtd.$listItem, CKEDITOR.dtd.$tableContent ); + walker = new CKEDITOR.dom.walker( walkerRange ), + + // Check the range is at the inner boundary of the structural element. + guard = function( walker, isEnd ) + { + return function( node, isWalkOut ) + { + if ( node.type == CKEDITOR.NODE_TEXT && ( !CKEDITOR.tools.trim( node.getText() ) || node.getParent().data( 'cke-bookmark' ) ) ) + return true; + + var tag; + if ( node.type == CKEDITOR.NODE_ELEMENT ) + { + tag = node.getName(); + + // Bypass bogus br at the end of block. + if ( tag == 'br' && isEnd && node.equals( node.getParent().getBogus() ) ) + return true; + + if ( isWalkOut && tag in enlargeables || tag in CKEDITOR.dtd.$removeEmpty ) + return true; + } + + walker.halted = 1; + return false; + }; + }; + + walker.guard = guard( walker ); + + if ( walker.checkBackward() && !walker.halted ) + { + walker = new CKEDITOR.dom.walker( walkerRange ); + walkerRange.setStart( this.endContainer, this.endOffset ); + walkerRange.setEndAt( root, CKEDITOR.POSITION_BEFORE_END ); + walker.guard = guard( walker, 1 ); + if ( walker.checkForward() && !walker.halted ) + { + this.setStartBefore( root ); + this.setEndAfter( root ); + return true; + } + } + } }, /** @@ -2019,6 +2084,7 @@ CKEDITOR.ENLARGE_ELEMENT = 1; CKEDITOR.ENLARGE_BLOCK_CONTENTS = 2; CKEDITOR.ENLARGE_LIST_ITEM_CONTENTS = 3; +CKEDITOR.ENLARGE_LIST_TABLE = 4; // Check boundary types. // @see CKEDITOR.dom.range.prototype.checkBoundaryOfElement