JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
vanilla ckeditor-3.2.1
[ckeditor.git] / _source / plugins / enterkey / plugin.js
index 0127ede..cce1208 100644 (file)
@@ -26,6 +26,19 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
 \r
                        var doc = range.document;\r
 \r
+                       // Exit the list when we're inside an empty list item block. (#5376)\r
+                       if ( range.checkStartOfBlock() && range.checkEndOfBlock() )\r
+                       {\r
+                               var path = new CKEDITOR.dom.elementPath( range.startContainer ),\r
+                                               block = path.block;\r
+\r
+                               if ( block.is( 'li' ) || block.getParent().is( 'li' ) )\r
+                               {\r
+                                       editor.execCommand( 'outdent' );\r
+                                       return;\r
+                               }\r
+                       }\r
+\r
                        // Determine the block element to be used.\r
                        var blockTag = ( mode == CKEDITOR.ENTER_DIV ? 'div' : 'p' );\r
 \r
@@ -80,13 +93,6 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                        }\r
                        else\r
                        {\r
-\r
-                               if ( isStartOfBlock && isEndOfBlock && previousBlock.is( 'li' ) )\r
-                               {\r
-                                       editor.execCommand( 'outdent' );\r
-                                       return;\r
-                               }\r
-\r
                                var newBlock;\r
 \r
                                if ( previousBlock )\r
@@ -94,7 +100,8 @@ 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 ( !forceMode && !headerTagRegex.test( previousBlock.getName() ) )\r
+                                       if ( previousBlock.is( 'li' ) ||\r
+                                                !( forceMode || headerTagRegex.test( previousBlock.getName() ) ) )\r
                                        {\r
                                                // Otherwise, duplicate the previous block.\r
                                                newBlock = previousBlock.clone();\r
@@ -219,7 +226,8 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
 \r
                                isPre = ( startBlockTag == 'pre' );\r
 \r
-                               if ( isPre )\r
+                               // Gecko prefers <br> as line-break inside <pre> (#4711).\r
+                               if ( isPre && !CKEDITOR.env.gecko )\r
                                        lineBreak = doc.createText( CKEDITOR.env.ie ? '\r' : '\n' );\r
                                else\r
                                        lineBreak = doc.createElement( 'br' );\r
@@ -290,6 +298,8 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
 \r
        function enter( editor, mode, forceMode )\r
        {\r
+               forceMode = editor.config.forceEnterMode || forceMode;\r
+\r
                // Only effective within document.\r
                if ( editor.mode != 'wysiwyg' )\r
                        return false;\r