diff --git a/src/services/webpage.service.ts b/src/services/webpage.service.ts index 08616ca..b7ccee3 100644 --- a/src/services/webpage.service.ts +++ b/src/services/webpage.service.ts @@ -41,7 +41,7 @@ module tagIt { this.tagStorageService.deleteTagById(evt.target.parentElement.id); } else if (this.findSelectedText()) { - updateSavedSelection(); + this.updateSavedSelection(); callbackOnSelectFunc(joinLongWords(this.findSelectedText())); } else { callbackOnDeSelectFunc(); @@ -59,12 +59,6 @@ module tagIt { theSurroundingSpanElement.parentNode .replaceChild(theOriginalTextNode, theSurroundingSpanElement); } - function updateSavedSelection() { - if (this.savedSelection) { - rangy.removeMarkers(this.savedSelection); - } - this.savedSelection = rangy.saveSelection(); - } } findSelectedText() { @@ -85,7 +79,7 @@ module tagIt { range, true, document.getElementById('tagit-body')); var generatedUuid: string = uuid.v4(); var parentElement = range.commonAncestorContainer; - + return { id: generatedUuid, userEmail: 'testEmail', @@ -154,6 +148,13 @@ module tagIt { } } } + + private updateSavedSelection() { + if (this.savedSelection) { + rangy.removeMarkers(this.savedSelection); + } + this.savedSelection = rangy.saveSelection(); + } private surroundRangeWithSpan(sense: ISense, range: Range, uuid: string) { // add span around content