/*\r
-Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved.\r
+Copyright (c) 2003-2012, CKSource - Frederico Knabben. All rights reserved.\r
For licensing, see LICENSE.html or http://ckeditor.com/license\r
*/\r
\r
\r
var whitespaces = CKEDITOR.dom.walker.whitespaces(),\r
bookmarks = CKEDITOR.dom.walker.bookmark(),\r
- nonEmpty = function( node ){ return !( whitespaces( node ) || bookmarks( node ) ); };\r
+ nonEmpty = function( node ){ return !( whitespaces( node ) || bookmarks( node ) );},\r
+ blockBogus = CKEDITOR.dom.walker.bogus();\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
+ // Inheirt inline styles from another element.\r
+ function inheirtInlineStyles( parent, el )\r
+ {\r
+ var style = parent.getAttribute( 'style' );\r
+\r
+ // Put parent styles before child styles.\r
+ style && el.setAttribute( 'style',\r
+ style.replace( /([^;])$/, '$1;' ) +\r
+ ( el.getAttribute( 'style' ) || '' ) );\r
+ }\r
\r
CKEDITOR.plugins.list = {\r
/*\r
baseIndex = 0;\r
if ( !listArray || listArray.length < baseIndex + 1 )\r
return null;\r
- var doc = listArray[ baseIndex ].parent.getDocument(),\r
+ var i,\r
+ doc = listArray[ baseIndex ].parent.getDocument(),\r
retval = new CKEDITOR.dom.documentFragment( doc ),\r
rootNode = null,\r
currentIndex = baseIndex,\r
indentLevel = Math.max( listArray[ baseIndex ].indent, 0 ),\r
currentListItem = null,\r
orgDir,\r
+ block,\r
paragraphName = ( paragraphMode == CKEDITOR.ENTER_P ? 'p' : 'div' );\r
while ( 1 )\r
{\r
- var item = listArray[ currentIndex ];\r
+ var item = listArray[ currentIndex ],\r
+ itemGrandParent = item.grandparent;\r
\r
orgDir = item.element.getDirection( 1 );\r
\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
+ for ( i = 0 ; i < item.contents.length ; i++ )\r
currentListItem.append( item.contents[i].clone( 1, 1 ) );\r
currentIndex++;\r
}\r
currentListItem.append( listData.listNode );\r
currentIndex = listData.nextIndex;\r
}\r
- else if ( item.indent == -1 && !baseIndex && item.grandparent )\r
+ else if ( item.indent == -1 && !baseIndex && itemGrandParent )\r
{\r
- if ( listNodeNames[ item.grandparent.getName() ] )\r
+ if ( listNodeNames[ itemGrandParent.getName() ] )\r
+ {\r
currentListItem = item.element.clone( false, true );\r
+ if ( orgDir != itemGrandParent.getDirection( 1 ) )\r
+ currentListItem.setAttribute( 'dir', orgDir );\r
+ }\r
else\r
+ currentListItem = new CKEDITOR.dom.documentFragment( doc );\r
+\r
+ // Migrate all children to the new container,\r
+ // apply the proper text direction.\r
+ var dirLoose = itemGrandParent.getDirection( 1 ) != orgDir,\r
+ li = item.element,\r
+ className = li.getAttribute( 'class' ),\r
+ style = li.getAttribute( 'style' );\r
+\r
+ var needsBlock = currentListItem.type ==\r
+ CKEDITOR.NODE_DOCUMENT_FRAGMENT &&\r
+ ( paragraphMode != CKEDITOR.ENTER_BR || dirLoose ||\r
+ style || className );\r
+\r
+ var child, count = item.contents.length;\r
+ for ( i = 0 ; i < count; i++ )\r
{\r
- // Create completely new blocks here.\r
- if ( dir || item.element.hasAttributes() || paragraphMode != CKEDITOR.ENTER_BR )\r
+ child = item.contents[ i ];\r
+\r
+ if ( child.type == CKEDITOR.NODE_ELEMENT && child.isBlockBoundary() )\r
+ {\r
+ // Apply direction on content blocks.\r
+ if ( dirLoose && !child.getDirection() )\r
+ child.setAttribute( 'dir', orgDir );\r
+\r
+ inheirtInlineStyles( li, child );\r
+\r
+ className && child.addClass( className );\r
+ }\r
+ else if ( needsBlock )\r
{\r
- currentListItem = doc.createElement( paragraphName );\r
- item.element.copyAttributes( currentListItem, { type:1, value:1 } );\r
-\r
- // There might be a case where there are no attributes in the element after all\r
- // (i.e. when "type" or "value" are the only attributes set). In this case, if enterMode = BR,\r
- // the current item should be a fragment.\r
- if ( !dir && paragraphMode == CKEDITOR.ENTER_BR && !currentListItem.hasAttributes() )\r
- currentListItem = new CKEDITOR.dom.documentFragment( doc );\r
+ // Establish new block to hold text direction and styles.\r
+ if ( !block )\r
+ {\r
+ block = doc.createElement( paragraphName );\r
+ dirLoose && block.setAttribute( 'dir', orgDir );\r
+ }\r
+\r
+ // Copy over styles to new block;\r
+ style && block.setAttribute( 'style', style );\r
+ className && block.setAttribute( 'class', className );\r
+\r
+ block.append( child.clone( 1, 1 ) );\r
}\r
- else\r
- currentListItem = new CKEDITOR.dom.documentFragment( doc );\r
- }\r
\r
- if ( currentListItem.type == CKEDITOR.NODE_ELEMENT )\r
- {\r
- if ( item.grandparent.getDirection( 1 ) != orgDir )\r
- currentListItem.setAttribute( 'dir', orgDir );\r
- else\r
- currentListItem.removeAttribute( 'dir' );\r
+ currentListItem.append( block || child.clone( 1, 1 ) );\r
}\r
\r
- for ( i = 0 ; i < item.contents.length ; i++ )\r
- currentListItem.append( item.contents[i].clone( 1, 1 ) );\r
-\r
if ( currentListItem.type == CKEDITOR.NODE_DOCUMENT_FRAGMENT\r
&& currentIndex != listArray.length - 1 )\r
{\r
}\r
}\r
\r
- if ( currentListItem.type == CKEDITOR.NODE_ELEMENT &&\r
- currentListItem.getName() == paragraphName &&\r
- currentListItem.$.firstChild )\r
- {\r
- currentListItem.trim();\r
- var firstChild = currentListItem.getFirst();\r
- if ( firstChild.type == CKEDITOR.NODE_ELEMENT && firstChild.isBlockBoundary() )\r
- {\r
- var tmp = new CKEDITOR.dom.documentFragment( doc );\r
- currentListItem.moveChildren( tmp );\r
- currentListItem = tmp;\r
- }\r
- }\r
-\r
var currentListItemName = currentListItem.$.nodeName.toLowerCase();\r
if ( !CKEDITOR.env.ie && ( currentListItemName == 'div' || currentListItemName == 'p' ) )\r
currentListItem.appendBogus();\r
else\r
return null;\r
\r
+ block = null;\r
+\r
if ( listArray.length <= currentIndex || Math.max( listArray[ currentIndex ].indent, 0 ) < indentLevel )\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
}\r
\r
var root = groupObj.root,\r
- fakeParent = root.getDocument().createElement( this.type );\r
- // Copy all attributes, except from 'start' and 'type'.\r
- root.copyAttributes( fakeParent, { start : 1, type : 1 } );\r
- // The list-style-type property should be ignored.\r
- fakeParent.removeStyle( 'list-style-type' );\r
+ doc = root.getDocument(),\r
+ listNode,\r
+ newListNode;\r
\r
for ( i = 0 ; i < selectedListItems.length ; i++ )\r
{\r
var listIndex = selectedListItems[i].getCustomData( 'listarray_index' );\r
- listArray[listIndex].parent = fakeParent;\r
+ listNode = listArray[ listIndex ].parent;\r
+\r
+ // Switch to new list node for this particular item.\r
+ if ( !listNode.is( this.type ) )\r
+ {\r
+ newListNode = doc.createElement( this.type );\r
+ // Copy all attributes, except from 'start' and 'type'.\r
+ listNode.copyAttributes( newListNode, { start : 1, type : 1 } );\r
+ // The list-style-type property should be ignored.\r
+ newListNode.removeStyle( 'list-style-type' );\r
+ listArray[ listIndex ].parent = newListNode;\r
+ }\r
}\r
+\r
var newList = CKEDITOR.plugins.list.arrayToList( listArray, database, null, editor.config.enterMode );\r
var child, length = newList.listNode.getChildCount();\r
for ( i = 0 ; i < length && ( child = newList.listNode.getChild( i ) ) ; i++ )\r
this.type = type;\r
}\r
\r
+ var elementType = CKEDITOR.dom.walker.nodeType( CKEDITOR.NODE_ELEMENT );\r
+\r
+ // Merge child nodes with direction preserved. (#7448)\r
+ function mergeChildren( from, into, refNode, forward )\r
+ {\r
+ var child, itemDir;\r
+ while ( ( child = from[ forward ? 'getLast' : 'getFirst' ]( elementType ) ) )\r
+ {\r
+ if ( ( itemDir = child.getDirection( 1 ) ) !== into.getDirection( 1 ) )\r
+ child.setAttribute( 'dir', itemDir );\r
+\r
+ child.remove();\r
+\r
+ refNode ?\r
+ child[ forward ? 'insertBefore' : 'insertAfter' ]( refNode ) :\r
+ into.append( child, forward );\r
+ }\r
+ }\r
+\r
listCommand.prototype = {\r
exec : function( editor )\r
{\r
removeList.call( this, editor, groupObj, database );\r
}\r
\r
- // For all new lists created, merge adjacent, same type lists.\r
+ // For all new lists created, merge into adjacent, same type lists.\r
for ( i = 0 ; i < listsCreated.length ; i++ )\r
- {\r
- listNode = listsCreated[i];\r
- var mergeSibling, listCommand = this;\r
- ( mergeSibling = function( rtl ){\r
-\r
- var sibling = listNode[ rtl ?\r
- 'getPrevious' : 'getNext' ]( CKEDITOR.dom.walker.whitespaces( true ) );\r
- if ( sibling && sibling.getName &&\r
- sibling.getName() == listCommand.type )\r
- {\r
- sibling.remove();\r
- // Move children order by merge direction.(#3820)\r
- sibling.moveChildren( listNode, rtl );\r
- }\r
- } )();\r
- mergeSibling( 1 );\r
- }\r
+ mergeListSiblings( listsCreated[ i ] );\r
\r
// Clean up, restore selection and update toolbar button states.\r
CKEDITOR.dom.element.clearAllMarkers( database );\r
}\r
};\r
\r
+ // Merge list adjacent, of same type lists.\r
+ function mergeListSiblings( listNode )\r
+ {\r
+ var mergeSibling;\r
+ ( mergeSibling = function( rtl )\r
+ {\r
+ var sibling = listNode[ rtl ? 'getPrevious' : 'getNext' ]( nonEmpty );\r
+ if ( sibling && sibling.type == CKEDITOR.NODE_ELEMENT &&\r
+ sibling.is( listNode.getName() ) )\r
+ {\r
+ // Move children order by merge direction.(#3820)\r
+ mergeChildren( listNode, sibling, null, !rtl );\r
+\r
+ listNode.remove();\r
+ listNode = sibling;\r
+ }\r
+ } )();\r
+ mergeSibling( 1 );\r
+ }\r
+\r
var dtd = CKEDITOR.dtd;\r
var tailNbspRegex = /[\t\r\n ]*(?: |\xa0)$/;\r
\r
for ( i in dtd.$listItem )\r
defaultListHtmlFilterRules.elements[ i ] = getExtendNestedListFilter( true );\r
\r
+ // Check if node is block element that recieves text.\r
+ function isTextBlock( node )\r
+ {\r
+ return node.type == CKEDITOR.NODE_ELEMENT &&\r
+ ( node.getName() in CKEDITOR.dtd.$block ||\r
+ node.getName() in CKEDITOR.dtd.$listItem ) &&\r
+ CKEDITOR.dtd[ node.getName() ][ '#' ];\r
+ }\r
+\r
+ // Join visually two block lines.\r
+ function joinNextLineToCursor( editor, cursor, nextCursor )\r
+ {\r
+ editor.fire( 'saveSnapshot' );\r
+\r
+ // Merge with previous block's content.\r
+ nextCursor.enlarge( CKEDITOR.ENLARGE_LIST_ITEM_CONTENTS );\r
+ var frag = nextCursor.extractContents();\r
+\r
+ cursor.trim( false, true );\r
+ var bm = cursor.createBookmark();\r
+\r
+ // Kill original bogus;\r
+ var currentPath = new CKEDITOR.dom.elementPath( cursor.startContainer ),\r
+ pathBlock = currentPath.block,\r
+ currentBlock = currentPath.lastElement.getAscendant( 'li', 1 ) || pathBlock,\r
+ nextPath = new CKEDITOR.dom.elementPath( nextCursor.startContainer ),\r
+ nextLi = nextPath.contains( CKEDITOR.dtd.$listItem ),\r
+ nextList = nextPath.contains( CKEDITOR.dtd.$list ),\r
+ last;\r
+\r
+ // Remove bogus node the current block/pseudo block.\r
+ if ( pathBlock )\r
+ {\r
+ var bogus = pathBlock.getBogus();\r
+ bogus && bogus.remove();\r
+ }\r
+ else if ( nextList )\r
+ {\r
+ last = nextList.getPrevious( nonEmpty );\r
+ if ( last && blockBogus( last ) )\r
+ last.remove();\r
+ }\r
+\r
+ // Kill the tail br in extracted.\r
+ last = frag.getLast();\r
+ if ( last && last.type == CKEDITOR.NODE_ELEMENT && last.is( 'br' ) )\r
+ last.remove();\r
+\r
+ // Insert fragment at the range position.\r
+ var nextNode = cursor.startContainer.getChild( cursor.startOffset );\r
+ if ( nextNode )\r
+ frag.insertBefore( nextNode );\r
+ else\r
+ cursor.startContainer.append( frag );\r
+\r
+ // Move the sub list nested in the next list item.\r
+ if ( nextLi )\r
+ {\r
+ var sublist = getSubList( nextLi );\r
+ if ( sublist )\r
+ {\r
+ // If next line is in the sub list of the current list item.\r
+ if ( currentBlock.contains( nextLi ) )\r
+ {\r
+ mergeChildren( sublist, nextLi.getParent(), nextLi );\r
+ sublist.remove();\r
+ }\r
+ // Migrate the sub list to current list item.\r
+ else\r
+ currentBlock.append( sublist );\r
+ }\r
+ }\r
+\r
+ // Remove any remaining empty path blocks at next line after merging.\r
+ while ( nextCursor.checkStartOfBlock() &&\r
+ nextCursor.checkEndOfBlock() )\r
+ {\r
+ nextPath = new CKEDITOR.dom.elementPath( nextCursor.startContainer );\r
+ var nextBlock = nextPath.block, parent;\r
+\r
+ // Check if also to remove empty list.\r
+ if ( nextBlock.is( 'li' ) )\r
+ {\r
+ parent = nextBlock.getParent();\r
+ if ( nextBlock.equals( parent.getLast( nonEmpty ) )\r
+ && nextBlock.equals( parent.getFirst( nonEmpty ) ) )\r
+ nextBlock = parent;\r
+ }\r
+\r
+ nextCursor.moveToPosition( nextBlock, CKEDITOR.POSITION_BEFORE_START );\r
+ nextBlock.remove();\r
+ }\r
+\r
+ // Check if need to further merge with the list resides after the merged block. (#9080)\r
+ var walkerRng = nextCursor.clone(), body = editor.document.getBody();\r
+ walkerRng.setEndAt( body, CKEDITOR.POSITION_BEFORE_END );\r
+ var walker = new CKEDITOR.dom.walker( walkerRng );\r
+ walker.evaluator = function( node ) { return nonEmpty( node ) && !blockBogus( node ); };\r
+ var next = walker.next();\r
+ if ( next && next.type == CKEDITOR.NODE_ELEMENT && next.getName() in CKEDITOR.dtd.$list )\r
+ mergeListSiblings( next );\r
+\r
+ cursor.moveToBookmark( bm );\r
+\r
+ // Make fresh selection.\r
+ cursor.select();\r
+\r
+ editor.selectionChange( 1 );\r
+ editor.fire( 'saveSnapshot' );\r
+ }\r
+\r
+ function getSubList( li )\r
+ {\r
+ var last = li.getLast( nonEmpty );\r
+ return last && last.type == CKEDITOR.NODE_ELEMENT && last.getName() in listNodeNames ? last : null;\r
+ }\r
+\r
CKEDITOR.plugins.add( 'list',\r
{\r
init : function( editor )\r
// Register the state changing handlers.\r
editor.on( 'selectionChange', CKEDITOR.tools.bind( onSelectionChange, numberedListCommand ) );\r
editor.on( 'selectionChange', CKEDITOR.tools.bind( onSelectionChange, bulletedListCommand ) );\r
+\r
+ // Handled backspace/del key to join list items. (#8248,#9080)\r
+ editor.on( 'key', function( evt )\r
+ {\r
+ var key = evt.data.keyCode;\r
+\r
+ // DEl/BACKSPACE\r
+ if ( editor.mode == 'wysiwyg' && key in { 8 : 1, 46 : 1 } )\r
+ {\r
+ var sel = editor.getSelection(),\r
+ range = sel.getRanges()[ 0 ];\r
+\r
+ if ( !range.collapsed )\r
+ return;\r
+\r
+ var path = new CKEDITOR.dom.elementPath( range.startContainer );\r
+ var isBackspace = key == 8;\r
+ var body = editor.document.getBody();\r
+ var walker = new CKEDITOR.dom.walker( range.clone() );\r
+ walker.evaluator = function( node ) { return nonEmpty( node ) && !blockBogus( node ); };\r
+\r
+ // Backspace/Del behavior at the start/end of table is handled in core.\r
+ walker.guard = function( node, isOut ) { return !( isOut && node.type == CKEDITOR.NODE_ELEMENT && node.is( 'table' ) ); };\r
+\r
+ var cursor = range.clone();\r
+\r
+ if ( isBackspace )\r
+ {\r
+ var previous, joinWith;\r
+\r
+ // Join a sub list's first line, with the previous visual line in parent.\r
+ if ( ( previous = path.contains( listNodeNames ) ) &&\r
+ range.checkBoundaryOfElement( previous, CKEDITOR.START ) &&\r
+ ( previous = previous.getParent() ) && previous.is( 'li' ) &&\r
+ ( previous = getSubList( previous ) ) )\r
+ {\r
+ joinWith = previous;\r
+ previous = previous.getPrevious( nonEmpty );\r
+ // Place cursor before the nested list.\r
+ cursor.moveToPosition(\r
+ previous && blockBogus( previous ) ? previous : joinWith,\r
+ CKEDITOR.POSITION_BEFORE_START );\r
+ }\r
+ // Join any line following a list, with the last visual line of the list.\r
+ else\r
+ {\r
+ walker.range.setStartAt( body, CKEDITOR.POSITION_AFTER_START );\r
+ walker.range.setEnd( range.startContainer, range.startOffset );\r
+ previous = walker.previous();\r
+\r
+ if ( previous && previous.type == CKEDITOR.NODE_ELEMENT &&\r
+ ( previous.getName() in listNodeNames || previous.is( 'li' ) ) )\r
+ {\r
+ if ( !previous.is( 'li' ) )\r
+ {\r
+ walker.range.selectNodeContents( previous );\r
+ walker.reset();\r
+ walker.evaluator = isTextBlock;\r
+ previous = walker.previous();\r
+ }\r
+\r
+ joinWith = previous;\r
+ // Place cursor at the end of previous block.\r
+ cursor.moveToElementEditEnd( joinWith );\r
+ }\r
+ }\r
+\r
+ if ( joinWith )\r
+ {\r
+ joinNextLineToCursor( editor, cursor, range );\r
+ evt.cancel();\r
+ }\r
+ else\r
+ {\r
+ var list = path.contains( listNodeNames ), li;\r
+ // Backspace pressed at the start of list outdents the first list item. (#9129)\r
+ if ( list && range.checkBoundaryOfElement( list, CKEDITOR.START ) )\r
+ {\r
+ li = list.getFirst( nonEmpty );\r
+\r
+ if ( range.checkBoundaryOfElement( li, CKEDITOR.START ) )\r
+ {\r
+ previous = list.getPrevious( nonEmpty );\r
+\r
+ // Only if the list item contains a sub list, do nothing but\r
+ // simply move cursor backward one character.\r
+ if ( getSubList( li ) )\r
+ {\r
+ if ( previous ) {\r
+ range.moveToElementEditEnd( previous );\r
+ range.select();\r
+ }\r
+\r
+ evt.cancel();\r
+ }\r
+ else\r
+ {\r
+ editor.execCommand( 'outdent' );\r
+ evt.cancel();\r
+ }\r
+ }\r
+ }\r
+ }\r
+ }\r
+ else\r
+ {\r
+ var next, nextLine;\r
+ li = range.startContainer.getAscendant( 'li', 1 );\r
+\r
+ if ( li )\r
+ {\r
+ walker.range.setEndAt( body, CKEDITOR.POSITION_BEFORE_END );\r
+\r
+ var last = li.getLast( nonEmpty );\r
+ var block = last && isTextBlock( last ) ? last : li;\r
+\r
+ // Indicate cursor at the visual end of an list item.\r
+ var isAtEnd = 0;\r
+\r
+ next = walker.next();\r
+\r
+ // When list item contains a sub list.\r
+ if ( next && next.type == CKEDITOR.NODE_ELEMENT &&\r
+ next.getName() in listNodeNames\r
+ && next.equals( last ) )\r
+ {\r
+ isAtEnd = 1;\r
+\r
+ // Move to the first item in sub list.\r
+ next = walker.next();\r
+ }\r
+ // Right at the end of list item.\r
+ else if ( range.checkBoundaryOfElement( block, CKEDITOR.END ) )\r
+ isAtEnd = 1;\r
+\r
+\r
+ if ( isAtEnd && next )\r
+ {\r
+ // Put cursor range there.\r
+ nextLine = range.clone();\r
+ nextLine.moveToElementEditStart( next );\r
+\r
+ joinNextLineToCursor( editor, cursor, nextLine );\r
+ evt.cancel();\r
+ }\r
+ }\r
+ else\r
+ {\r
+ // Handle Del key pressed before the list.\r
+ walker.range.setEndAt( body, CKEDITOR.POSITION_BEFORE_END );\r
+ next = walker.next();\r
+\r
+ if ( next && next.type == CKEDITOR.NODE_ELEMENT &&\r
+ next.getName() in listNodeNames )\r
+ {\r
+ // The start <li>\r
+ next = next.getFirst( nonEmpty );\r
+\r
+ // Simply remove the current empty block, move cursor to the\r
+ // subsequent list.\r
+ if ( path.block &&\r
+ range.checkStartOfBlock() &&\r
+ range.checkEndOfBlock() )\r
+ {\r
+ path.block.remove();\r
+ range.moveToElementEditStart( next );\r
+ range.select();\r
+ evt.cancel();\r
+ }\r
+\r
+ // Preventing the default (merge behavior), but simply move\r
+ // the cursor one character forward if subsequent list item\r
+ // contains sub list.\r
+ else if ( getSubList( next ) )\r
+ {\r
+ range.moveToElementEditStart( next );\r
+ range.select();\r
+ evt.cancel();\r
+ }\r
+ // Merge the first list item with the current line.\r
+ else\r
+ {\r
+ nextLine = range.clone();\r
+ nextLine.moveToElementEditStart( next );\r
+ joinNextLineToCursor( editor, cursor, nextLine );\r
+ evt.cancel();\r
+ }\r
+ }\r
+ }\r
+ }\r
+\r
+ // The backspace/del could potentially put cursor at a bad position,\r
+ // being it handled or not, check immediately the selection to have it fixed.\r
+ setTimeout( function() { editor.selectionChange( 1 ); } );\r
+ }\r
+ } );\r
},\r
\r
afterInit : function ( editor )\r