Index: trunk/extensions/VisualEditor/modules/es/tools/es.FormatDropdownTool.js |
— | — | @@ -68,7 +68,9 @@ |
69 | 69 | item.type, |
70 | 70 | item.attributes |
71 | 71 | ); |
72 | | - this.toolbar.surfaceView.model.transact( txs ); |
| 72 | + for ( var i = 0; i < txs.length; i++ ) { |
| 73 | + this.toolbar.surfaceView.model.transact( txs[i] ); |
| 74 | + } |
73 | 75 | }; |
74 | 76 | |
75 | 77 | es.FormatDropdownTool.prototype.updateState = function( annotations, nodes ) { |
Index: trunk/extensions/VisualEditor/modules/es/tools/es.ListButtonTool.js |
— | — | @@ -29,7 +29,7 @@ |
30 | 30 | insertAt, |
31 | 31 | removeLength, |
32 | 32 | data, |
33 | | - txs = [], |
| 33 | + tx, |
34 | 34 | i, |
35 | 35 | j; |
36 | 36 | |
— | — | @@ -82,12 +82,13 @@ |
83 | 83 | styles = listItems[i].getElementAttribute( 'styles' ); |
84 | 84 | if ( styles[styles.length - 1] !== style ) { |
85 | 85 | styles.splice( styles.length - 1, 1, style ); |
86 | | - txs.push( surface.model.getDocument().prepareElementAttributeChange( |
| 86 | + tx = surface.model.getDocument().prepareElementAttributeChange( |
87 | 87 | surface.documentView.model.getOffsetFromNode( listItems[i], false ), |
88 | 88 | 'set', |
89 | 89 | 'styles', |
90 | 90 | styles |
91 | | - ) ); |
| 91 | + ); |
| 92 | + surface.model.transact( tx ); |
92 | 93 | } |
93 | 94 | } |
94 | 95 | |
— | — | @@ -112,12 +113,16 @@ |
113 | 114 | } |
114 | 115 | data = data.concat( [ { 'type': '/list' } ] ); |
115 | 116 | |
116 | | - txs.push( surface.model.getDocument().prepareInsertion( insertAt, data ) ); |
117 | | - txs.push( surface.model.getDocument().prepareRemoval( |
| 117 | + tx = surface.model.getDocument().prepareInsertion( insertAt, data ); |
| 118 | + surface.model.transact( tx ); |
| 119 | + |
| 120 | + tx = surface.model.getDocument().prepareRemoval( |
118 | 121 | new es.Range( insertAt + data.length, insertAt + removeLength + data.length ) |
119 | | - ) ); |
| 122 | + ); |
| 123 | + surface.model.transact( tx ); |
| 124 | + |
120 | 125 | } |
121 | | - surface.model.transact( txs ); |
| 126 | + |
122 | 127 | surface.model.select( selection, true ); |
123 | 128 | }; |
124 | 129 | |
Index: trunk/extensions/VisualEditor/modules/es/models/es.SurfaceModel.js |
— | — | @@ -120,14 +120,6 @@ |
121 | 121 | * (such as when replacing - delete, then insert) |
122 | 122 | */ |
123 | 123 | es.SurfaceModel.prototype.transact = function( transaction, isPartial ) { |
124 | | - |
125 | | - if(es.isArray(transaction)) { |
126 | | - for( var i = 0; i < transaction.length; i++ ) { |
127 | | - this.transact( transaction[i] ); |
128 | | - } |
129 | | - return; |
130 | | - } |
131 | | - |
132 | 124 | // console.log( 'tx:' + $.map( transaction.getOperations(), function(tx) { return tx.type; } ).join(",") |
133 | 125 | // + ' isPartial:' + isPartial ); |
134 | 126 | this.doc.commit( transaction ); |
Index: trunk/extensions/VisualEditor/modules/es/views/es.SurfaceView.js |
— | — | @@ -613,15 +613,13 @@ |
614 | 614 | }, 10 ); |
615 | 615 | }; |
616 | 616 | |
617 | | -es.SurfaceView.prototype.handleDelete = function( backspace, notExecute ) { |
| 617 | +es.SurfaceView.prototype.handleDelete = function( backspace, isPartial ) { |
618 | 618 | var selection = this.currentSelection.clone(), |
619 | 619 | sourceOffset, |
620 | 620 | targetOffset, |
621 | 621 | sourceSplitableNode, |
622 | 622 | targetSplitableNode, |
623 | | - tx, |
624 | | - txs = []; |
625 | | - |
| 623 | + tx; |
626 | 624 | if ( selection.from === selection.to ) { |
627 | 625 | if ( backspace ) { |
628 | 626 | sourceOffset = selection.to; |
— | — | @@ -651,13 +649,15 @@ |
652 | 650 | if ( sourceNode === targetNode || |
653 | 651 | ( typeof sourceSplitableNode !== 'undefined' && |
654 | 652 | sourceSplitableNode.getParent() === targetSplitableNode.getParent() ) ) { |
655 | | - txs.push( this.model.getDocument().prepareRemoval( |
| 653 | + tx = this.model.getDocument().prepareRemoval( |
656 | 654 | new es.Range( targetOffset, sourceOffset ) |
657 | | - ) ); |
| 655 | + ); |
| 656 | + this.model.transact( tx, isPartial ); |
658 | 657 | } else { |
659 | | - txs.push( this.model.getDocument().prepareInsertion( |
| 658 | + tx = this.model.getDocument().prepareInsertion( |
660 | 659 | targetOffset, sourceNode.model.getContentData() |
661 | | - ) ); |
| 660 | + ); |
| 661 | + this.model.transact( tx, isPartial ); |
662 | 662 | |
663 | 663 | var nodeToDelete = sourceNode; |
664 | 664 | es.DocumentNode.traverseUpstream( nodeToDelete, function( node ) { |
— | — | @@ -671,31 +671,23 @@ |
672 | 672 | var range = new es.Range(); |
673 | 673 | range.from = this.documentView.getOffsetFromNode( nodeToDelete, false ); |
674 | 674 | range.to = range.from + nodeToDelete.getElementLength(); |
675 | | - txs.push( this.model.getDocument().prepareRemoval( range ) ); |
| 675 | + tx = this.model.getDocument().prepareRemoval( range ); |
| 676 | + this.model.transact( tx, isPartial ); |
676 | 677 | } |
677 | | - if ( notExecute ) { |
678 | | - return txs; |
679 | | - } else { |
680 | | - this.model.transact( txs ); |
681 | | - } |
682 | 678 | } else { |
683 | 679 | // selection removal |
684 | 680 | tx = this.model.getDocument().prepareRemoval( selection ); |
| 681 | + this.model.transact( tx, isPartial ); |
685 | 682 | selection.from = selection.to = selection.start; |
686 | 683 | this.model.select( selection ); |
687 | | - if ( notExecute ) { |
688 | | - return [tx]; |
689 | | - } else { |
690 | | - this.model.transact( tx ); |
691 | | - } |
692 | 684 | } |
693 | 685 | }; |
694 | 686 | |
695 | 687 | es.SurfaceView.prototype.handleEnter = function() { |
696 | 688 | var selection = this.currentSelection.clone(), |
697 | | - txs = []; |
| 689 | + tx; |
698 | 690 | if ( selection.from !== selection.to ) { |
699 | | - txs.concat( this.handleDelete( false, true ) ); |
| 691 | + this.handleDelete( false, true ); |
700 | 692 | } |
701 | 693 | var node = this.documentView.getNodeFromOffset( selection.to, false ), |
702 | 694 | nodeOffset = this.documentView.getOffsetFromNode( node, false ); |
— | — | @@ -704,11 +696,11 @@ |
705 | 697 | nodeOffset + node.getContentLength() + 1 === selection.to && |
706 | 698 | node === es.DocumentViewNode.getSplitableNode( node ) |
707 | 699 | ) { |
708 | | - txs.push( this.documentView.model.prepareInsertion( |
| 700 | + tx = this.documentView.model.prepareInsertion( |
709 | 701 | nodeOffset + node.getElementLength(), |
710 | 702 | [ { 'type': 'paragraph' }, { 'type': '/paragraph' } ] |
711 | | - ) ); |
712 | | - this.model.transact( txs ); |
| 703 | + ); |
| 704 | + this.model.transact( tx ); |
713 | 705 | selection.from = selection.to = nodeOffset + node.getElementLength() + 1; |
714 | 706 | } else { |
715 | 707 | var stack = [], |
— | — | @@ -734,8 +726,8 @@ |
735 | 727 | splitable = es.DocumentView.splitRules[ elementType ].self; |
736 | 728 | return true; |
737 | 729 | } ); |
738 | | - txs.push( this.documentView.model.prepareInsertion( selection.to, stack ) ); |
739 | | - this.model.transact( txs ); |
| 730 | + tx = this.documentView.model.prepareInsertion( selection.to, stack ); |
| 731 | + this.model.transact( tx ); |
740 | 732 | selection.from = selection.to = |
741 | 733 | this.model.getDocument().getRelativeContentOffset( selection.to, 1 ); |
742 | 734 | } |
— | — | @@ -764,15 +756,17 @@ |
765 | 757 | this.$input.val( '' ); |
766 | 758 | |
767 | 759 | // Prepare and process a transaction |
768 | | - var txs = []; |
| 760 | + var tx; |
769 | 761 | if ( selection.from != selection.to ) { |
770 | | - txs.push( this.model.getDocument().prepareRemoval( selection ) ); |
771 | | - selection.from = selection.to = Math.min( selection.from, selection.to ); |
| 762 | + tx = this.model.getDocument().prepareRemoval( selection ); |
| 763 | + this.model.transact( tx, true ); |
| 764 | + selection.from = selection.to = |
| 765 | + Math.min( selection.from, selection.to ); |
772 | 766 | } |
773 | 767 | var data = val.split(''); |
774 | 768 | es.DocumentModel.addAnnotationsToData( data, this.getInsertionAnnotations() ); |
775 | | - txs.push( this.model.getDocument().prepareInsertion( selection.from, data ) ); |
776 | | - this.model.transact( txs ); |
| 769 | + tx = this.model.getDocument().prepareInsertion( selection.from, data ); |
| 770 | + this.model.transact( tx ); |
777 | 771 | |
778 | 772 | // Move the selection |
779 | 773 | selection.from += val.length; |