From 7bc84d8cf4b2dd247e3bf1426d45c54b2103b3ef Mon Sep 17 00:00:00 2001 From: Inez Korczynski Date: Thu, 1 Dec 2011 01:10:38 +0000 Subject: [PATCH] getIndexOfAnnotation is method of DocumentModel. not DocumentView --- modules/es/tools/es.AnnotationButtonTool.js | 2 +- modules/es/views/es.SurfaceView.js | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) 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 );