X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=_source%2Fplugins%2Fenterkey%2Fplugin.js;h=5046b1d0ddc9d1b1fb0145b7164f1d96876b7bfa;hb=039a051ccf3901311661022a30afd60fc38130c9;hp=10b7e621004e3056502b2c8e43d1ff4792272bf6;hpb=8665a7c6c60586526e32e8941fe2896739b6ebfb;p=ckeditor.git diff --git a/_source/plugins/enterkey/plugin.js b/_source/plugins/enterkey/plugin.js index 10b7e62..5046b1d 100644 --- a/_source/plugins/enterkey/plugin.js +++ b/_source/plugins/enterkey/plugin.js @@ -24,6 +24,11 @@ For licensing, see LICENSE.html or http://ckeditor.com/license // Get the range for the current selection. range = range || getRange( editor ); + // We may not have valid ranges to work on, like when inside a + // contenteditable=false element. + if ( !range ) + return; + var doc = range.document; // Exit the list when we're inside an empty list item block. (#5376) @@ -64,7 +69,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license if ( node.is( 'li' ) ) { nextBlock.breakParent( node ); - nextBlock.move( nextBlock.getNext(), true ); + nextBlock.move( nextBlock.getNext(), 1 ); } } else if ( previousBlock && ( node = previousBlock.getParent() ) && node.is( 'li' ) ) @@ -189,6 +194,11 @@ For licensing, see LICENSE.html or http://ckeditor.com/license // Get the range for the current selection. range = range || getRange( editor ); + // We may not have valid ranges to work on, like when inside a + // contenteditable=false element. + if ( !range ) + return; + var doc = range.document; // Determine the block element to be used. @@ -307,7 +317,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license return true; } else - return enter( editor, editor.config.shiftEnterMode, true ); + return enter( editor, editor.config.shiftEnterMode, 1 ); } function enter( editor, mode, forceMode ) @@ -325,7 +335,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license setTimeout( function() { editor.fire( 'saveSnapshot' ); // Save undo step. - if ( mode == CKEDITOR.ENTER_BR || editor.getSelection().getStartElement().hasAscendant( 'pre', true ) ) + if ( mode == CKEDITOR.ENTER_BR || editor.getSelection().getStartElement().hasAscendant( 'pre', 1 ) ) enterBr( editor, mode, null, forceMode ); else enterBlock( editor, mode, null, forceMode ); @@ -339,7 +349,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license function getRange( editor ) { // Get the selection ranges. - var ranges = editor.getSelection().getRanges(); + var ranges = editor.getSelection().getRanges( true ); // Delete the contents of all ranges except the first one. for ( var i = ranges.length - 1 ; i > 0 ; i-- )