JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
vanilla ckeditor-3.2.2
[ckeditor.git] / _source / plugins / list / plugin.js
index 0a55231..be74702 100644 (file)
@@ -234,6 +234,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 +287,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