Fix: updating savedSelection removes previous rangy marker. Is now able to tag multiple tags. But need to figure out how to add them all back to the page in the right places. As soon as one starts adding new content to the html it throws of the addition of the other tags.

This commit is contained in:
Nils Norman Haukås 2015-11-29 20:26:20 +01:00
parent d5d3518b5b
commit a69d801aaf

View file

@ -38,7 +38,7 @@ module tagIt {
this.tagStorageService.deleteTagById(evt.target.parentElement.id);
}
else if (this.findSelectedText()) {
this.savedSelection = rangy.saveSelection();
this.updateSavedSelection();
callbackOnSelectFunc(joinLongWords(this.findSelectedText()));
} else {
callbackOnDeSelectFunc();
@ -83,7 +83,7 @@ module tagIt {
rangy.removeMarkers(this.savedSelection);
var range = rangy.getSelection().getRangeAt(0);
var serializedRange = rangy.serializeRange(
range, false, document.getElementById('tagit-body'));
range, true, document.getElementById('tagit-body'));
var generatedUuid: string = uuid.v4();
// this.surroundRangeWithSpan(sense, range, generatedUuid);
@ -96,7 +96,7 @@ module tagIt {
serializedSelectionRange: serializedRange
}
};
removeAllTagsFromPage() {
// find all tags
var elements = document.getElementsByClassName('tagit-tag');
@ -161,6 +161,13 @@ module tagIt {
return deserializedRange;
}
}
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