X-Git-Url: https://jasonwoof.com/gitweb/?p=ckeditor.git;a=blobdiff_plain;f=_source%2Fplugins%2Fselection%2Fplugin.js;h=04be63171d0a106aeacbb2888e7f5b8277a498e7;hp=9a85a84da5502185fdd87382aa8f6ac183c71547;hb=8665a7c6c60586526e32e8941fe2896739b6ebfb;hpb=e7789c1ad838194d45eeee6ac2eb6e55f5cf35a1 diff --git a/_source/plugins/selection/plugin.js b/_source/plugins/selection/plugin.js index 9a85a84..04be631 100644 --- a/_source/plugins/selection/plugin.js +++ b/_source/plugins/selection/plugin.js @@ -209,7 +209,8 @@ For licensing, see LICENSE.html or http://ckeditor.com/license if ( saveEnabled ) { var doc = editor.document, - sel = doc && doc.$.selection; + sel = editor.getSelection(), + nativeSel = sel && sel.getNative(); // There is a very specific case, when clicking // inside a text selection. In that case, the @@ -219,7 +220,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license // range at the very start of the document. In // such situation we have to test the range, to // be sure it's valid. - if ( testIt && sel && sel.type == 'None' ) + if ( testIt && nativeSel && nativeSel.type == 'None' ) { // The "InsertImage" command can be used to // test whether the selection is good or not. @@ -232,7 +233,16 @@ For licensing, see LICENSE.html or http://ckeditor.com/license } } - savedRange = sel && sel.createRange(); + // Avoid saving selection from within text input. (#5747) + var parentTag; + if ( nativeSel.type == 'Text' + && ( parentTag = nativeSel.createRange().parentElement().nodeName.toLowerCase() ) + && parentTag in { input: 1, textarea : 1 } ) + { + return; + } + + savedRange = nativeSel && sel.getRanges()[ 0 ]; checkSelectionChangeTimeout.call( editor ); } @@ -752,16 +762,21 @@ For licensing, see LICENSE.html or http://ckeditor.com/license // node of the range. function() { - var range = self.getRanges()[ 0 ]; - range.shrink( CKEDITOR.SHRINK_ELEMENT ); - - var enclosed; - if ( range.startContainer.equals( range.endContainer ) - && ( range.endOffset - range.startOffset ) == 1 - && styleObjectElements[ ( enclosed = range.startContainer.getChild( range.startOffset ) ).getName() ] ) + var range = self.getRanges()[ 0 ], + enclosed, + selected; + + // Check first any enclosed element, e.g. + for ( var i = 2; i && !( ( enclosed = range.getEnclosedNode() ) + && ( enclosed.type == CKEDITOR.NODE_ELEMENT ) + && styleObjectElements[ enclosed.getName() ] + && ( selected = enclosed ) ); i-- ) { - return enclosed.$; + // Then check any deep wrapped element, e.g. [] + range.shrink( CKEDITOR.SHRINK_ELEMENT ); } + + return selected.$; }); return cache.selectedElement = ( node ? new CKEDITOR.dom.element( node ) : null ); @@ -1009,6 +1024,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license { var notWhitespaces = CKEDITOR.dom.walker.whitespaces( true ); var fillerTextRegex = /\ufeff|\u00a0/; +var nonCells = { table:1,tbody:1,tr:1 }; CKEDITOR.dom.range.prototype.select = CKEDITOR.env.ie ? @@ -1019,6 +1035,14 @@ CKEDITOR.dom.range.prototype.select = var isStartMarkerAlone; var dummySpan; + // IE doesn't support selecting the entire table row/cell, move the selection into cells, e.g. + // [... =>
cell
... + if ( this.startContainer.type == CKEDITOR.NODE_ELEMENT && this.startContainer.getName() in nonCells + || this.endContainer.type == CKEDITOR.NODE_ELEMENT && this.endContainer.getName() in nonCells ) + { + this.shrink( CKEDITOR.NODE_ELEMENT, true ); + } + var bookmark = this.createBookmark(); // Create marker tags for the start and end boundaries.
[cell