Index: trunk/extensions/VisualEditor/modules/es/views/es.SurfaceView.js |
— | — | @@ -56,7 +56,7 @@ |
57 | 57 | } ); |
58 | 58 | |
59 | 59 | // Hidden input |
60 | | - this.$input = $( '<input class="es-surfaceView-input" />' ) |
| 60 | + this.$input = $( '<textarea class="es-surfaceView-textarea" />' ) |
61 | 61 | .prependTo( this.$ ) |
62 | 62 | .on( { |
63 | 63 | 'focus' : function() { |
— | — | @@ -199,11 +199,29 @@ |
200 | 200 | case 46: // Delete |
201 | 201 | break; |
202 | 202 | default: // Insert content (maybe) |
| 203 | + if ( this.keyboard.keydownTimeout ) { |
| 204 | + clearTimeout( this.keyboard.keydownTimeout ); |
| 205 | + } |
| 206 | + var surface = this; |
| 207 | + this.keyboard.keydownTimeout = setTimeout( function () { |
| 208 | + surface.insertFromInput(); |
| 209 | + }, 10 ); |
203 | 210 | break; |
204 | 211 | } |
205 | | - return false; |
| 212 | + return true; |
206 | 213 | }; |
207 | 214 | |
| 215 | +es.SurfaceView.prototype.insertFromInput = function() { |
| 216 | + var val = this.$input.val(); |
| 217 | + this.$input.val( '' ); |
| 218 | + if ( val.length > 0 ) { |
| 219 | + var transaction = this.documentView.model.prepareInsertion( this.selection.to, val.split('') ); |
| 220 | + this.documentView.model.commit ( transaction ); |
| 221 | + this.selection.to += val.length; |
| 222 | + this.showCursor(); |
| 223 | + } |
| 224 | +}; |
| 225 | + |
208 | 226 | es.SurfaceView.prototype.onKeyUp = function( e ) { |
209 | 227 | switch ( e.keyCode ) { |
210 | 228 | case 16: // Shift |