JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
vanilla ckeditor-3.2.1
[ckeditor.git] / _source / plugins / list / plugin.js
index 87ad3cc..0a55231 100644 (file)
@@ -29,7 +29,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                        if ( !baseArray )\r
                                baseArray = [];\r
 \r
-                       // Iterate over all list items to get their contents and look for inner lists.\r
+                       // Iterate over all list items to and look for inner lists.\r
                        for ( var i = 0, count = listNode.getChildCount() ; i < count ; i++ )\r
                        {\r
                                var listItem = listNode.getChild( i );\r
@@ -37,7 +37,8 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                                // It may be a text node or some funny stuff.\r
                                if ( listItem.$.nodeName.toLowerCase() != 'li' )\r
                                        continue;\r
-                               var itemObj = { 'parent' : listNode, indent : baseIndentLevel, contents : [] };\r
+\r
+                               var itemObj = { 'parent' : listNode, indent : baseIndentLevel, element : listItem, contents : [] };\r
                                if ( !grandparentNode )\r
                                {\r
                                        itemObj.grandparent = listNode.getParent();\r
@@ -51,9 +52,9 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                                        CKEDITOR.dom.element.setMarker( database, listItem, 'listarray_index', baseArray.length );\r
                                baseArray.push( itemObj );\r
 \r
-                               for ( var j = 0, itemChildCount = listItem.getChildCount() ; j < itemChildCount ; j++ )\r
+                               for ( var j = 0, itemChildCount = listItem.getChildCount(), child; j < itemChildCount ; j++ )\r
                                {\r
-                                       var child = listItem.getChild( j );\r
+                                       child = listItem.getChild( j );\r
                                        if ( child.type == CKEDITOR.NODE_ELEMENT && listNodeNames[ child.getName() ] )\r
                                                // Note the recursion here, it pushes inner list items with\r
                                                // +1 indentation in the correct order.\r
@@ -89,7 +90,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                                                rootNode = listArray[ currentIndex ].parent.clone( false, true );\r
                                                retval.append( rootNode );\r
                                        }\r
-                                       currentListItem = rootNode.append( doc.createElement( 'li' ) );\r
+                                       currentListItem = rootNode.append( item.element.clone( false, true ) );\r
                                        for ( var i = 0 ; i < item.contents.length ; i++ )\r
                                                currentListItem.append( item.contents[i].clone( true, true ) );\r
                                        currentIndex++;\r
@@ -104,9 +105,10 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                                {\r
                                        currentListItem;\r
                                        if ( listNodeNames[ item.grandparent.getName() ] )\r
-                                               currentListItem = doc.createElement( 'li' );\r
+                                               currentListItem = item.element.clone( false, true );\r
                                        else\r
                                        {\r
+                                               // Create completely new blocks here, attributes are dropped.\r
                                                if ( paragraphMode != CKEDITOR.ENTER_BR && item.grandparent.getName() != 'td' )\r
                                                        currentListItem = doc.createElement( paragraphName );\r
                                                else\r