X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=_source%2Fplugins%2Flist%2Fplugin.js;h=4c728fa9e9fe95cbd69ff7d49526d5e2790f99ac;hb=refs%2Ftags%2Fv3.3.2;hp=87ad3cc89a7b588214dd33451a87d0325d9d198f;hpb=c6e377a02b54abc07129d72b632763c727476a15;p=ckeditor.git diff --git a/_source/plugins/list/plugin.js b/_source/plugins/list/plugin.js index 87ad3cc..4c728fa 100644 --- a/_source/plugins/list/plugin.js +++ b/_source/plugins/list/plugin.js @@ -29,7 +29,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license if ( !baseArray ) baseArray = []; - // Iterate over all list items to get their contents and look for inner lists. + // Iterate over all list items to and look for inner lists. for ( var i = 0, count = listNode.getChildCount() ; i < count ; i++ ) { var listItem = listNode.getChild( i ); @@ -37,7 +37,8 @@ For licensing, see LICENSE.html or http://ckeditor.com/license // It may be a text node or some funny stuff. if ( listItem.$.nodeName.toLowerCase() != 'li' ) continue; - var itemObj = { 'parent' : listNode, indent : baseIndentLevel, contents : [] }; + + var itemObj = { 'parent' : listNode, indent : baseIndentLevel, element : listItem, contents : [] }; if ( !grandparentNode ) { itemObj.grandparent = listNode.getParent(); @@ -51,9 +52,9 @@ For licensing, see LICENSE.html or http://ckeditor.com/license CKEDITOR.dom.element.setMarker( database, listItem, 'listarray_index', baseArray.length ); baseArray.push( itemObj ); - for ( var j = 0, itemChildCount = listItem.getChildCount() ; j < itemChildCount ; j++ ) + for ( var j = 0, itemChildCount = listItem.getChildCount(), child; j < itemChildCount ; j++ ) { - var child = listItem.getChild( j ); + child = listItem.getChild( j ); if ( child.type == CKEDITOR.NODE_ELEMENT && listNodeNames[ child.getName() ] ) // Note the recursion here, it pushes inner list items with // +1 indentation in the correct order. @@ -89,7 +90,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license rootNode = listArray[ currentIndex ].parent.clone( false, true ); retval.append( rootNode ); } - currentListItem = rootNode.append( doc.createElement( 'li' ) ); + currentListItem = rootNode.append( item.element.clone( false, true ) ); for ( var i = 0 ; i < item.contents.length ; i++ ) currentListItem.append( item.contents[i].clone( true, true ) ); currentIndex++; @@ -104,9 +105,10 @@ For licensing, see LICENSE.html or http://ckeditor.com/license { currentListItem; if ( listNodeNames[ item.grandparent.getName() ] ) - currentListItem = doc.createElement( 'li' ); + currentListItem = item.element.clone( false, true ); else { + // Create completely new blocks here, attributes are dropped. if ( paragraphMode != CKEDITOR.ENTER_BR && item.grandparent.getName() != 'td' ) currentListItem = doc.createElement( paragraphName ); else @@ -216,7 +218,13 @@ For licensing, see LICENSE.html or http://ckeditor.com/license CKEDITOR.dom.element.setMarker( database, itemNode, 'list_item_processed', true ); } - var fakeParent = groupObj.root.getDocument().createElement( this.type ); + var root = groupObj.root, + fakeParent = root.getDocument().createElement( this.type ); + // Copy all attributes, except from 'start' and 'type'. + root.copyAttributes( fakeParent, { start : 1, type : 1 } ); + // The list-style-type property should be ignored. + fakeParent.removeStyle( 'list-style-type' ); + for ( i = 0 ; i < selectedListItems.length ; i++ ) { var listIndex = selectedListItems[i].getCustomData( 'listarray_index' ); @@ -232,6 +240,8 @@ For licensing, see LICENSE.html or http://ckeditor.com/license newList.listNode.replace( groupObj.root ); } + var headerTagRegex = /^h[1-6]$/; + function createList( editor, groupObj, listsCreated ) { var contents = groupObj.contents, @@ -283,8 +293,17 @@ For licensing, see LICENSE.html or http://ckeditor.com/license { var contentBlock = listContents.shift(), listItem = doc.createElement( 'li' ); - contentBlock.moveChildren( listItem ); - contentBlock.remove(); + + // Preserve heading structure when converting to list item. (#5271) + if ( headerTagRegex.test( contentBlock.getName() ) ) + contentBlock.appendTo( listItem ); + else + { + contentBlock.copyAttributes( listItem ); + contentBlock.moveChildren( listItem ); + contentBlock.remove(); + } + listItem.appendTo( listNode ); // Append a bogus BR to force the LI to render at full height @@ -425,17 +444,6 @@ For licensing, see LICENSE.html or http://ckeditor.com/license while ( ranges.length > 0 ) { range = ranges.shift(); - - var boundaryNodes = range.getBoundaryNodes(), - startNode = boundaryNodes.startNode, - endNode = boundaryNodes.endNode; - - if ( startNode.type == CKEDITOR.NODE_ELEMENT && startNode.getName() == 'td' ) - range.setStartAt( boundaryNodes.startNode, CKEDITOR.POSITION_AFTER_START ); - - if ( endNode.type == CKEDITOR.NODE_ELEMENT && endNode.getName() == 'td' ) - range.setEndAt( boundaryNodes.endNode, CKEDITOR.POSITION_BEFORE_END ); - var iterator = range.createIterator(), block;