getCaretIndex = function (e) {
    let d;

    if (this.config.root) {
        d = this.config.root;
    } else {
        d = window;
    }
    let pos = 0;
    const s = d.getSelection();
    if (s) {
        if (s.rangeCount !== 0) {
            const r = s.getRangeAt(0);
            const p = r.cloneRange();
            p.selectNodeContents(e);
            p.setEnd(r.endContainer, r.endOffset);
            pos = p.toString().length;
        }
    }
    return pos;
}
Get carret position for one element