Layout pour le dossier de skins cmf.
[ckeditor.git] / _source / plugins / list / plugin.js
diff --git a/_source/plugins/list/plugin.js b/_source/plugins/list/plugin.js
deleted file mode 100644 (file)
index bc28e51..0000000
+++ /dev/null
@@ -1,734 +0,0 @@
-/*\r
-Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved.\r
-For licensing, see LICENSE.html or http://ckeditor.com/license\r
-*/\r
-\r
-/**\r
- * @file Insert and remove numbered and bulleted lists.\r
- */\r
-\r
-(function()\r
-{\r
-       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
-                * manipulate. This operation should be non-intrusive in the sense that it\r
-                * does not change the DOM tree, with the exception that it may add some\r
-                * markers to the list item nodes when database is specified.\r
-                */\r
-               listToArray : function( listNode, database, baseArray, baseIndentLevel, grandparentNode )\r
-               {\r
-                       if ( !listNodeNames[ listNode.getName() ] )\r
-                               return [];\r
-\r
-                       if ( !baseIndentLevel )\r
-                               baseIndentLevel = 0;\r
-                       if ( !baseArray )\r
-                               baseArray = [];\r
-\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
-\r
-                               // Fixing malformed nested lists by moving it into a previous list item. (#6236)\r
-                               if( listItem.type == CKEDITOR.NODE_ELEMENT && listItem.getName() in CKEDITOR.dtd.$list )\r
-                                       CKEDITOR.plugins.list.listToArray( listItem, database, baseArray, baseIndentLevel + 1 );\r
-\r
-                               // It may be a text node or some funny stuff.\r
-                               if ( listItem.$.nodeName.toLowerCase() != 'li' )\r
-                                       continue;\r
-\r
-                               var itemObj = { 'parent' : listNode, indent : baseIndentLevel, element : listItem, contents : [] };\r
-                               if ( !grandparentNode )\r
-                               {\r
-                                       itemObj.grandparent = listNode.getParent();\r
-                                       if ( itemObj.grandparent && itemObj.grandparent.$.nodeName.toLowerCase() == 'li' )\r
-                                               itemObj.grandparent = itemObj.grandparent.getParent();\r
-                               }\r
-                               else\r
-                                       itemObj.grandparent = grandparentNode;\r
-\r
-                               if ( database )\r
-                                       CKEDITOR.dom.element.setMarker( database, listItem, 'listarray_index', baseArray.length );\r
-                               baseArray.push( itemObj );\r
-\r
-                               for ( var j = 0, itemChildCount = listItem.getChildCount(), child; j < itemChildCount ; j++ )\r
-                               {\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
-                                               CKEDITOR.plugins.list.listToArray( child, database, baseArray, baseIndentLevel + 1, itemObj.grandparent );\r
-                                       else\r
-                                               itemObj.contents.push( child );\r
-                               }\r
-                       }\r
-                       return baseArray;\r
-               },\r
-\r
-               // Convert our internal representation of a list back to a DOM forest.\r
-               arrayToList : function( listArray, database, baseIndex, paragraphMode, dir )\r
-               {\r
-                       if ( !baseIndex )\r
-                               baseIndex = 0;\r
-                       if ( !listArray || listArray.length < baseIndex + 1 )\r
-                               return null;\r
-                       var doc = listArray[ baseIndex ].parent.getDocument(),\r
-                               retval = new CKEDITOR.dom.documentFragment( doc ),\r
-                               rootNode = null,\r
-                               currentIndex = baseIndex,\r
-                               indentLevel = Math.max( listArray[ baseIndex ].indent, 0 ),\r
-                               currentListItem = null,\r
-                               orgDir,\r
-                               paragraphName = ( paragraphMode == CKEDITOR.ENTER_P ? 'p' : 'div' );\r
-                       while ( 1 )\r
-                       {\r
-                               var item = listArray[ currentIndex ];\r
-\r
-                               orgDir = item.element.getDirection( 1 );\r
-\r
-                               if ( item.indent == indentLevel )\r
-                               {\r
-                                       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
-\r
-                                       if ( orgDir != rootNode.getDirection( 1 ) )\r
-                                               currentListItem.setAttribute( 'dir', orgDir );\r
-                                       else\r
-                                               currentListItem.removeAttribute( 'dir' );\r
-\r
-                                       for ( var i = 0 ; i < item.contents.length ; i++ )\r
-                                               currentListItem.append( item.contents[i].clone( 1, 1 ) );\r
-                                       currentIndex++;\r
-                               }\r
-                               else if ( item.indent == Math.max( indentLevel, 0 ) + 1 )\r
-                               {\r
-                                       // Maintain original direction (#6861).\r
-                                       var currDir = listArray[ currentIndex - 1 ].element.getDirection( 1 ),\r
-                                               listData = CKEDITOR.plugins.list.arrayToList( listArray, null, currentIndex, paragraphMode,\r
-                                               currDir != orgDir ? orgDir: null );\r
-\r
-                                       // If the next block is an <li> with another list tree as the first\r
-                                       // child, we'll need to append a filler (<br>/NBSP) or the list item\r
-                                       // wouldn't be editable. (#6724)\r
-                                       if ( !currentListItem.getChildCount() && CKEDITOR.env.ie && !( doc.$.documentMode > 7 ))\r
-                                               currentListItem.append( doc.createText( '\xa0' ) );\r
-                                       currentListItem.append( listData.listNode );\r
-                                       currentIndex = listData.nextIndex;\r
-                               }\r
-                               else if ( item.indent == -1 && !baseIndex && item.grandparent )\r
-                               {\r
-                                       if ( listNodeNames[ item.grandparent.getName() ] )\r
-                                               currentListItem = item.element.clone( false, true );\r
-                                       else\r
-                                       {\r
-                                               // Create completely new blocks here.\r
-                                               if ( dir || item.element.hasAttributes() || paragraphMode != CKEDITOR.ENTER_BR )\r
-                                               {\r
-                                                       currentListItem = doc.createElement( paragraphName );\r
-                                                       item.element.copyAttributes( currentListItem, { type:1, value:1 } );\r
-\r
-                                                       // There might be a case where there are no attributes in the element after all\r
-                                                       // (i.e. when "type" or "value" are the only attributes set). In this case, if enterMode = BR,\r
-                                                       // the current item should be a fragment.\r
-                                                       if ( !dir && paragraphMode == CKEDITOR.ENTER_BR && !currentListItem.hasAttributes() )\r
-                                                               currentListItem = new CKEDITOR.dom.documentFragment( doc );\r
-                                               }\r
-                                               else\r
-                                                       currentListItem = new CKEDITOR.dom.documentFragment( doc );\r
-                                       }\r
-\r
-                                       if ( currentListItem.type == CKEDITOR.NODE_ELEMENT )\r
-                                       {\r
-                                               if ( item.grandparent.getDirection( 1 ) != orgDir )\r
-                                                       currentListItem.setAttribute( 'dir', orgDir );\r
-                                               else\r
-                                                       currentListItem.removeAttribute( 'dir' );\r
-                                       }\r
-\r
-                                       for ( i = 0 ; i < item.contents.length ; i++ )\r
-                                               currentListItem.append( item.contents[i].clone( 1, 1 ) );\r
-\r
-                                       if ( currentListItem.type == CKEDITOR.NODE_DOCUMENT_FRAGMENT\r
-                                                && currentIndex != listArray.length - 1 )\r
-                                       {\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
-                                                       currentListItem.getName() == paragraphName &&\r
-                                                       currentListItem.$.firstChild )\r
-                                       {\r
-                                               currentListItem.trim();\r
-                                               var firstChild = currentListItem.getFirst();\r
-                                               if ( firstChild.type == CKEDITOR.NODE_ELEMENT && firstChild.isBlockBoundary() )\r
-                                               {\r
-                                                       var tmp = new CKEDITOR.dom.documentFragment( doc );\r
-                                                       currentListItem.moveChildren( tmp );\r
-                                                       currentListItem = tmp;\r
-                                               }\r
-                                       }\r
-\r
-                                       var currentListItemName = currentListItem.$.nodeName.toLowerCase();\r
-                                       if ( !CKEDITOR.env.ie && ( currentListItemName == 'div' || currentListItemName == 'p' ) )\r
-                                               currentListItem.appendBogus();\r
-                                       retval.append( currentListItem );\r
-                                       rootNode = null;\r
-                                       currentIndex++;\r
-                               }\r
-                               else\r
-                                       return null;\r
-\r
-                               if ( listArray.length <= currentIndex || Math.max( listArray[ currentIndex ].indent, 0 ) < indentLevel )\r
-                                       break;\r
-                       }\r
-\r
-                       // Clear marker attributes for the new list tree made of cloned nodes, if any.\r
-                       if ( database )\r
-                       {\r
-                               var currentNode = retval.getFirst();\r
-                               while ( currentNode )\r
-                               {\r
-                                       if ( currentNode.type == CKEDITOR.NODE_ELEMENT )\r
-                                               CKEDITOR.dom.element.clearMarkers( database, currentNode );\r
-                                       currentNode = currentNode.getNextSourceNode();\r
-                               }\r
-                       }\r
-\r
-                       return { listNode : retval, nextIndex : currentIndex };\r
-               }\r
-       };\r
-\r
-       function onSelectionChange( evt )\r
-       {\r
-               if ( evt.editor.readOnly )\r
-                       return null;\r
-\r
-               var path = evt.data.path,\r
-                       blockLimit = path.blockLimit,\r
-                       elements = path.elements,\r
-                       element,\r
-                       i;\r
-\r
-               // Grouping should only happen under blockLimit.(#3940).\r
-               for ( i = 0 ; i < elements.length && ( element = elements[ i ] )\r
-                         && !element.equals( blockLimit ); i++ )\r
-               {\r
-                       if ( listNodeNames[ elements[ i ].getName() ] )\r
-                               return this.setState( this.type == elements[ i ].getName() ? CKEDITOR.TRISTATE_ON : CKEDITOR.TRISTATE_OFF );\r
-               }\r
-\r
-               return this.setState( CKEDITOR.TRISTATE_OFF );\r
-       }\r
-\r
-       function changeListType( editor, groupObj, database, listsCreated )\r
-       {\r
-               // This case is easy...\r
-               // 1. Convert the whole list into a one-dimensional array.\r
-               // 2. Change the list type by modifying the array.\r
-               // 3. Recreate the whole list by converting the array to a list.\r
-               // 4. Replace the original list with the recreated list.\r
-               var listArray = CKEDITOR.plugins.list.listToArray( groupObj.root, database ),\r
-                       selectedListItems = [];\r
-\r
-               for ( var i = 0 ; i < groupObj.contents.length ; i++ )\r
-               {\r
-                       var itemNode = groupObj.contents[i];\r
-                       itemNode = itemNode.getAscendant( 'li', true );\r
-                       if ( !itemNode || itemNode.getCustomData( 'list_item_processed' ) )\r
-                               continue;\r
-                       selectedListItems.push( itemNode );\r
-                       CKEDITOR.dom.element.setMarker( database, itemNode, 'list_item_processed', true );\r
-               }\r
-\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
-                       listArray[listIndex].parent = fakeParent;\r
-               }\r
-               var newList = CKEDITOR.plugins.list.arrayToList( listArray, database, null, editor.config.enterMode );\r
-               var child, length = newList.listNode.getChildCount();\r
-               for ( i = 0 ; i < length && ( child = newList.listNode.getChild( i ) ) ; i++ )\r
-               {\r
-                       if ( child.getName() == this.type )\r
-                               listsCreated.push( child );\r
-               }\r
-               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
-                       doc = groupObj.root.getDocument(),\r
-                       listContents = [];\r
-\r
-               // It is possible to have the contents returned by DomRangeIterator to be the same as the root.\r
-               // e.g. when we're running into table cells.\r
-               // In such a case, enclose the childNodes of contents[0] into a <div>.\r
-               if ( contents.length == 1 && contents[0].equals( groupObj.root ) )\r
-               {\r
-                       var divBlock = doc.createElement( 'div' );\r
-                       contents[0].moveChildren && contents[0].moveChildren( divBlock );\r
-                       contents[0].append( divBlock );\r
-                       contents[0] = divBlock;\r
-               }\r
-\r
-               // Calculate the common parent node of all content blocks.\r
-               var commonParent = groupObj.contents[0].getParent();\r
-               for ( var i = 0 ; i < contents.length ; i++ )\r
-                       commonParent = commonParent.getCommonAncestor( contents[i].getParent() );\r
-\r
-               var useComputedState = editor.config.useComputedState,\r
-                       listDir, explicitDirection;\r
-\r
-               useComputedState = useComputedState === undefined || useComputedState;\r
-\r
-               // We want to insert things that are in the same tree level only, so calculate the contents again\r
-               // by expanding the selected blocks to the same tree level.\r
-               for ( i = 0 ; i < contents.length ; i++ )\r
-               {\r
-                       var contentNode = contents[i],\r
-                               parentNode;\r
-                       while ( ( parentNode = contentNode.getParent() ) )\r
-                       {\r
-                               if ( parentNode.equals( commonParent ) )\r
-                               {\r
-                                       listContents.push( contentNode );\r
-\r
-                                       // Determine the lists's direction.\r
-                                       if ( !explicitDirection && contentNode.getDirection() )\r
-                                               explicitDirection = 1;\r
-\r
-                                       var itemDir = contentNode.getDirection( useComputedState );\r
-\r
-                                       if ( listDir !== null )\r
-                                       {\r
-                                               // If at least one LI have a different direction than current listDir, we can't have listDir.\r
-                                               if ( listDir && listDir != itemDir )\r
-                                                       listDir = null;\r
-                                               else\r
-                                                       listDir = itemDir;\r
-                                       }\r
-\r
-                                       break;\r
-                               }\r
-                               contentNode = parentNode;\r
-                       }\r
-               }\r
-\r
-               if ( listContents.length < 1 )\r
-                       return;\r
-\r
-               // Insert the list to the DOM tree.\r
-               var insertAnchor = listContents[ listContents.length - 1 ].getNext(),\r
-                       listNode = doc.createElement( this.type );\r
-\r
-               listsCreated.push( listNode );\r
-\r
-               var contentBlock, listItem;\r
-\r
-               while ( listContents.length )\r
-               {\r
-                       contentBlock = listContents.shift();\r
-                       listItem = doc.createElement( 'li' );\r
-\r
-                       // Preserve preformat block and heading structure when converting to list item. (#5335) (#5271)\r
-                       if ( contentBlock.is( 'pre' ) || headerTagRegex.test( contentBlock.getName() ) )\r
-                               contentBlock.appendTo( listItem );\r
-                       else\r
-                       {\r
-                               contentBlock.copyAttributes( listItem );\r
-                               // Remove direction attribute after it was merged into list root. (#7657)\r
-                               if ( listDir && contentBlock.getDirection() )\r
-                               {\r
-                                       listItem.removeStyle( 'direction' );\r
-                                       listItem.removeAttribute( 'dir' );\r
-                               }\r
-                               contentBlock.moveChildren( listItem );\r
-                               contentBlock.remove();\r
-                       }\r
-\r
-                       listItem.appendTo( listNode );\r
-               }\r
-\r
-               // Apply list root dir only if it has been explicitly declared.\r
-               if ( listDir && explicitDirection )\r
-                       listNode.setAttribute( 'dir', listDir );\r
-\r
-               if ( insertAnchor )\r
-                       listNode.insertBefore( insertAnchor );\r
-               else\r
-                       listNode.appendTo( commonParent );\r
-       }\r
-\r
-       function removeList( editor, groupObj, database )\r
-       {\r
-               // This is very much like the change list type operation.\r
-               // Except that we're changing the selected items' indent to -1 in the list array.\r
-               var listArray = CKEDITOR.plugins.list.listToArray( groupObj.root, database ),\r
-                       selectedListItems = [];\r
-\r
-               for ( var i = 0 ; i < groupObj.contents.length ; i++ )\r
-               {\r
-                       var itemNode = groupObj.contents[i];\r
-                       itemNode = itemNode.getAscendant( 'li', true );\r
-                       if ( !itemNode || itemNode.getCustomData( 'list_item_processed' ) )\r
-                               continue;\r
-                       selectedListItems.push( itemNode );\r
-                       CKEDITOR.dom.element.setMarker( database, itemNode, 'list_item_processed', true );\r
-               }\r
-\r
-               var lastListIndex = null;\r
-               for ( i = 0 ; i < selectedListItems.length ; i++ )\r
-               {\r
-                       var listIndex = selectedListItems[i].getCustomData( 'listarray_index' );\r
-                       listArray[listIndex].indent = -1;\r
-                       lastListIndex = listIndex;\r
-               }\r
-\r
-               // After cutting parts of the list out with indent=-1, we still have to maintain the array list\r
-               // model's nextItem.indent <= currentItem.indent + 1 invariant. Otherwise the array model of the\r
-               // list cannot be converted back to a real DOM list.\r
-               for ( i = lastListIndex + 1 ; i < listArray.length ; i++ )\r
-               {\r
-                       if ( listArray[i].indent > listArray[i-1].indent + 1 )\r
-                       {\r
-                               var indentOffset = listArray[i-1].indent + 1 - listArray[i].indent;\r
-                               var oldIndent = listArray[i].indent;\r
-                               while ( listArray[i] && listArray[i].indent >= oldIndent )\r
-                               {\r
-                                       listArray[i].indent += indentOffset;\r
-                                       i++;\r
-                               }\r
-                               i--;\r
-                       }\r
-               }\r
-\r
-               var newList = CKEDITOR.plugins.list.arrayToList( listArray, database, null, editor.config.enterMode,\r
-                       groupObj.root.getAttribute( 'dir' ) );\r
-\r
-               // Compensate <br> before/after the list node if the surrounds are non-blocks.(#3836)\r
-               var docFragment = newList.listNode, boundaryNode, siblingNode;\r
-               function compensateBrs( isStart )\r
-               {\r
-                       if ( ( boundaryNode = docFragment[ isStart ? 'getFirst' : 'getLast' ]() )\r
-                                && !( boundaryNode.is && boundaryNode.isBlockBoundary() )\r
-                                && ( siblingNode = groupObj.root[ isStart ? 'getPrevious' : 'getNext' ]\r
-                                     ( CKEDITOR.dom.walker.whitespaces( true ) ) )\r
-                                && !( siblingNode.is && siblingNode.isBlockBoundary( { br : 1 } ) ) )\r
-                               editor.document.createElement( 'br' )[ isStart ? 'insertBefore' : 'insertAfter' ]( boundaryNode );\r
-               }\r
-               compensateBrs( true );\r
-               compensateBrs();\r
-\r
-               docFragment.replace( groupObj.root );\r
-       }\r
-\r
-       function listCommand( name, type )\r
-       {\r
-               this.name = name;\r
-               this.type = type;\r
-       }\r
-\r
-       listCommand.prototype = {\r
-               exec : function( editor )\r
-               {\r
-                       var doc = editor.document,\r
-                               config = editor.config,\r
-                               selection = editor.getSelection(),\r
-                               ranges = selection && selection.getRanges( true );\r
-\r
-                       // There should be at least one selected range.\r
-                       if ( !ranges || ranges.length < 1 )\r
-                               return;\r
-\r
-                       // Midas lists rule #1 says we can create a list even in an empty document.\r
-                       // But DOM iterator wouldn't run if the document is really empty.\r
-                       // So create a paragraph if the document is empty and we're going to create a list.\r
-                       if ( this.state == CKEDITOR.TRISTATE_OFF )\r
-                       {\r
-                               var body = doc.getBody();\r
-                               if ( !body.getFirst( nonEmpty ) )\r
-                               {\r
-                                       config.enterMode == CKEDITOR.ENTER_BR ?\r
-                                               body.appendBogus() :\r
-                                               ranges[ 0 ].fixBlock( 1, config.enterMode == CKEDITOR.ENTER_P ? 'p' : 'div' );\r
-\r
-                                       selection.selectRanges( ranges );\r
-                               }\r
-                               // Maybe a single range there enclosing the whole list,\r
-                               // turn on the list state manually(#4129).\r
-                               else\r
-                               {\r
-                                       var range = ranges.length == 1 && ranges[ 0 ],\r
-                                               enclosedNode = range && range.getEnclosedNode();\r
-                                       if ( enclosedNode && enclosedNode.is\r
-                                               && this.type == enclosedNode.getName() )\r
-                                                       this.setState( CKEDITOR.TRISTATE_ON );\r
-                               }\r
-                       }\r
-\r
-                       var bookmarks = selection.createBookmarks( true );\r
-\r
-                       // Group the blocks up because there are many cases where multiple lists have to be created,\r
-                       // or multiple lists have to be cancelled.\r
-                       var listGroups = [],\r
-                               database = {},\r
-                               rangeIterator = ranges.createIterator(),\r
-                               index = 0;\r
-\r
-                       while ( ( range = rangeIterator.getNextRange() ) && ++index )\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
-                               iterator.forceBrBreak = ( this.state == CKEDITOR.TRISTATE_OFF );\r
-\r
-                               while ( ( block = iterator.getNextParagraph() ) )\r
-                               {\r
-                                       // Avoid duplicate blocks get processed across ranges.\r
-                                       if( block.getCustomData( 'list_block' ) )\r
-                                               continue;\r
-                                       else\r
-                                               CKEDITOR.dom.element.setMarker( database, block, 'list_block', 1 );\r
-\r
-                                       var path = new CKEDITOR.dom.elementPath( block ),\r
-                                               pathElements = path.elements,\r
-                                               pathElementsCount = pathElements.length,\r
-                                               listNode = null,\r
-                                               processedFlag = 0,\r
-                                               blockLimit = path.blockLimit,\r
-                                               element;\r
-\r
-                                       // First, try to group by a list ancestor.\r
-                                       for ( var i = pathElementsCount - 1; i >= 0 && ( element = pathElements[ i ] ); i-- )\r
-                                       {\r
-                                               if ( listNodeNames[ element.getName() ]\r
-                                                        && blockLimit.contains( element ) )     // Don't leak outside block limit (#3940).\r
-                                               {\r
-                                                       // If we've encountered a list inside a block limit\r
-                                                       // The last group object of the block limit element should\r
-                                                       // no longer be valid. Since paragraphs after the list\r
-                                                       // should belong to a different group of paragraphs before\r
-                                                       // the list. (Bug #1309)\r
-                                                       blockLimit.removeCustomData( 'list_group_object_' + index );\r
-\r
-                                                       var groupObj = element.getCustomData( 'list_group_object' );\r
-                                                       if ( groupObj )\r
-                                                               groupObj.contents.push( block );\r
-                                                       else\r
-                                                       {\r
-                                                               groupObj = { root : element, contents : [ block ] };\r
-                                                               listGroups.push( groupObj );\r
-                                                               CKEDITOR.dom.element.setMarker( database, element, 'list_group_object', groupObj );\r
-                                                       }\r
-                                                       processedFlag = 1;\r
-                                                       break;\r
-                                               }\r
-                                       }\r
-\r
-                                       if ( processedFlag )\r
-                                               continue;\r
-\r
-                                       // No list ancestor? Group by block limit, but don't mix contents from different ranges.\r
-                                       var root = blockLimit;\r
-                                       if ( root.getCustomData( 'list_group_object_' + index ) )\r
-                                               root.getCustomData( 'list_group_object_' + index ).contents.push( block );\r
-                                       else\r
-                                       {\r
-                                               groupObj = { root : root, contents : [ block ] };\r
-                                               CKEDITOR.dom.element.setMarker( database, root, 'list_group_object_' + index, groupObj );\r
-                                               listGroups.push( groupObj );\r
-                                       }\r
-                               }\r
-                       }\r
-\r
-                       // Now we have two kinds of list groups, groups rooted at a list, and groups rooted at a block limit element.\r
-                       // We either have to build lists or remove lists, for removing a list does not makes sense when we are looking\r
-                       // at the group that's not rooted at lists. So we have three cases to handle.\r
-                       var listsCreated = [];\r
-                       while ( listGroups.length > 0 )\r
-                       {\r
-                               groupObj = listGroups.shift();\r
-                               if ( this.state == CKEDITOR.TRISTATE_OFF )\r
-                               {\r
-                                       if ( listNodeNames[ groupObj.root.getName() ] )\r
-                                               changeListType.call( this, editor, groupObj, database, listsCreated );\r
-                                       else\r
-                                               createList.call( this, editor, groupObj, listsCreated );\r
-                               }\r
-                               else if ( this.state == CKEDITOR.TRISTATE_ON && listNodeNames[ groupObj.root.getName() ] )\r
-                                       removeList.call( this, editor, groupObj, database );\r
-                       }\r
-\r
-                       // For all new lists created, merge adjacent, same type lists.\r
-                       for ( i = 0 ; i < listsCreated.length ; i++ )\r
-                       {\r
-                               listNode = listsCreated[i];\r
-                               var mergeSibling, listCommand = this;\r
-                               ( mergeSibling = function( rtl ){\r
-\r
-                                       var sibling = listNode[ rtl ?\r
-                                               'getPrevious' : 'getNext' ]( CKEDITOR.dom.walker.whitespaces( true ) );\r
-                                       if ( sibling && sibling.getName &&\r
-                                                sibling.getName() == listCommand.type )\r
-                                       {\r
-                                               sibling.remove();\r
-                                               // Move children order by merge direction.(#3820)\r
-                                               sibling.moveChildren( listNode, rtl );\r
-                                       }\r
-                               } )();\r
-                               mergeSibling( 1 );\r
-                       }\r
-\r
-                       // Clean up, restore selection and update toolbar button states.\r
-                       CKEDITOR.dom.element.clearAllMarkers( database );\r
-                       selection.selectBookmarks( bookmarks );\r
-                       editor.focus();\r
-               }\r
-       };\r
-\r
-       var dtd = CKEDITOR.dtd;\r
-       var tailNbspRegex = /[\t\r\n ]*(?:&nbsp;|\xa0)$/;\r
-\r
-       function indexOfFirstChildElement( element, tagNameList )\r
-       {\r
-               var child,\r
-                       children = element.children,\r
-                       length = children.length;\r
-\r
-               for ( var i = 0 ; i < length ; i++ )\r
-               {\r
-                       child = children[ i ];\r
-                       if ( child.name && ( child.name in tagNameList ) )\r
-                               return i;\r
-               }\r
-\r
-               return length;\r
-       }\r
-\r
-       function getExtendNestedListFilter( isHtmlFilter )\r
-       {\r
-               // An element filter function that corrects nested list start in an empty\r
-               // list item for better displaying/outputting. (#3165)\r
-               return function( listItem )\r
-               {\r
-                       var children = listItem.children,\r
-                               firstNestedListIndex = indexOfFirstChildElement( listItem, dtd.$list ),\r
-                               firstNestedList = children[ firstNestedListIndex ],\r
-                               nodeBefore = firstNestedList && firstNestedList.previous,\r
-                               tailNbspmatch;\r
-\r
-                       if ( nodeBefore\r
-                               && ( nodeBefore.name && nodeBefore.name == 'br'\r
-                                       || nodeBefore.value && ( tailNbspmatch = nodeBefore.value.match( tailNbspRegex ) ) ) )\r
-                       {\r
-                               var fillerNode = nodeBefore;\r
-\r
-                               // Always use 'nbsp' as filler node if we found a nested list appear\r
-                               // in front of a list item.\r
-                               if ( !( tailNbspmatch && tailNbspmatch.index ) && fillerNode == children[ 0 ] )\r
-                                       children[ 0 ] = ( isHtmlFilter || CKEDITOR.env.ie ) ?\r
-                                                        new CKEDITOR.htmlParser.text( '\xa0' ) :\r
-                                                                        new CKEDITOR.htmlParser.element( 'br', {} );\r
-\r
-                               // Otherwise the filler is not needed anymore.\r
-                               else if ( fillerNode.name == 'br' )\r
-                                       children.splice( firstNestedListIndex - 1, 1 );\r
-                               else\r
-                                       fillerNode.value = fillerNode.value.replace( tailNbspRegex, '' );\r
-                       }\r
-\r
-               };\r
-       }\r
-\r
-       var defaultListDataFilterRules = { elements : {} };\r
-       for ( var i in dtd.$listItem )\r
-               defaultListDataFilterRules.elements[ i ] = getExtendNestedListFilter();\r
-\r
-       var defaultListHtmlFilterRules = { elements : {} };\r
-       for ( i in dtd.$listItem )\r
-               defaultListHtmlFilterRules.elements[ i ] = getExtendNestedListFilter( true );\r
-\r
-       CKEDITOR.plugins.add( 'list',\r
-       {\r
-               init : function( editor )\r
-               {\r
-                       // Register commands.\r
-                       var numberedListCommand = editor.addCommand( 'numberedlist', new listCommand( 'numberedlist', 'ol' ) ),\r
-                               bulletedListCommand = editor.addCommand( 'bulletedlist', new listCommand( 'bulletedlist', 'ul' ) );\r
-\r
-                       // Register the toolbar button.\r
-                       editor.ui.addButton( 'NumberedList',\r
-                               {\r
-                                       label : editor.lang.numberedlist,\r
-                                       command : 'numberedlist'\r
-                               } );\r
-                       editor.ui.addButton( 'BulletedList',\r
-                               {\r
-                                       label : editor.lang.bulletedlist,\r
-                                       command : 'bulletedlist'\r
-                               } );\r
-\r
-                       // Register the state changing handlers.\r
-                       editor.on( 'selectionChange', CKEDITOR.tools.bind( onSelectionChange, numberedListCommand ) );\r
-                       editor.on( 'selectionChange', CKEDITOR.tools.bind( onSelectionChange, bulletedListCommand ) );\r
-               },\r
-\r
-               afterInit : function ( editor )\r
-               {\r
-                       var dataProcessor = editor.dataProcessor;\r
-                       if ( dataProcessor )\r
-                       {\r
-                               dataProcessor.dataFilter.addRules( defaultListDataFilterRules );\r
-                               dataProcessor.htmlFilter.addRules( defaultListHtmlFilterRules );\r
-                       }\r
-               },\r
-\r
-               requires : [ 'domiterator' ]\r
-       } );\r
-})();\r