JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
vanilla ckeditor-3.3.2
[ckeditor.git] / _source / plugins / list / plugin.js
index 0a55231..4c728fa 100644 (file)
@@ -218,7 +218,13 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                        CKEDITOR.dom.element.setMarker( database, itemNode, 'list_item_processed', true );\r
                }\r
 \r
-               var fakeParent = groupObj.root.getDocument().createElement( this.type );\r
+               var root = groupObj.root,\r
+                       fakeParent = root.getDocument().createElement( this.type );\r
+               // Copy all attributes, except from 'start' and 'type'.\r
+               root.copyAttributes( fakeParent, { start : 1, type : 1 } );\r
+               // The list-style-type property should be ignored.\r
+               fakeParent.removeStyle( 'list-style-type' );\r
+\r
                for ( i = 0 ; i < selectedListItems.length ; i++ )\r
                {\r
                        var listIndex = selectedListItems[i].getCustomData( 'listarray_index' );\r
@@ -234,6 +240,8 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                newList.listNode.replace( groupObj.root );\r
        }\r
 \r
+       var headerTagRegex = /^h[1-6]$/;\r
+\r
        function createList( editor, groupObj, listsCreated )\r
        {\r
                var contents = groupObj.contents,\r
@@ -285,8 +293,17 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                {\r
                        var contentBlock = listContents.shift(),\r
                                listItem = doc.createElement( 'li' );\r
-                       contentBlock.moveChildren( listItem );\r
-                       contentBlock.remove();\r
+\r
+                       // Preserve heading structure when converting to list item. (#5271)\r
+                       if ( headerTagRegex.test( contentBlock.getName() ) )\r
+                               contentBlock.appendTo( listItem );\r
+                       else\r
+                       {\r
+                               contentBlock.copyAttributes( listItem );\r
+                               contentBlock.moveChildren( listItem );\r
+                               contentBlock.remove();\r
+                       }\r
+\r
                        listItem.appendTo( listNode );\r
 \r
                        // Append a bogus BR to force the LI to render at full height\r
@@ -427,17 +444,6 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                        while ( ranges.length > 0 )\r
                        {\r
                                range = ranges.shift();\r
-\r
-                               var boundaryNodes = range.getBoundaryNodes(),\r
-                                       startNode = boundaryNodes.startNode,\r
-                                       endNode = boundaryNodes.endNode;\r
-\r
-                               if ( startNode.type == CKEDITOR.NODE_ELEMENT && startNode.getName() == 'td' )\r
-                                       range.setStartAt( boundaryNodes.startNode, CKEDITOR.POSITION_AFTER_START );\r
-\r
-                               if ( endNode.type == CKEDITOR.NODE_ELEMENT && endNode.getName() == 'td' )\r
-                                       range.setEndAt( boundaryNodes.endNode, CKEDITOR.POSITION_BEFORE_END );\r
-\r
                                var iterator = range.createIterator(),\r
                                        block;\r
 \r