Apply JS formatter

This commit is contained in:
Aljaž Grilc 2024-02-07 09:08:53 +01:00
parent f3f37fff02
commit dd5a6ff85b

View File

@ -7,11 +7,7 @@ class BesEditor {
this.children = []
this.correctionPanel = document.getElementById('correction-panel') // TODO: use document.createElement('div') and insert it before edit element in DOM.
this.proof(edit)
edit.addEventListener(
'beforeinput',
e => this.handleBeforeInput(e),
false
)
edit.addEventListener('beforeinput', e => this.handleBeforeInput(e), false)
edit.addEventListener('click', e => this.handleClick(e))
}
@ -20,7 +16,7 @@ class BesEditor {
switch (el.nodeType) {
case Node.TEXT_NODE:
return [{ text: el.textContent, el: el, markup: false }]
case Node.ELEMENT_NODE:
if (BesEditor.isBlockElement(el)) {
// Block elements are grammar-proofed independently.
@ -60,7 +56,7 @@ class BesEditor {
let matches = []
responseData.matches.forEach(match => {
let range = document.createRange()
// Locate start of the grammar mistake.
for (
let idx = 0, startingOffset = 0;
@ -72,11 +68,14 @@ class BesEditor {
/*startingOffset <= match.offset &&*/ match.offset <
startingOffset + data[idx].text.length
) {
range.setStart(data[idx].el, match.offset - startingOffset)
range.setStart(
data[idx].el,
match.offset - startingOffset
)
break
}
}
// Locate end of the grammar mistake.
let endOffset = match.offset + match.length
for (
@ -93,14 +92,14 @@ class BesEditor {
break
}
}
matches.push({
range: range,
rects: this.addMistakeMarkup(range, match),
match: match
})
})
this.markProofed(el, matches)
})
.catch(error => {
@ -123,7 +122,7 @@ class BesEditor {
})
return data
}
default:
return [{ text: '<?' + el.nodeType + '>', el: el, markup: true }]
}
@ -231,7 +230,8 @@ class BesEditor {
// Returns first block parent element
getBlockParent(el) {
for (; el && el !== this.el; el = el.parentNode) {
if (el.nodeType === Node.ELEMENT_NODE && BesEditor.isBlockElement(el)) return el
if (el.nodeType === Node.ELEMENT_NODE && BesEditor.isBlockElement(el))
return el
}
return el
}
@ -277,7 +277,7 @@ class BesEditor {
}
return false
}
static isPointInRect(x, y, rect) {
return (
x >= rect.x &&