Index: _source/plugins/wysiwygarea/plugin.js =================================================================== --- _source/plugins/wysiwygarea/plugin.js (revision 7235) +++ _source/plugins/wysiwygarea/plugin.js (revision ) @@ -749,80 +749,82 @@ 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 fully selected element . (#4047) (#7645) + if ( 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(); + range.moveToPosition( selected, CKEDITOR.POSITION_BEFORE_START ); - // Remove the control manually. + // Remove the control manually. - control.remove(); - sel.selectBookmarks( [ bookmark ] ); + selected.remove(); + range.select(); - editor.fire( 'saveSnapshot' ); + editor.fire( 'saveSnapshot' ); - evt.data.preventDefault(); + evt.data.preventDefault(); + return; - } - } - } ); + } + } + } ); - // 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 7235) +++ _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 ); } }); @@ -1145,6 +1146,74 @@ { return self.getNative().createRange().item( 0 ); }, + // If a table or list is fully selected. + function() + { + var root, + retval, + range = self.getRanges()[ 0 ], + ancestor = range.getCommonAncestor( 1, 1 ), + tags = { table:1,ul:1,ol:1,dl:1 }; + + for ( var t in tags ) + { + if ( root = ancestor.getAscendant( t, 1 ) ) + break; + } + + if ( root ) + { + // Enlarging the start boundary. + var testRange = new CKEDITOR.dom.range( this.document ); + testRange.setStartAt( root, CKEDITOR.POSITION_AFTER_START ); + testRange.setEnd( range.startContainer, range.startOffset ); + + var enlargeables = CKEDITOR.tools.extend( tags, CKEDITOR.dtd.$listItem, CKEDITOR.dtd.$tableContent ), + walker = new CKEDITOR.dom.walker( testRange ), + // 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( testRange ); + testRange.setStart( range.endContainer, range.endOffset ); + testRange.setEndAt( root, CKEDITOR.POSITION_BEFORE_END ); + walker.guard = guard( walker, 1 ); + if ( walker.checkForward() && !walker.halted ) + retval = root.$; + } + } + + if ( !retval ) + throw 0; + + return retval; + }, // Figure it out by checking if there's a single enclosed // node of the range. function() @@ -1444,6 +1513,8 @@ sel.addRange( nativeRange ); } + // Don't miss selection change event for non-IEs. + this.document.fire( 'selectionchange' ); this.reset(); } },