0👍
Found a workaround by getting the selected text length and setting end = start + selTextLength:
const selectedText = window.getSelection().toString()
const selTextLength = selectedText.length
const start = selection.anchorOffset
const end = start + selTextLength
Source:stackexchange.com