Index: trunk/extensions/VisualEditor/modules/es/views/es.SurfaceView.js |
— | — | @@ -70,10 +70,11 @@ |
71 | 71 | // Respond to selection changes |
72 | 72 | if ( selection.from !== selection.to ) { |
73 | 73 | _this.hideCursor(); |
| 74 | + _this.documentView.drawSelection( selection ); |
74 | 75 | } else { |
75 | 76 | _this.showCursor(); |
| 77 | + _this.documentView.clearSelection( selection ); |
76 | 78 | } |
77 | | - _this.documentView.drawSelection( selection ); |
78 | 79 | } ); |
79 | 80 | this.model.getDocument().on( 'update', function() { |
80 | 81 | _this.emit( 'update' ); |
— | — | @@ -156,10 +157,6 @@ |
157 | 158 | // Extend current or create new selection |
158 | 159 | selection.to = offset; |
159 | 160 | } else { |
160 | | - if ( selection.to !== selection.from ) { |
161 | | - // Clear the selection if there was any |
162 | | - this.documentView.clearSelection(); |
163 | | - } |
164 | 161 | selection.from = selection.to = offset; |
165 | 162 | |
166 | 163 | var position = es.Position.newFromEventPagePosition( e ), |
— | — | @@ -371,9 +368,9 @@ |
372 | 369 | case 85: |
373 | 370 | if ( e.metaKey || e.ctrlKey ) { |
374 | 371 | if ( this.keyboard.keys.shift ) { |
375 | | - this.model.redo( 1 ); |
| 372 | + this.model.redo( 1, true ); |
376 | 373 | } else { |
377 | | - this.model.undo( 1 ); |
| 374 | + this.model.undo( 1, true ); |
378 | 375 | } |
379 | 376 | return false; |
380 | 377 | } |
— | — | @@ -383,9 +380,9 @@ |
384 | 381 | case 90: |
385 | 382 | if ( e.metaKey || e.ctrlKey ) { |
386 | 383 | if ( this.keyboard.keys.shift ) { |
387 | | - this.model.redo( 1, true ); |
| 384 | + this.model.redo( 1 ); |
388 | 385 | } else { |
389 | | - this.model.undo( 1, true ); |
| 386 | + this.model.undo( 1 ); |
390 | 387 | } |
391 | 388 | return false; |
392 | 389 | } |
— | — | @@ -444,7 +441,7 @@ |
445 | 442 | } |
446 | 443 | |
447 | 444 | selection.from = selection.to = targetOffset; |
448 | | - this.model.select( selection ); |
| 445 | + this.model.select( selection, true ); |
449 | 446 | |
450 | 447 | if ( sourceNode === targetNode || |
451 | 448 | ( typeof sourceSplitableNode !== 'undefined' && |
— | — | @@ -452,12 +449,12 @@ |
453 | 450 | tx = this.model.getDocument().prepareRemoval( |
454 | 451 | new es.Range( targetOffset, sourceOffset ) |
455 | 452 | ); |
456 | | - this.model.transact( tx ); |
| 453 | + this.model.transact( tx, true ); |
457 | 454 | } else { |
458 | 455 | tx = this.model.getDocument().prepareInsertion( |
459 | 456 | targetOffset, sourceNode.model.getContent() |
460 | 457 | ); |
461 | | - this.model.transact( tx ); |
| 458 | + this.model.transact( tx, true ); |
462 | 459 | |
463 | 460 | var nodeToDelete = sourceNode; |
464 | 461 | es.DocumentNode.traverseUpstream( nodeToDelete, function( node ) { |
— | — | @@ -471,15 +468,14 @@ |
472 | 469 | range.from = this.documentView.getOffsetFromNode( nodeToDelete, false ); |
473 | 470 | range.to = range.from + nodeToDelete.getElementLength(); |
474 | 471 | tx = this.model.getDocument().prepareRemoval( range ); |
475 | | - this.model.transact( tx ); |
| 472 | + this.model.transact( tx, true ); |
476 | 473 | } |
477 | 474 | } else { |
478 | 475 | // selection removal |
479 | 476 | tx = this.model.getDocument().prepareRemoval( selection ); |
480 | | - this.model.transact( tx ); |
481 | | - this.documentView.clearSelection(); |
| 477 | + this.model.transact( tx, true ); |
482 | 478 | selection.from = selection.to = selection.start; |
483 | | - this.model.select( selection ); |
| 479 | + this.model.select( selection, true ); |
484 | 480 | } |
485 | 481 | }; |
486 | 482 | |
— | — | @@ -500,7 +496,7 @@ |
501 | 497 | nodeOffset + node.getElementLength(), |
502 | 498 | [ { 'type': 'paragraph' }, { 'type': '/paragraph' } ] |
503 | 499 | ); |
504 | | - this.model.transact( tx ); |
| 500 | + this.model.transact( tx, true ); |
505 | 501 | selection.from = selection.to = nodeOffset + node.getElementLength() + 1; |
506 | 502 | } else { |
507 | 503 | var stack = [], |
— | — | @@ -526,11 +522,11 @@ |
527 | 523 | splitable = es.DocumentView.splitRules[ elementType ].self; |
528 | 524 | } ); |
529 | 525 | tx = this.documentView.model.prepareInsertion( selection.to, stack ); |
530 | | - this.model.transact( tx ); |
| 526 | + this.model.transact( tx, true ); |
531 | 527 | selection.from = selection.to = |
532 | 528 | this.model.getDocument().getRelativeContentOffset( selection.to, 1 ); |
533 | 529 | } |
534 | | - this.model.select( selection ); |
| 530 | + this.model.select( selection, true ); |
535 | 531 | }; |
536 | 532 | |
537 | 533 | es.SurfaceView.prototype.insertFromInput = function() { |
— | — | @@ -541,16 +537,15 @@ |
542 | 538 | var tx; |
543 | 539 | if ( selection.from != selection.to ) { |
544 | 540 | tx = this.model.getDocument().prepareRemoval( selection ); |
545 | | - this.model.transact( tx ); |
546 | | - this.documentView.clearSelection(); |
| 541 | + this.model.transact( tx, true ); |
547 | 542 | selection.from = selection.to = |
548 | 543 | Math.min( selection.from, selection.to ); |
549 | 544 | } |
550 | 545 | tx = this.model.getDocument().prepareInsertion( selection.from, val.split('') ); |
551 | | - this.model.transact( tx ); |
| 546 | + this.model.transact( tx, true ); |
552 | 547 | selection.from += val.length; |
553 | 548 | selection.to += val.length; |
554 | | - this.model.select( selection ); |
| 549 | + this.model.select( selection, true ); |
555 | 550 | } |
556 | 551 | }; |
557 | 552 | |
— | — | @@ -671,9 +666,6 @@ |
672 | 667 | if ( this.keyboard.keys.shift && selection.from !== to) { |
673 | 668 | selection.to = to; |
674 | 669 | } else { |
675 | | - if ( selection.from !== selection.to ) { |
676 | | - this.documentView.clearSelection(); |
677 | | - } |
678 | 670 | selection.from = selection.to = to; |
679 | 671 | } |
680 | 672 | this.model.select( selection ); |