Rename methods to describe better what they are doing
clearAllMistakes and addMistake were not clearing mistakes or adding one. They merely manipulate the mistake markup.
This commit is contained in:
parent
7fc063650c
commit
f3f37fff02
@ -27,7 +27,7 @@ class BesEditor {
|
|||||||
if (this.isProofed(el)) {
|
if (this.isProofed(el)) {
|
||||||
return [{ text: '<' + el.tagName + '/>', el: el, markup: true }]
|
return [{ text: '<' + el.tagName + '/>', el: el, markup: true }]
|
||||||
}
|
}
|
||||||
this.clearAllMistakes(el)
|
this.clearMistakeMarkup(el)
|
||||||
let data = []
|
let data = []
|
||||||
for (const el2 of el.childNodes) {
|
for (const el2 of el.childNodes) {
|
||||||
data = data.concat(await this.proof(el2))
|
data = data.concat(await this.proof(el2))
|
||||||
@ -96,7 +96,7 @@ class BesEditor {
|
|||||||
|
|
||||||
matches.push({
|
matches.push({
|
||||||
range: range,
|
range: range,
|
||||||
rects: this.addMistake(range, match),
|
rects: this.addMistakeMarkup(range, match),
|
||||||
match: match
|
match: match
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@ -175,7 +175,7 @@ class BesEditor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Remove all grammar mistakes markup for given block element.
|
// Remove all grammar mistakes markup for given block element.
|
||||||
clearAllMistakes(el) {
|
clearMistakeMarkup(el) {
|
||||||
let filteredChildren = this.children.filter(child => child.elements === el)
|
let filteredChildren = this.children.filter(child => child.elements === el)
|
||||||
if (!filteredChildren.length) return
|
if (!filteredChildren.length) return
|
||||||
|
|
||||||
@ -197,7 +197,7 @@ class BesEditor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Adds grammar mistake markup
|
// Adds grammar mistake markup
|
||||||
addMistake(range, match) {
|
addMistakeMarkup(range, match) {
|
||||||
const clientRects = range.getClientRects()
|
const clientRects = range.getClientRects()
|
||||||
for (let i = 0, n = clientRects.length; i < n; ++i) {
|
for (let i = 0, n = clientRects.length; i < n; ++i) {
|
||||||
const rect = clientRects[i]
|
const rect = clientRects[i]
|
||||||
@ -301,9 +301,9 @@ window.onload = () => {
|
|||||||
window.onresize = () => {
|
window.onresize = () => {
|
||||||
besEditors.forEach(editor => {
|
besEditors.forEach(editor => {
|
||||||
editor.children.forEach(child => {
|
editor.children.forEach(child => {
|
||||||
editor.clearAllMistakes(child.elements)
|
editor.clearMistakeMarkup(child.elements)
|
||||||
child.matches.forEach(match => {
|
child.matches.forEach(match => {
|
||||||
match.rects = editor.addMistake(match.range, match)
|
match.rects = editor.addMistakeMarkup(match.range, match)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user