JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
vanilla ckeditor-3.4.3
[ckeditor.git] / _source / plugins / list / plugin.js
index 0b61c2d..3a47c55 100644 (file)
@@ -12,6 +12,10 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
        var listNodeNames = { ol : 1, ul : 1 },\r
                emptyTextRegex = /^[\n\r\t ]*$/;\r
 \r
+       var whitespaces = CKEDITOR.dom.walker.whitespaces(),\r
+               bookmarks = CKEDITOR.dom.walker.bookmark(),\r
+               nonEmpty = function( node ){ return !( whitespaces( node ) || bookmarks( node ) ); };\r
+\r
        CKEDITOR.plugins.list = {\r
                /*\r
                 * Convert a DOM list tree into a data structure that is easier to\r
@@ -88,6 +92,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                                        if ( !rootNode || listArray[ currentIndex ].parent.getName() != rootNode.getName() )\r
                                        {\r
                                                rootNode = listArray[ currentIndex ].parent.clone( false, 1 );\r
+                                               dir && rootNode.setAttribute( 'dir', dir );\r
                                                retval.append( rootNode );\r
                                        }\r
                                        currentListItem = rootNode.append( item.element.clone( 0, 1 ) );\r
@@ -132,11 +137,19 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                                        if ( currentListItem.type == CKEDITOR.NODE_DOCUMENT_FRAGMENT\r
                                                 && currentIndex != listArray.length - 1 )\r
                                        {\r
-                                               if ( currentListItem.getLast()\r
-                                                               && currentListItem.getLast().type == CKEDITOR.NODE_ELEMENT\r
-                                                               && currentListItem.getLast().getAttribute( 'type' ) == '_moz' )\r
-                                                       currentListItem.getLast().remove();\r
-                                               currentListItem.appendBogus();\r
+                                               var last = currentListItem.getLast();\r
+                                               if ( last && last.type == CKEDITOR.NODE_ELEMENT\r
+                                                               && last.getAttribute( 'type' ) == '_moz' )\r
+                                               {\r
+                                                       last.remove();\r
+                                               }\r
+\r
+                                               if ( !( last = currentListItem.getLast( nonEmpty )\r
+                                                       && last.type == CKEDITOR.NODE_ELEMENT\r
+                                                       && last.getName() in CKEDITOR.dtd.$block ) )\r
+                                               {\r
+                                                       currentListItem.append( doc.createElement( 'br' ) );\r
+                                               }\r
                                        }\r
 \r
                                        if ( currentListItem.type == CKEDITOR.NODE_ELEMENT &&\r