Like I've said in my previous reply, directly changing any DocumentElement in a measured document is not recommended and could cause the behavior you are observing, as well as unexpected crashes.
As far as I can tell from the code snippet in your post, you are trying to insert specific content directly after the span where the caret is located, could you confirm? Please note that a Span element does not always correspond to a single word. For example, the following: ABCDEF
would be split into two separate spans because the characters have different styling.
As to retaining the caret position while executing actions, you can try an approach similar to the one from this forum thread
. Create a custom annotation marker and insert it at the caret position on demand, in the case of the demo when exporting and in yours - just before editing the string. Then move the caret to the desired location in order to insert the text, e.g. this snippet inserts at the end of the current word:
I hope this is useful.
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.