Filter out insertion annotations that aren't textStyle or link

This commit is contained in:
Trevor Parscal 2011-12-01 00:21:59 +00:00
parent 18681cb758
commit b3790de52d

View file

@ -144,6 +144,18 @@ es.SurfaceView.prototype.addInsertionAnnotation = function( annotation ) {
this.insertionAnnotations.push( annotation );
};
es.SurfaceView.prototype.loadInsertionAnnotations = function( annotation ) {
this.insertionAnnotations =
this.model.getDocument().getAnnotationsFromOffset( _this.currentSelection.to );
// Filter out annotations that aren't textStyles or links
for ( var i = 0; i < this.insertionAnnotations.length; i++ ) {
if ( !this.insertionAnnotations[i].type.match( /(textStyle\/|link\/)/ ) ) {
this.insertionAnnotations.splice( i, 1 );
i--;
}
}
};
es.SurfaceView.prototype.removeInsertionAnnotation = function( annotation ) {
var index = es.DocumentView.getIndexOfAnnotation( this.insertionAnnotations, annotation );
if ( index !== -1 ) {
@ -163,18 +175,15 @@ es.SurfaceView.prototype.updateSelection = function( delay ) {
var _this = this;
function update() {
if ( _this.currentSelection.from !== _this.currentSelection.to ) {
_this.clearInsertionAnnotations();
_this.hideCursor();
_this.documentView.drawSelection( _this.currentSelection );
// Update the context icon position
_this.contextView.update();
// Clear insertion annotations
_this.insertionAnnotations = [];
} else {
_this.loadInsertionAnnotations();
_this.showCursor();
_this.documentView.clearSelection( _this.currentSelection );
// Load new insertion annotations
_this.insertionAnnotations =
_this.model.getDocument().getAnnotationsFromOffset( _this.currentSelection.to );
}
_this.updateSelectionTimeout = undefined;
}