Index: trunk/extensions/VisualEditor/modules/ve/ce/ve.ce.Surface.js |
— | — | @@ -24,6 +24,7 @@ |
25 | 25 | .append( this.documentView.$ ); |
26 | 26 | this.emitUpdateTimeout = undefined; |
27 | 27 | this.clipboard = {}; |
| 28 | + this.autoRender = false; |
28 | 29 | |
29 | 30 | // Events |
30 | 31 | this.documentView.$.bind( { |
— | — | @@ -95,9 +96,11 @@ |
96 | 97 | var tx = this.model.getDocument().prepareContentAnnotation( |
97 | 98 | range, method, annotation |
98 | 99 | ); |
| 100 | + |
| 101 | + this.autoRender = true; |
99 | 102 | this.model.transact( tx ); |
100 | | - // re-render Node |
101 | | - this.renderDomNode ( rangy.getSelection().anchorNode ); |
| 103 | + this.autoRender = false; |
| 104 | + |
102 | 105 | } else { |
103 | 106 | if ( method === 'set' ) { |
104 | 107 | this.addInsertionAnnotation( annotation ); |
— | — | @@ -160,16 +163,15 @@ |
161 | 164 | setTimeout( function() { |
162 | 165 | var key = $('#paste').hide().text().replace( /\s/gm, '' ); |
163 | 166 | |
164 | | - if ( _this.clipboard[key] ) { |
| 167 | + if ( _this.clipboard[key] ) { |
165 | 168 | // transact |
166 | 169 | var tx = _this.documentView.model.prepareInsertion( |
167 | 170 | insertionPoint, _this.clipboard[key] |
168 | 171 | ); |
| 172 | + _this.autoRender = true; |
169 | 173 | _this.model.transact( tx ); |
| 174 | + _this.autoRender = false; |
170 | 175 | |
171 | | - // re-render |
172 | | - _this.getLeafNode( node ).data( 'view' ).renderContent(); |
173 | | - |
174 | 176 | // clear the prev information from poll object (probably a better way to do this) |
175 | 177 | _this.poll.prevText = |
176 | 178 | _this.poll.prevHash = |
Index: trunk/extensions/VisualEditor/modules/ve/ce/ve.ce.Content.js |
— | — | @@ -1,16 +1,22 @@ |
2 | | -ve.ce.Content = function( $container, model ) { |
| 2 | +ve.ce.Content = function( model, $container, parent ) { |
3 | 3 | // Inheritance |
4 | 4 | ve.EventEmitter.call( this ); |
5 | 5 | |
6 | 6 | // Properties |
7 | 7 | this.$ = $container; |
8 | 8 | this.model = model; |
| 9 | + this.parent = parent; |
9 | 10 | |
10 | 11 | if ( model ) { |
11 | 12 | // Events |
12 | 13 | var _this = this; |
| 14 | + |
13 | 15 | this.model.on( 'update', function( offset ) { |
14 | | - //_this.render( offset || 0 ); |
| 16 | + var surfaceView = _this.getSurfaceView(); |
| 17 | + |
| 18 | + if (surfaceView.autoRender) { |
| 19 | + _this.render( offset || 0 ); |
| 20 | + } |
15 | 21 | } ); |
16 | 22 | } |
17 | 23 | }; |
— | — | @@ -236,6 +242,14 @@ |
237 | 243 | return out; |
238 | 244 | }; |
239 | 245 | |
| 246 | +ve.ce.Content.prototype.getSurfaceView = function() { |
| 247 | + var view = this; |
| 248 | + while(!view.surfaceView) { |
| 249 | + view = view.parent; |
| 250 | + } |
| 251 | + return view.surfaceView; |
| 252 | +} |
| 253 | + |
240 | 254 | /* Inheritance */ |
241 | 255 | |
242 | 256 | ve.extendClass( ve.ce.Content, ve.EventEmitter ); |
\ No newline at end of file |
Index: trunk/extensions/VisualEditor/modules/ve/ce/ve.ce.LeafNode.js |
— | — | @@ -18,7 +18,7 @@ |
19 | 19 | this.$.addClass('ce-leafNode'); |
20 | 20 | |
21 | 21 | // Properties |
22 | | - this.contentView = new ve.ce.Content( this.$, model ); |
| 22 | + this.contentView = new ve.ce.Content( model, this.$, this ); |
23 | 23 | |
24 | 24 | // Events |
25 | 25 | this.contentView.on( 'update', this.emitUpdate ); |