bookmarks = CKEDITOR.dom.walker.bookmark(),\r
nonEmpty = function( node ){ return !( whitespaces( node ) || bookmarks( node ) ); };\r
\r
+ function cleanUpDirection( element )\r
+ {\r
+ var dir, parent, parentDir;\r
+ if ( ( dir = element.getDirection() ) )\r
+ {\r
+ parent = element.getParent();\r
+ while ( parent && !( parentDir = parent.getDirection() ) )\r
+ parent = parent.getParent();\r
+\r
+ if ( dir == parentDir )\r
+ element.removeAttribute( 'dir' );\r
+ }\r
+ }\r
+\r
CKEDITOR.plugins.list = {\r
/*\r
* Convert a DOM list tree into a data structure that is easier to\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
{\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
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
+ var currentNode = retval.getFirst(),\r
+ listRoot = listArray[ 0 ].parent;\r
+\r
while ( currentNode )\r
{\r
if ( currentNode.type == CKEDITOR.NODE_ELEMENT )\r
+ {\r
+ // Clear marker attributes for the new list tree made of cloned nodes, if any.\r
CKEDITOR.dom.element.clearMarkers( database, currentNode );\r
+\r
+ // Clear redundant direction attribute specified on list items.\r
+ if ( currentNode.getName() in CKEDITOR.dtd.$listItem )\r
+ cleanUpDirection( currentNode );\r
+ }\r
+\r
currentNode = currentNode.getNextSourceNode();\r
}\r
}\r
this.type = type;\r
}\r
\r
+ // Move direction attribute from root to list items.\r
+ function dirToListItems( list )\r
+ {\r
+ var dir = list.getDirection();\r
+ if ( dir )\r
+ {\r
+ for ( var i = 0, children = list.getChildren(), child; child = children.getItem( i ), i < children.count(); i++ )\r
+ {\r
+ if ( child.type == CKEDITOR.NODE_ELEMENT && child.is( 'li' ) && !child.getDirection() )\r
+ child.setAttribute( 'dir', dir );\r
+ }\r
+\r
+ list.removeAttribute( 'dir' );\r
+ }\r
+ }\r
+\r
listCommand.prototype = {\r
exec : function( editor )\r
{\r
if ( sibling && sibling.getName &&\r
sibling.getName() == listCommand.type )\r
{\r
+\r
+ // In case to be merged lists have difference directions. (#7448)\r
+ if ( sibling.getDirection( 1 ) != listNode.getDirection( 1 ) )\r
+ dirToListItems( listNode.getDirection() ? listNode : sibling );\r
+\r
sibling.remove();\r
// Move children order by merge direction.(#3820)\r
sibling.moveChildren( listNode, rtl );\r