diff --git a/modules/es/tools/es.AnnotationButtonTool.js b/modules/es/tools/es.AnnotationButtonTool.js index b742a96e49..264b463bd9 100644 --- a/modules/es/tools/es.AnnotationButtonTool.js +++ b/modules/es/tools/es.AnnotationButtonTool.js @@ -7,7 +7,7 @@ es.AnnotationButtonTool.prototype.onClick = function() { var method; if ( this.$.hasClass( 'es-toolbarButtonTool-down' ) ) { method = 'clear'; - this.toolbar.surfaceView.clearInsertionAnnotations( this.data ); + this.toolbar.surfaceView.removeInsertionAnnotation( this.data ); } else { method = 'set'; this.toolbar.surfaceView.addInsertionAnnotation( this.data ); diff --git a/modules/es/views/es.SurfaceView.js b/modules/es/views/es.SurfaceView.js index f6fcb4c6a8..451583ed61 100644 --- a/modules/es/views/es.SurfaceView.js +++ b/modules/es/views/es.SurfaceView.js @@ -163,7 +163,7 @@ es.SurfaceView.prototype.loadInsertionAnnotations = function( annotation ) { }; es.SurfaceView.prototype.removeInsertionAnnotation = function( annotation ) { - var index = es.DocumentView.getIndexOfAnnotation( this.insertionAnnotations, annotation ); + var index = es.DocumentModel.getIndexOfAnnotation( this.insertionAnnotations, annotation ); if ( index !== -1 ) { this.insertionAnnotations.splice( index, 1 ); } @@ -619,8 +619,12 @@ es.SurfaceView.prototype.insertFromInput = function() { selection.from = selection.to = Math.min( selection.from, selection.to ); } - tx = this.model.getDocument().prepareInsertion( selection.from, val.split('') ); + var data = val.split(''); + es.DocumentModel.addAnnotationsToData( data, this.getInsertionAnnotations() ); + + tx = this.model.getDocument().prepareInsertion( selection.from, data ); this.model.transact( tx, true ); + selection.from += val.length; selection.to += val.length; this.model.select( selection, true );