Index: _source/plugins/wysiwygarea/plugin.js =================================================================== --- _source/plugins/wysiwygarea/plugin.js (revision 7196) +++ _source/plugins/wysiwygarea/plugin.js (revision ) @@ -759,80 +759,87 @@ keystrokeHandler.blockedKeystrokes[ 8 ] = !editable; keystrokeHandler.attach( domDocument ); - if ( CKEDITOR.env.ie ) - { - domDocument.getDocumentElement().addClass( domDocument.$.compatMode ); + domDocument.getDocumentElement().addClass( domDocument.$.compatMode ); - // Override keystrokes which should have deletion behavior - // on control types in IE . (#4047) + // Override keystroke behaviors. - editable && domDocument.on( 'keydown', function( evt ) - { - var keyCode = evt.data.getKeystroke(); + editable && domDocument.on( 'keydown', function( evt ) + { + var keyCode = evt.data.getKeystroke(); - // Backspace OR Delete. - if ( keyCode in { 8 : 1, 46 : 1 } ) - { - var sel = editor.getSelection(), + // Backspace OR Delete. + if ( keyCode in { 8 : 1, 46 : 1 } ) + { + var sel = editor.getSelection(), - control = sel.getSelectedElement(); + selected = sel.getSelectedElement(), + range = sel.getRanges()[ 0 ]; - if ( control ) + // Override keystrokes which should have deletion behavior + // on control types in IE . (#4047) + if ( CKEDITOR.env.ie && selected ) - { - // Make undo snapshot. - editor.fire( 'saveSnapshot' ); + { + // Make undo snapshot. + editor.fire( 'saveSnapshot' ); - // Delete any element that 'hasLayout' (e.g. hr,table) in IE8 will - // break up the selection, safely manage it here. (#4795) + // 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. + // Remove the control manually. - control.remove(); + selected.remove(); - sel.selectBookmarks( [ bookmark ] ); + sel.selectBookmarks( [ bookmark ] ); - editor.fire( 'saveSnapshot' ); + editor.fire( 'saveSnapshot' ); - evt.data.preventDefault(); + evt.data.preventDefault(); + return; - } + } + + // A fully selected table/list produces a range anchors only at inner boundaries, enlarge it here. (#7645) + if ( range.enlarge( CKEDITOR.ENLARGE_LIST_TABLE ) ) + range.select(); + debugger; - } - } ); + } + } ); - // PageUp/PageDown scrolling is broken in document - // with standard doctype, manually fix it. (#4736) + // PageUp/PageDown scrolling is broken in document + // with standard doctype, manually fix it. (#4736) - if ( domDocument.$.compatMode == 'CSS1Compat' ) + if ( CKEDITOR.env.ie && domDocument.$.compatMode == 'CSS1Compat' ) - { - var pageUpDownKeys = { 33 : 1, 34 : 1 }; - domDocument.on( 'keydown', function( evt ) - { - if ( evt.data.getKeystroke() in pageUpDownKeys ) - { - setTimeout( function () - { - editor.getSelection().scrollIntoView(); - }, 0 ); - } - } ); - } + { + var pageUpDownKeys = { 33 : 1, 34 : 1 }; + domDocument.on( 'keydown', function( evt ) + { + if ( evt.data.getKeystroke() in pageUpDownKeys ) + { + setTimeout( function () + { + editor.getSelection().scrollIntoView(); + }, 0 ); + } + } ); + } - // Prevent IE from leaving new paragraph after deleting all contents in body. (#6966) + // Prevent IE from leaving new paragraph after deleting all contents in body. (#6966) - editor.config.enterMode != CKEDITOR.ENTER_P - && domDocument.on( 'selectionchange', function() + if ( CKEDITOR.env.ie && editor.config.enterMode != CKEDITOR.ENTER_P ) - { + { + domDocument.on( 'selectionchange', function() + { - var body = domDocument.getBody(), - range = editor.getSelection().getRanges()[ 0 ]; + var body = domDocument.getBody(), + range = editor.getSelection().getRanges()[ 0 ]; - if ( body.getHtml().match( /^
<\/p>$/i ) - && range.startContainer.equals( body ) ) - { - // Avoid the ambiguity from a real user cursor position. - setTimeout( function () - { - range = editor.getSelection().getRanges()[ 0 ]; - if ( !range.startContainer.equals ( 'body' ) ) - { - body.getFirst().remove( 1 ); - range.moveToElementEditEnd( body ); - range.select( 1 ); - } - }, 0 ); - } - }); + if ( body.getHtml().match( /^
<\/p>$/i ) + && range.startContainer.equals( body ) ) + { + // Avoid the ambiguity from a real user cursor position. + setTimeout( function () + { + range = editor.getSelection().getRanges()[ 0 ]; + if ( !range.startContainer.equals ( 'body' ) ) + { + body.getFirst().remove( 1 ); + range.moveToElementEditEnd( body ); + range.select( 1 ); + } + }, 0 ); + } + }); } // Adds the document body as a context menu target. Index: _source/plugins/selection/plugin.js =================================================================== --- _source/plugins/selection/plugin.js (revision 7196) +++ _source/plugins/selection/plugin.js (revision ) @@ -463,6 +463,7 @@ doc.on( 'mouseup', checkSelectionChangeTimeout, editor ); doc.on( 'keyup', checkSelectionChangeTimeout, editor ); + doc.on( 'selectionchange', checkSelectionChangeTimeout, editor ); } }); @@ -1432,6 +1433,8 @@ sel.addRange( nativeRange ); } + // Don't miss selection change event for non-IEs. + this.document.fire( 'selectionchange' ); this.reset(); } }, Index: _source/core/dom/range.js =================================================================== --- _source/core/dom/range.js (revision 7218) +++ _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(), @@ -1365,7 +1364,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; + } + } + } }, /** @@ -2035,6 +2100,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