X-Git-Url: https://jasonwoof.com/gitweb/?p=ckeditor.git;a=blobdiff_plain;f=_source%2Fplugins%2Flist%2Fplugin.js;h=3a47c55824b7970e89d8be9504abd27e52e2094c;hp=0b61c2d7f06329e23ceab83aa824db17196b26d5;hb=614511639979907ceb0da3614122a4d8eb963ad4;hpb=039a051ccf3901311661022a30afd60fc38130c9 diff --git a/_source/plugins/list/plugin.js b/_source/plugins/list/plugin.js index 0b61c2d..3a47c55 100644 --- a/_source/plugins/list/plugin.js +++ b/_source/plugins/list/plugin.js @@ -12,6 +12,10 @@ For licensing, see LICENSE.html or http://ckeditor.com/license var listNodeNames = { ol : 1, ul : 1 }, emptyTextRegex = /^[\n\r\t ]*$/; + var whitespaces = CKEDITOR.dom.walker.whitespaces(), + bookmarks = CKEDITOR.dom.walker.bookmark(), + nonEmpty = function( node ){ return !( whitespaces( node ) || bookmarks( node ) ); }; + CKEDITOR.plugins.list = { /* * Convert a DOM list tree into a data structure that is easier to @@ -88,6 +92,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license if ( !rootNode || listArray[ currentIndex ].parent.getName() != rootNode.getName() ) { rootNode = listArray[ currentIndex ].parent.clone( false, 1 ); + dir && rootNode.setAttribute( 'dir', dir ); retval.append( rootNode ); } currentListItem = rootNode.append( item.element.clone( 0, 1 ) ); @@ -132,11 +137,19 @@ For licensing, see LICENSE.html or http://ckeditor.com/license if ( currentListItem.type == CKEDITOR.NODE_DOCUMENT_FRAGMENT && currentIndex != listArray.length - 1 ) { - if ( currentListItem.getLast() - && currentListItem.getLast().type == CKEDITOR.NODE_ELEMENT - && currentListItem.getLast().getAttribute( 'type' ) == '_moz' ) - currentListItem.getLast().remove(); - currentListItem.appendBogus(); + var last = currentListItem.getLast(); + if ( last && last.type == CKEDITOR.NODE_ELEMENT + && last.getAttribute( 'type' ) == '_moz' ) + { + last.remove(); + } + + if ( !( last = currentListItem.getLast( nonEmpty ) + && last.type == CKEDITOR.NODE_ELEMENT + && last.getName() in CKEDITOR.dtd.$block ) ) + { + currentListItem.append( doc.createElement( 'br' ) ); + } } if ( currentListItem.type == CKEDITOR.NODE_ELEMENT &&