JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
vanilla ckeditor-3.2.2
[ckeditor.git] / _source / plugins / enterkey / plugin.js
index cce1208..10b7e62 100644 (file)
@@ -32,7 +32,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                                var path = new CKEDITOR.dom.elementPath( range.startContainer ),\r
                                                block = path.block;\r
 \r
-                               if ( block.is( 'li' ) || block.getParent().is( 'li' ) )\r
+                               if ( block && ( block.is( 'li' ) || block.getParent().is( 'li' ) ) )\r
                                {\r
                                        editor.execCommand( 'outdent' );\r
                                        return;\r
@@ -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\r
                                        // a Shift+Enter (#77). Create a new block element instead\r
                                        // (later in the code).\r
-                                       if ( previousBlock.is( 'li' ) ||\r
-                                                !( forceMode || headerTagRegex.test( previousBlock.getName() ) ) )\r
+                                       if ( previousBlock.is( 'li' ) || !headerTagRegex.test( previousBlock.getName() ) )\r
                                        {\r
                                                // Otherwise, duplicate the previous block.\r
                                                newBlock = previousBlock.clone();\r
@@ -112,6 +111,9 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
 \r
                                if ( !newBlock )\r
                                        newBlock = doc.createElement( blockTag );\r
+                               // Force the enter block unless we're talking of a list item.\r
+                               else if ( forceMode && !newBlock.is( 'li' ) )\r
+                                       newBlock.renameNode( blockTag );\r
 \r
                                // Recreate the inline elements tree, which was available\r
                                // before hitting enter, so the same styles will be available in\r
@@ -291,9 +293,21 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
 \r
        function shiftEnter( editor )\r
        {\r
-               // On SHIFT+ENTER we want to enforce the mode to be respected, instead\r
+               // Only effective within document.\r
+               if ( editor.mode != 'wysiwyg' )\r
+                       return false;\r
+\r
+               // On SHIFT+ENTER:\r
+               // 1. We want to enforce the mode to be respected, instead\r
                // of cloning the current block. (#77)\r
-               return enter( editor, editor.config.shiftEnterMode, true );\r
+               // 2. Always perform a block break when inside <pre> (#5402).\r
+               if ( editor.getSelection().getStartElement().hasAscendant( 'pre', true ) )\r
+               {\r
+                       setTimeout( function() { enterBlock( editor, editor.config.enterMode, null, true ); }, 0 );\r
+                       return true;\r
+               }\r
+               else\r
+                       return enter( editor, editor.config.shiftEnterMode, true );\r
        }\r
 \r
        function enter( editor, mode, forceMode )\r