X-Git-Url: https://jasonwoof.com/gitweb/?p=ckeditor.git;a=blobdiff_plain;f=_source%2Fplugins%2Fenterkey%2Fplugin.js;h=10b7e621004e3056502b2c8e43d1ff4792272bf6;hp=cce120845273ce847a3ef1547c12e26a60e745e6;hb=8665a7c6c60586526e32e8941fe2896739b6ebfb;hpb=e7789c1ad838194d45eeee6ac2eb6e55f5cf35a1 diff --git a/_source/plugins/enterkey/plugin.js b/_source/plugins/enterkey/plugin.js index cce1208..10b7e62 100644 --- a/_source/plugins/enterkey/plugin.js +++ b/_source/plugins/enterkey/plugin.js @@ -32,7 +32,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license var path = new CKEDITOR.dom.elementPath( range.startContainer ), block = path.block; - if ( block.is( 'li' ) || block.getParent().is( 'li' ) ) + if ( block && ( block.is( 'li' ) || block.getParent().is( 'li' ) ) ) { editor.execCommand( 'outdent' ); return; @@ -100,8 +100,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license // Do not enter this block if it's a header tag, or we are in // a Shift+Enter (#77). Create a new block element instead // (later in the code). - if ( previousBlock.is( 'li' ) || - !( forceMode || headerTagRegex.test( previousBlock.getName() ) ) ) + if ( previousBlock.is( 'li' ) || !headerTagRegex.test( previousBlock.getName() ) ) { // Otherwise, duplicate the previous block. newBlock = previousBlock.clone(); @@ -112,6 +111,9 @@ For licensing, see LICENSE.html or http://ckeditor.com/license if ( !newBlock ) newBlock = doc.createElement( blockTag ); + // Force the enter block unless we're talking of a list item. + else if ( forceMode && !newBlock.is( 'li' ) ) + newBlock.renameNode( blockTag ); // Recreate the inline elements tree, which was available // before hitting enter, so the same styles will be available in @@ -291,9 +293,21 @@ For licensing, see LICENSE.html or http://ckeditor.com/license function shiftEnter( editor ) { - // On SHIFT+ENTER we want to enforce the mode to be respected, instead + // Only effective within document. + if ( editor.mode != 'wysiwyg' ) + return false; + + // On SHIFT+ENTER: + // 1. We want to enforce the mode to be respected, instead // of cloning the current block. (#77) - return enter( editor, editor.config.shiftEnterMode, true ); + // 2. Always perform a block break when inside
 (#5402).
+		if ( editor.getSelection().getStartElement().hasAscendant( 'pre', true ) )
+		{
+			setTimeout( function() { enterBlock( editor, editor.config.enterMode, null, true ); }, 0 );
+			return true;
+		}
+		else
+			return enter( editor, editor.config.shiftEnterMode, true );
 	}
 
 	function enter( editor, mode, forceMode )