JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
vanilla ckeditor-3.4.3
[ckeditor.git] / _source / plugins / enterkey / plugin.js
index 5046b1d..4114516 100644 (file)
@@ -98,7 +98,8 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                        }\r
                        else\r
                        {\r
-                               var newBlock;\r
+                               var newBlock,\r
+                                       newBlockDir;\r
 \r
                                if ( previousBlock )\r
                                {\r
@@ -115,7 +116,11 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                                        newBlock = nextBlock.clone();\r
 \r
                                if ( !newBlock )\r
+                               {\r
                                        newBlock = doc.createElement( blockTag );\r
+                                       if ( previousBlock && ( newBlockDir = previousBlock.getDirection() ) )\r
+                                               newBlock.setAttribute( 'dir', newBlockDir );\r
+                               }\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
@@ -222,15 +227,28 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                        // If we are at the end of a header block.\r
                        if ( !forceMode && isEndOfBlock && headerTagRegex.test( startBlockTag ) )\r
                        {\r
-                               // Insert a <br> after the current paragraph.\r
-                               doc.createElement( 'br' ).insertAfter( startBlock );\r
+                               var newBlock,\r
+                                       newBlockDir;\r
 \r
-                               // A text node is required by Gecko only to make the cursor blink.\r
-                               if ( CKEDITOR.env.gecko )\r
-                                       doc.createText( '' ).insertAfter( startBlock );\r
+                               if ( newBlockDir = startBlock.getDirection() )\r
+                               {\r
+                                       newBlock = doc.createElement( 'div' );\r
+                                       newBlock.setAttribute( 'dir', newBlockDir );\r
+                                       newBlock.insertAfter( startBlock );\r
+                                       range.setStart( newBlock, 0 );\r
+                               }\r
+                               else\r
+                               {\r
+                                       // Insert a <br> after the current paragraph.\r
+                                       doc.createElement( 'br' ).insertAfter( startBlock );\r
 \r
-                               // IE has different behaviors regarding position.\r
-                               range.setStartAt( startBlock.getNext(), CKEDITOR.env.ie ? CKEDITOR.POSITION_BEFORE_START : CKEDITOR.POSITION_AFTER_START );\r
+                                       // A text node is required by Gecko only to make the cursor blink.\r
+                                       if ( CKEDITOR.env.gecko )\r
+                                               doc.createText( '' ).insertAfter( startBlock );\r
+\r
+                                       // IE has different behaviors regarding position.\r
+                                       range.setStartAt( startBlock.getNext(), CKEDITOR.env.ie ? CKEDITOR.POSITION_BEFORE_START : CKEDITOR.POSITION_AFTER_START );\r
+                               }\r
                        }\r
                        else\r
                        {\r