diff --git a/modules/ve/ce/ve.ce.Surface.js b/modules/ve/ce/ve.ce.Surface.js index 4daca66107..91ecaed758 100644 --- a/modules/ve/ce/ve.ce.Surface.js +++ b/modules/ve/ce/ve.ce.Surface.js @@ -719,20 +719,16 @@ ve.ce.Surface.prototype.handleEnter = function( e ) { node.model.length === 0 // the child is empty ) { // Enter was pressed in an empty list item. - var list = outermostNode.getModel().getParent(); - // Remove the list item - tx = ve.dm.Transaction.newFromRemoval( documentModel, outermostNode.getModel().getOuterRange() ); - this.model.change( tx ); - // Insert a paragraph - tx = ve.dm.Transaction.newFromInsertion( documentModel, list.getOuterRange().to, emptyParagraph ); - + // Outdent the list item, which will turn it into a paragraph if it's not in a nested list + // FIXME this is an ugly way to trigger outdent, with a proper API we could do better + ve.ui.IndentationButtonTool.outdentListItem( this.model ); advanceCursor = false; } else { // We must process the transaction first because getRelativeContentOffset can't help us yet tx = ve.dm.Transaction.newFromInsertion( documentModel, selection.from, stack ); + this.model.change( tx ); } } - this.model.change( tx ); // Now we can move the cursor forward if ( advanceCursor ) {