X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;ds=sidebyside;f=_source%2Fplugins%2Flist%2Fplugin.js;h=856a43046b8b1da247412e7ba00c9d69b67ec091;hb=48b1db88210b4160dce439c6e3e32e14af8c106b;hp=0b61c2d7f06329e23ceab83aa824db17196b26d5;hpb=039a051ccf3901311661022a30afd60fc38130c9;p=ckeditor.git
diff --git a/_source/plugins/list/plugin.js b/_source/plugins/list/plugin.js
index 0b61c2d..856a430 100644
--- a/_source/plugins/list/plugin.js
+++ b/_source/plugins/list/plugin.js
@@ -1,5 +1,5 @@
/*
-Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved.
+Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved.
For licensing, see LICENSE.html or http://ckeditor.com/license
*/
@@ -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 ) );
@@ -98,6 +103,12 @@ 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 );
+
+ // 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
+ // wouldn't be editable. (#6724)
+ if ( !currentListItem.getChildCount() && CKEDITOR.env.ie && !( doc.$.documentMode > 7 ))
+ currentListItem.append( doc.createText( '\xa0' ) );
currentListItem.append( listData.listNode );
currentIndex = listData.nextIndex;
}
@@ -109,12 +120,13 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
else
{
// Create completely new blocks here.
- if ( dir || item.element.hasAttributes() ||
- ( paragraphMode != CKEDITOR.ENTER_BR && item.grandparent.getName() != 'td' ) )
+ if ( dir || item.element.hasAttributes() || paragraphMode != CKEDITOR.ENTER_BR )
{
currentListItem = doc.createElement( paragraphName );
item.element.copyAttributes( currentListItem, { type:1, value:1 } );
- dir && currentListItem.setAttribute( 'dir', dir );
+ var 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,
@@ -132,11 +144,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 &&
@@ -183,30 +203,23 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
}
};
- function setState( editor, state )
- {
- editor.getCommand( this.name ).setState( state );
- }
-
function onSelectionChange( evt )
{
var path = evt.data.path,
blockLimit = path.blockLimit,
elements = path.elements,
- element;
+ element,
+ i;
// Grouping should only happen under blockLimit.(#3940).
- for ( var i = 0 ; i < elements.length && ( element = elements[ i ] )
+ for ( i = 0 ; i < elements.length && ( element = elements[ i ] )
&& !element.equals( blockLimit ); i++ )
{
if ( listNodeNames[ elements[i].getName() ] )
- {
- return setState.call( this, evt.editor,
- this.type == elements[i].getName() ? CKEDITOR.TRISTATE_ON : CKEDITOR.TRISTATE_OFF );
- }
+ return this.setState( this.type == elements[i].getName() ? CKEDITOR.TRISTATE_ON : CKEDITOR.TRISTATE_OFF );
}
- return setState.call( this, evt.editor, CKEDITOR.TRISTATE_OFF );
+ return this.setState( CKEDITOR.TRISTATE_OFF );
}
function changeListType( editor, groupObj, database, listsCreated )
@@ -472,7 +485,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
enclosedNode = range && range.getEnclosedNode();
if ( enclosedNode && enclosedNode.is
&& this.type == enclosedNode.getName() )
- setState.call( this, editor, CKEDITOR.TRISTATE_ON );
+ this.setState( CKEDITOR.TRISTATE_ON );
}
}
@@ -673,10 +686,8 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
init : function( editor )
{
// Register commands.
- var numberedListCommand = new listCommand( 'numberedlist', 'ol' ),
- bulletedListCommand = new listCommand( 'bulletedlist', 'ul' );
- editor.addCommand( 'numberedlist', numberedListCommand );
- editor.addCommand( 'bulletedlist', bulletedListCommand );
+ var numberedListCommand = editor.addCommand( 'numberedlist', new listCommand( 'numberedlist', 'ol' ) ),
+ bulletedListCommand = editor.addCommand( 'bulletedlist', new listCommand( 'bulletedlist', 'ul' ) );
// Register the toolbar button.
editor.ui.addButton( 'NumberedList',