I have underlined the word through my JS add-in code by updating the Ooxml value, and to identify that word I have used the bookmark, (added the underline inside the bookmark).
The issue I’m facing is when I manually edit the underlined word from its end, the underline continues to the newly added characters, but the bookmark is not updated as it contains only the previously present characters.
But as later I use the bookmark to remove the underlines of the word, then it only removes the underline for the characters present inside the bookmark. and the newly added characters underline remains as it is.
Example:
DocumentText = "Hey my name is Microsofty"
UnderlinedWord = "Microsofty"
Now here I have added the bookmark with underline to the word “Microsoft” and inserted back in document:
bookmark_of_Microsofty = <w:bookmarkStart w:id="0" w:name="S10000"/><w:r><w:rPr><w:u w:val="wave" w:color="EF0018"/></w:rPr><w:t>Microsofty</w:t></w:r><w:bookmarkEnd w:id="0"/>
I go and manually edit the word “Microsofty” to “Microsoft-company” by erasing “y” and adding “-company” to it, and then remove the bookmark.
So after removing the bookmark it only removed the underline till “Microsoft” and other remained as it is. (check attached screen-shots).
So how can I resolve this issue, the underline gets continued but the bookmark remains only to the originally added word, and when I try to remove the underline through bookmark it only removes half.
I tried by manipulating the ooxml value of paragraph, but its complex and may create issues in future.
I’m expecting that when I remove the bookmark it should remove the underline of whole updated word.