Index: trunk/extensions/VisualEditor/modules/es/views/es.SurfaceView.js |
— | — | @@ -144,6 +144,18 @@ |
145 | 145 | this.insertionAnnotations.push( annotation ); |
146 | 146 | }; |
147 | 147 | |
| 148 | +es.SurfaceView.prototype.loadInsertionAnnotations = function( annotation ) { |
| 149 | + this.insertionAnnotations = |
| 150 | + this.model.getDocument().getAnnotationsFromOffset( _this.currentSelection.to ); |
| 151 | + // Filter out annotations that aren't textStyles or links |
| 152 | + for ( var i = 0; i < this.insertionAnnotations.length; i++ ) { |
| 153 | + if ( !this.insertionAnnotations[i].type.match( /(textStyle\/|link\/)/ ) ) { |
| 154 | + this.insertionAnnotations.splice( i, 1 ); |
| 155 | + i--; |
| 156 | + } |
| 157 | + } |
| 158 | +}; |
| 159 | + |
148 | 160 | es.SurfaceView.prototype.removeInsertionAnnotation = function( annotation ) { |
149 | 161 | var index = es.DocumentView.getIndexOfAnnotation( this.insertionAnnotations, annotation ); |
150 | 162 | if ( index !== -1 ) { |
— | — | @@ -163,18 +175,15 @@ |
164 | 176 | var _this = this; |
165 | 177 | function update() { |
166 | 178 | if ( _this.currentSelection.from !== _this.currentSelection.to ) { |
| 179 | + _this.clearInsertionAnnotations(); |
167 | 180 | _this.hideCursor(); |
168 | 181 | _this.documentView.drawSelection( _this.currentSelection ); |
169 | 182 | // Update the context icon position |
170 | 183 | _this.contextView.update(); |
171 | | - // Clear insertion annotations |
172 | | - _this.insertionAnnotations = []; |
173 | 184 | } else { |
| 185 | + _this.loadInsertionAnnotations(); |
174 | 186 | _this.showCursor(); |
175 | 187 | _this.documentView.clearSelection( _this.currentSelection ); |
176 | | - // Load new insertion annotations |
177 | | - _this.insertionAnnotations = |
178 | | - _this.model.getDocument().getAnnotationsFromOffset( _this.currentSelection.to ); |
179 | 188 | } |
180 | 189 | _this.updateSelectionTimeout = undefined; |
181 | 190 | } |