Just a quick addition:
If you have line break characters in your string, those are not counted by the textIndex, but they are counted by the string, so then the selection of the final pipe character goes wrong.
If you need linebreaks in the string,
That can be fixed with:Just a quick addition:
If you have line break characters in your string, those are not counted by the textIndex, but they are counted by the string, so then the selection of the final pipe character goes wrong.
If you need linebreaks in the string,
That can be fixed with:
text.sourceText.value.replace(/\r/g,””).length;
(It replaces all linebreak characters with nothing before measuring the length of the string)