From 122a31a02151eb02beea26041a897e3ce3e76c91 Mon Sep 17 00:00:00 2001 From: Christian Williams Date: Fri, 22 Jun 2012 15:05:35 -0700 Subject: [PATCH] Bugzilla:33093 - Shift-Enter splits at paragraphs instead of list items Change-Id: Ie32e878cf9c71f7179143c631a01c0e2e671ed18 --- modules/ve/ce/ve.ce.Surface.js | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/modules/ve/ce/ve.ce.Surface.js b/modules/ve/ce/ve.ce.Surface.js index 061b79d919..367fc164f0 100644 --- a/modules/ve/ce/ve.ce.Surface.js +++ b/modules/ve/ce/ve.ce.Surface.js @@ -182,7 +182,7 @@ ve.ce.Surface.prototype.onKeyDown = function( e ) { // Enter case 13: e.preventDefault(); - this.handleEnter(); + this.handleEnter( e ); break; // Backspace case 8: @@ -605,14 +605,16 @@ ve.ce.Surface.prototype.onChange = function( transaction, selection ) { } }; -ve.ce.Surface.prototype.handleEnter = function() { +ve.ce.Surface.prototype.handleEnter = function( e ) { var selection = this.model.getSelection(), documentModel = this.model.getDocument(), emptyParagraph = [{ 'type': 'paragraph' }, { 'type': '/paragraph' }], tx, advanceCursor = true; + // Stop polling while we work this.stopPolling(); + // Handle removal first if ( selection.from !== selection.to ) { tx = ve.dm.Transaction.newFromRemoval( documentModel, selection ); @@ -661,12 +663,16 @@ ve.ce.Surface.prototype.handleEnter = function() { node.model.getClonedElement() ); outermostNode = node; - return true; + if ( e.shiftKey ) { + return false; + } else { + return true; + } } ); - + var outerParent = outermostNode.getModel().getParent(), outerChildrenCount = outerParent.getChildren().length - + if ( outermostNode.type == 'listItem' && // this is a list item outerParent.getChildren()[outerChildrenCount - 1] == outermostNode.getModel() && // this is the last list item