X-Git-Url: https://jasonwoof.com/gitweb/?p=ckeditor.git;a=blobdiff_plain;f=_source%2Fplugins%2Flist%2Fplugin.js;h=bc28e515c655787817facd8b77efccbc1baa6fdf;hp=be10d0d54361c6609b0330436799b95c34e653f0;hb=f0610347140239143439a511ee2bd48cb784f470;hpb=4e70ea24db840898be8cc21c950363a52a2a6aba diff --git a/_source/plugins/list/plugin.js b/_source/plugins/list/plugin.js index be10d0d..bc28e51 100644 --- a/_source/plugins/list/plugin.js +++ b/_source/plugins/list/plugin.js @@ -87,11 +87,14 @@ For licensing, see LICENSE.html or http://ckeditor.com/license currentIndex = baseIndex, indentLevel = Math.max( listArray[ baseIndex ].indent, 0 ), currentListItem = null, - itemDir, + orgDir, paragraphName = ( paragraphMode == CKEDITOR.ENTER_P ? 'p' : 'div' ); while ( 1 ) { var item = listArray[ currentIndex ]; + + orgDir = item.element.getDirection( 1 ); + if ( item.indent == indentLevel ) { if ( !rootNode || listArray[ currentIndex ].parent.getName() != rootNode.getName() ) @@ -101,6 +104,12 @@ For licensing, see LICENSE.html or http://ckeditor.com/license retval.append( rootNode ); } currentListItem = rootNode.append( item.element.clone( 0, 1 ) ); + + if ( orgDir != rootNode.getDirection( 1 ) ) + currentListItem.setAttribute( 'dir', orgDir ); + else + currentListItem.removeAttribute( 'dir' ); + for ( var i = 0 ; i < item.contents.length ; i++ ) currentListItem.append( item.contents[i].clone( 1, 1 ) ); currentIndex++; @@ -108,8 +117,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license else if ( item.indent == Math.max( indentLevel, 0 ) + 1 ) { // Maintain original direction (#6861). - var orgDir = item.element.getDirection( 1 ), - currDir = listArray[ currentIndex - 1 ].element.getDirection( 1 ), + var currDir = listArray[ currentIndex - 1 ].element.getDirection( 1 ), listData = CKEDITOR.plugins.list.arrayToList( listArray, null, currentIndex, paragraphMode, currDir != orgDir ? orgDir: null ); @@ -124,12 +132,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license else if ( item.indent == -1 && !baseIndex && item.grandparent ) { if ( listNodeNames[ item.grandparent.getName() ] ) - { currentListItem = item.element.clone( false, true ); - itemDir = item.element.getDirection( 1 ); - item.grandparent.getDirection( 1 ) != itemDir && - currentListItem.setAttribute( 'dir', itemDir ); - } else { // Create completely new blocks here. @@ -137,9 +140,6 @@ For licensing, see LICENSE.html or http://ckeditor.com/license { currentListItem = doc.createElement( paragraphName ); item.element.copyAttributes( currentListItem, { type:1, value:1 } ); - itemDir = item.element.getDirection() || dir; - itemDir && - currentListItem.setAttribute( 'dir', itemDir ); // There might be a case where there are no attributes in the element after all // (i.e. when "type" or "value" are the only attributes set). In this case, if enterMode = BR, @@ -151,6 +151,14 @@ For licensing, see LICENSE.html or http://ckeditor.com/license currentListItem = new CKEDITOR.dom.documentFragment( doc ); } + if ( currentListItem.type == CKEDITOR.NODE_ELEMENT ) + { + if ( item.grandparent.getDirection( 1 ) != orgDir ) + currentListItem.setAttribute( 'dir', orgDir ); + else + currentListItem.removeAttribute( 'dir' ); + } + for ( i = 0 ; i < item.contents.length ; i++ ) currentListItem.append( item.contents[i].clone( 1, 1 ) ); @@ -363,14 +371,13 @@ For licensing, see LICENSE.html or http://ckeditor.com/license contentBlock.appendTo( listItem ); else { - // Remove DIR attribute if it was merged into list root. + contentBlock.copyAttributes( listItem ); + // Remove direction attribute after it was merged into list root. (#7657) if ( listDir && contentBlock.getDirection() ) { - contentBlock.removeStyle( 'direction' ); - contentBlock.removeAttribute( 'dir' ); + listItem.removeStyle( 'direction' ); + listItem.removeAttribute( 'dir' ); } - - contentBlock.copyAttributes( listItem ); contentBlock.moveChildren( listItem ); contentBlock.remove(); }