Prevent nested ternary expressions (#18376)

Co-authored-by: Pascal Jufer <pascal-jufer@bluewin.ch>
This commit is contained in:
Brainslug
2023-05-01 21:07:40 +02:00
committed by GitHub
parent 3ff71cc34a
commit 87f2edc735
9 changed files with 82 additions and 39 deletions

View File

@@ -228,8 +228,13 @@ function parseHTML(innerText?: string, isDirectInput = false) {
}
let newHTML = input.value.innerText;
let caretPos = 0;
const caretPos = isDirectInput ? previousCaretPos : window.getSelection()?.rangeCount ? position(input.value).pos : 0;
if (isDirectInput) {
caretPos = previousCaretPos;
} else if (window.getSelection()?.rangeCount) {
caretPos = position(input.value).pos;
}
let lastMatchIndex = 0;
const matches = newHTML.match(new RegExp(`${props.captureGroup}(?!</mark>)`, 'gi'));