getIndexOfAnnotation is method of DocumentModel. not DocumentView

This commit is contained in:
Inez Korczynski 2011-12-01 01:10:38 +00:00
parent 0f123a6d2f
commit 7bc84d8cf4
2 changed files with 7 additions and 3 deletions

View file

@ -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 );

View file

@ -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 );