JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
vanilla ckeditor-3.5.3
[ckeditor.git] / _source / plugins / enterkey / plugin.js
index 14db3da..1a79c51 100644 (file)
@@ -75,7 +75,8 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                        else if ( previousBlock && ( node = previousBlock.getParent() ) && node.is( 'li' ) )\r
                        {\r
                                previousBlock.breakParent( node );\r
-                               range.moveToElementEditStart( previousBlock.getNext() );\r
+                               node = previousBlock.getNext();\r
+                               range.moveToElementEditStart( node );\r
                                previousBlock.move( previousBlock.getPrevious() );\r
                        }\r
 \r
@@ -110,6 +111,8 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                                        {\r
                                                // Otherwise, duplicate the previous block.\r
                                                newBlock = previousBlock.clone();\r
+                                               // Value attribute of list item should not be duplicated (#7330).\r
+                                               newBlock.is( 'li' ) && newBlock.removeAttribute( 'value' );\r
                                        }\r
                                }\r
                                else if ( nextBlock )\r
@@ -117,9 +120,15 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
 \r
                                if ( !newBlock )\r
                                {\r
-                                       newBlock = doc.createElement( blockTag );\r
-                                       if ( previousBlock && ( newBlockDir = previousBlock.getDirection() ) )\r
-                                               newBlock.setAttribute( 'dir', newBlockDir );\r
+                                       // We have already created a new list item. (#6849)\r
+                                       if ( node && node.is( 'li' ) )\r
+                                               newBlock = node;\r
+                                       else\r
+                                       {\r
+                                               newBlock = doc.createElement( blockTag );\r
+                                               if ( previousBlock && ( newBlockDir = previousBlock.getDirection() ) )\r
+                                                       newBlock.setAttribute( 'dir', newBlockDir );\r
+                                       }\r
                                }\r
                                // Force the enter block unless we're talking of a list item.\r
                                else if ( forceMode && !newBlock.is( 'li' ) )\r
@@ -150,7 +159,8 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                                if ( !CKEDITOR.env.ie )\r
                                        newBlock.appendBogus();\r
 \r
-                               range.insertNode( newBlock );\r
+                               if ( !newBlock.getParent() )\r
+                                       range.insertNode( newBlock );\r
 \r
                                // This is tricky, but to make the new block visible correctly\r
                                // we must select it.\r
@@ -265,29 +275,27 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                                range.deleteContents();\r
                                range.insertNode( lineBreak );\r
 \r
-                               // A text node is required by Gecko only to make the cursor blink.\r
-                               // We need some text inside of it, so the bogus <br> is properly\r
-                               // created.\r
-                               if ( !CKEDITOR.env.ie )\r
-                                       doc.createText( '\ufeff' ).insertAfter( lineBreak );\r
-\r
-                               // If we are at the end of a block, we must be sure the bogus node is available in that block.\r
-                               if ( isEndOfBlock && !CKEDITOR.env.ie )\r
-                                       lineBreak.getParent().appendBogus();\r
-\r
-                               // Now we can remove the text node contents, so the caret doesn't\r
-                               // stop on it.\r
-                               if ( !CKEDITOR.env.ie )\r
-                                       lineBreak.getNext().$.nodeValue = '';\r
                                // IE has different behavior regarding position.\r
                                if ( CKEDITOR.env.ie )\r
                                        range.setStartAt( lineBreak, CKEDITOR.POSITION_AFTER_END );\r
                                else\r
+                               {\r
+                                       // A text node is required by Gecko only to make the cursor blink.\r
+                                       // We need some text inside of it, so the bogus <br> is properly\r
+                                       // created.\r
+                                       doc.createText( '\ufeff' ).insertAfter( lineBreak );\r
+\r
+                                       // If we are at the end of a block, we must be sure the bogus node is available in that block.\r
+                                       if ( isEndOfBlock )\r
+                                               lineBreak.getParent().appendBogus();\r
+\r
+                                       // Now we can remove the text node contents, so the caret doesn't\r
+                                       // stop on it.\r
+                                       lineBreak.getNext().$.nodeValue = '';\r
+\r
                                        range.setStartAt( lineBreak.getNext(), CKEDITOR.POSITION_AFTER_START );\r
 \r
-                               // Scroll into view, for non IE.\r
-                               if ( !CKEDITOR.env.ie )\r
-                               {\r
+                                       // Scroll into view, for non IE.\r
                                        var dummy = null;\r
 \r
                                        // BR is not positioned in Opera and Webkit.\r
@@ -363,7 +371,6 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                return true;\r
        }\r
 \r
-\r
        function getRange( editor )\r
        {\r
                // Get the selection ranges.\r