Using getRelativeContentOffset for insertAnnotations

Previously, we were looking one offset to the left to load the insertAnnotations. This would fail at the beginning of a document that began with a slug, and probably other cases too. Now using getRelativeContent offset.

Change-Id: I31b24e2ccfa9fda2ce7fb19d1221f8708a96083f
This commit is contained in:
Christian Williams 2012-10-01 13:43:27 -07:00
parent 4ae9096632
commit 75c154ef6c

View file

@ -120,7 +120,8 @@ ve.dm.Surface.prototype.change = function ( transactions, selection ) {
// Clear and add annotations to stack if insertingAnnotations isn't happening
if (!this.insertingAnnotations) {
var annotations = this.documentModel.getAnnotationsFromOffset( this.getSelection().start - 1 );
var contentOffset = this.documentModel.getNearestContentOffset( this.getSelection().start - 1, -1 ),
annotations = this.documentModel.getAnnotationsFromOffset( contentOffset );
// Reset insertAnnotations
this.documentModel.insertAnnotations = new ve.AnnotationSet();