https://www.mediawiki.org/wiki/Special:Code/MediaWiki/103424

Revision: 103424
Author:   inez
Date:     2011-11-17 00:28:40 +0000 (Thu, 17 Nov 2011)
Log Message:
-----------
Improve handling for enter, backspace, delete

Modified Paths:
--------------
    trunk/extensions/VisualEditor/modules/es/views/es.SurfaceView.js

Modified: trunk/extensions/VisualEditor/modules/es/views/es.SurfaceView.js
===================================================================
--- trunk/extensions/VisualEditor/modules/es/views/es.SurfaceView.js    
2011-11-17 00:26:18 UTC (rev 103423)
+++ trunk/extensions/VisualEditor/modules/es/views/es.SurfaceView.js    
2011-11-17 00:28:40 UTC (rev 103424)
@@ -334,27 +334,43 @@
                        break;
                case 8: // Backspace
                        this.selection.normalize();
+                       
+                       var range;
 
-                       if ( this.selection.from != this.selection.to ) { // 
delete selection
-                               var tx = 
this.documentView.model.prepareRemoval( this.selection );
-                               this.documentView.model.commit ( tx );
+                       if ( this.selection.from === this.selection.to ) {
+                               range = new es.Range(
+                                       
this.documentView.getModel().getRelativeContentOffset( this.selection.from, -1 
),
+                                       this.selection.from
+                               );
+                       } else {
                                this.documentView.clearSelection();
-                               this.selection.from = this.selection.to = 
this.selection.start;
-                               this.showCursor();
+                               range = this.selection;                         
                        }
 
+                       var tx = this.documentView.model.prepareRemoval( range 
);
+                       this.documentView.model.commit ( tx );
+                       this.selection.from = this.selection.to = range.start;
+                       this.showCursor();
                        break;
                case 46: // Delete
                        this.selection.normalize();
 
-                       if ( this.selection.from != this.selection.to ) { // 
delete selection
-                               var tx = 
this.documentView.model.prepareRemoval( this.selection );
-                               this.documentView.model.commit ( tx );
+                       var range;
+
+                       if ( this.selection.from === this.selection.to ) {
+                               range = new es.Range(
+                                       
this.documentView.getModel().getRelativeContentOffset( this.selection.from, 1 ),
+                                       this.selection.from
+                               );
+                       } else {
                                this.documentView.clearSelection();
-                               this.selection.from = this.selection.to = 
this.selection.start;
-                               this.showCursor();
+                               range = this.selection;                         
                        }
 
+                       var tx = this.documentView.model.prepareRemoval( range 
);
+                       this.documentView.model.commit ( tx );
+                       this.selection.from = this.selection.to = range.start;
+                       this.showCursor();
                        break;
                case 13: // Enter
                        if ( this.selection.from === this.selection.to ) {
@@ -385,6 +401,7 @@
                                this.selection.from = this.selection.to = 
this.documentView.getModel().getRelativeContentOffset( this.selection.to, 1 );
                                this.showCursor();
                                e.preventDefault();
+                               return false;
                        }
                        break;
                default: // Insert content (maybe)


_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to