I think it’s the DecorateCallBack functions:
Related test:
To help debug by returning the content of the text on selection, you can console.log(_selectedText); after this line in a core file:
console.log(_selectedText);