Quill’s getSelection returns different number than index of html text content

Sorry about the confusing title, but what I mean is getSelection gives the number of characters on screen shown in the Quill text editor.

But the html string containing the html markdown of the editor text contains all the tags so it gets confusing when you’re trying to concatenate text auto-complete suggestions.

How can one remedy this?