Set cursor pos in contenteditable innerHTML

I saw this question

Contenteditable Div – Cursor position in terms of innerHTML position

with an answer that worked perfectly, but now I just need something that can set cursor position while including length of element tags, or maybe something that would just count and add the length of tags before the pos I’m trying to set the cursor.

I tried using the regular method of setting cursor pos in a contenteditable but it didn’t work obviously as it doesn’t consider element tag lengths.