X-Git-Url: https://jasonwoof.com/gitweb/?p=ckeditor.git;a=blobdiff_plain;f=_source%2Fplugins%2Flist%2Fplugin.js;h=b0676d0def8917b81fc3ac02cd979188f8cd7066;hp=856a43046b8b1da247412e7ba00c9d69b67ec091;hb=4e90e78dc97789709ee7404359a5517540c27553;hpb=8f6c203fdaa543c3bca40baea6ae4ddcdf1a77f5
diff --git a/_source/plugins/list/plugin.js b/_source/plugins/list/plugin.js
index 856a430..b0676d0 100644
--- a/_source/plugins/list/plugin.js
+++ b/_source/plugins/list/plugin.js
@@ -38,6 +38,10 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
{
var listItem = listNode.getChild( i );
+ // Fixing malformed nested lists by moving it into a previous list item. (#6236)
+ if( listItem.type == CKEDITOR.NODE_ELEMENT && listItem.getName() in CKEDITOR.dtd.$list )
+ CKEDITOR.plugins.list.listToArray( listItem, database, baseArray, baseIndentLevel + 1 );
+
// It may be a text node or some funny stuff.
if ( listItem.$.nodeName.toLowerCase() != 'li' )
continue;
@@ -83,6 +87,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
currentIndex = baseIndex,
indentLevel = Math.max( listArray[ baseIndex ].indent, 0 ),
currentListItem = null,
+ itemDir,
paragraphName = ( paragraphMode == CKEDITOR.ENTER_P ? 'p' : 'div' );
while ( 1 )
{
@@ -102,7 +107,11 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
}
else if ( item.indent == Math.max( indentLevel, 0 ) + 1 )
{
- var listData = CKEDITOR.plugins.list.arrayToList( listArray, null, currentIndex, paragraphMode );
+ // Maintain original direction (#6861).
+ var orgDir = item.element.getDirection( 1 ),
+ currDir = listArray[ currentIndex - 1 ].element.getDirection( 1 ),
+ listData = CKEDITOR.plugins.list.arrayToList( listArray, null, currentIndex, paragraphMode,
+ currDir != orgDir ? orgDir: null );
// If the next block is an
with another list tree as the first
// child, we'll need to append a filler (
/NBSP) or the list item
@@ -114,9 +123,13 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
}
else if ( item.indent == -1 && !baseIndex && item.grandparent )
{
- currentListItem;
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.
@@ -124,7 +137,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
{
currentListItem = doc.createElement( paragraphName );
item.element.copyAttributes( currentListItem, { type:1, value:1 } );
- var itemDir = item.element.getDirection() || dir;
+ itemDir = item.element.getDirection() || dir;
itemDir &&
currentListItem.setAttribute( 'dir', itemDir );
@@ -444,9 +457,8 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
listCommand.prototype = {
exec : function( editor )
{
- editor.focus();
-
var doc = editor.document,
+ config = editor.config,
selection = editor.getSelection(),
ranges = selection && selection.getRanges( true );
@@ -460,21 +472,12 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
if ( this.state == CKEDITOR.TRISTATE_OFF )
{
var body = doc.getBody();
- body.trim();
- if ( !body.getFirst() )
+ if ( !body.getFirst( nonEmpty ) )
{
- var paragraph = doc.createElement( editor.config.enterMode == CKEDITOR.ENTER_P ? 'p' :
- ( editor.config.enterMode == CKEDITOR.ENTER_DIV ? 'div' : 'br' ) );
- paragraph.appendTo( body );
- ranges = new CKEDITOR.dom.rangeList( [ new CKEDITOR.dom.range( doc ) ] );
- // IE exception on inserting anything when anchor inside
.
- if ( paragraph.is( 'br' ) )
- {
- ranges[ 0 ].setStartBefore( paragraph );
- ranges[ 0 ].setEndAfter( paragraph );
- }
- else
- ranges[ 0 ].selectNodeContents( paragraph );
+ config.enterMode == CKEDITOR.ENTER_BR ?
+ body.appendBogus() :
+ ranges[ 0 ].fixBlock( 1, config.enterMode == CKEDITOR.ENTER_P ? 'p' : 'div' );
+
selection.selectRanges( ranges );
}
// Maybe a single range there enclosing the whole list,