diff --git a/src/utils/utils.ts b/src/utils/utils.ts index 7a9bb4c68c..775e7a01f4 100644 --- a/src/utils/utils.ts +++ b/src/utils/utils.ts @@ -390,9 +390,13 @@ export function sanitizeEditableContent(element: any, cleanLineBreaks: boolean = selection.removeAllRanges(); selection.addRange(range); - for (let i = 0; i < innerText.length - tail_len; i++) { - (selection as any).modify("move", "forward", "character"); + while (selection.toString().length < innerText.length - tail_len) { + const selLen = selection.toString().length; + (selection as any).modify("extend", "forward", "character"); + if (selection.toString().length == selLen) break; } + range = selection.getRangeAt(0); + range.setStart(range.endContainer, range.endOffset); } } function mergeValues(src: any, dest: any) {