Index: trunk/extensions/VisualEditor/modules/es/views/es.SurfaceView.js |
— | — | @@ -143,7 +143,7 @@ |
144 | 144 | if ( e.button === 0 ) { // left mouse button |
145 | 145 | |
146 | 146 | var offset = this.documentView.getOffsetFromEvent( e ); |
147 | | - |
| 147 | + |
148 | 148 | console.log('onMouseDown; offset: ' + offset); |
149 | 149 | |
150 | 150 | if ( e.originalEvent.detail === 1 ) { // single click |
— | — | @@ -356,6 +356,40 @@ |
357 | 357 | } |
358 | 358 | |
359 | 359 | break; |
| 360 | + case 13: // Enter |
| 361 | + if ( this.selection.from === this.selection.to ) { |
| 362 | + var node = this.documentView.getNodeFromOffset( this.selection.to, false ).model, |
| 363 | + nodeType, |
| 364 | + stack = []; |
| 365 | + |
| 366 | + while ( node ) { |
| 367 | + nodeType = node.getElementType(); |
| 368 | + stack.push(nodeType); |
| 369 | + node = node.getParent(); |
| 370 | + |
| 371 | + if ( es.DocumentView.splitRules[ nodeType ].self === true ) { |
| 372 | + nodeType = node.getElementType(); |
| 373 | + if ( es.DocumentView.splitRules[ nodeType ].children === true) { |
| 374 | + break; |
| 375 | + } |
| 376 | + } |
| 377 | + } |
| 378 | + |
| 379 | + var temp = []; |
| 380 | + for ( var i = 0; i < stack.length; i++ ) { |
| 381 | + temp.push( { 'type' : '/' + stack[i] } ); |
| 382 | + } |
| 383 | + for ( var i = stack.length - 1; i >= 0; i-- ) { |
| 384 | + temp.push( { 'type' : stack[i] } ); |
| 385 | + } |
| 386 | + |
| 387 | + var tx = this.documentView.model.prepareInsertion( this.selection.to, temp ); |
| 388 | + this.documentView.model.commit( tx ); |
| 389 | + |
| 390 | + //this.selection.from = this.selection.to = this.documentView.getModel().getRelativeContentOffset( this.selection.to+1, 1 ); |
| 391 | + //this.showCursor(); |
| 392 | + } |
| 393 | + break; |
360 | 394 | default: // Insert content (maybe) |
361 | 395 | if ( this.keyboard.keydownTimeout ) { |
362 | 396 | clearTimeout( this.keyboard.keydownTimeout ); |