diff --git a/service.js b/service.js index f43ded7..2ebf4d9 100644 --- a/service.js +++ b/service.js @@ -198,7 +198,7 @@ class BesService { */ setMarkupStyle(style) { this.markupStyle = style - this.repositionAllMarkup() + this.redrawAllMistakeMarkup() } /** @@ -358,7 +358,7 @@ class BesService { * * @param {*} match Grammar checking rule match */ - addMistakeMarkup(match) { + drawMistakeMarkup(match) { const range = match.range const canvasPanelRect = this.canvasPanel.getBoundingClientRect() const scrollX = canvasPanelRect.left @@ -893,7 +893,7 @@ class BesService { ) { this.canvasPanel.width = newCanvasWidth this.canvasPanel.height = newCanvasHeight - this.repositionAllMarkup() + this.redrawAllMistakeMarkup() } if (this.isHostElementInline()) { const totalWidth = @@ -975,12 +975,12 @@ class BesService { } /** - * Updates all grammar mistake markup positions. + * Redraws all grammar mistake markup. */ - repositionAllMarkup() { + redrawAllMistakeMarkup() { this.ctx.clearRect(0, 0, this.canvasPanel.width, this.canvasPanel.height) this.results.forEach(result => { - result.matches.forEach(match => this.addMistakeMarkup(match)) + result.matches.forEach(match => this.drawMistakeMarkup(match)) }) } @@ -1136,7 +1136,7 @@ class BesTreeService extends BesService { ), match: match } - this.addMistakeMarkup(m) + this.drawMistakeMarkup(m) matches.push(m) }) this.markProofed(node, matches) @@ -1221,7 +1221,7 @@ class BesTreeService extends BesService { this.results = this.results.filter( result => !BesTreeService.isSameParagraph(result.element, el) ) - this.repositionAllMarkup() + this.redrawAllMistakeMarkup() } /** @@ -1453,7 +1453,7 @@ class BesDOMService extends BesTreeService { */ onInput() { // Now that the text is done changing, we can correctly calculate markup position. - this.repositionAllMarkup() + this.redrawAllMistakeMarkup() this.dismissPopup() // Defer grammar-checking to reduce stress on grammar-checking server. this.scheduleProofing(1000) @@ -1535,7 +1535,7 @@ class BesCKService extends BesTreeService { // element, it will not be updated immediately. setTimeout(() => { // Now that the text is done changing, we can correctly calculate markup position. - this.repositionAllMarkup() + this.redrawAllMistakeMarkup() // Defer grammar-checking to reduce stress on grammar-checking server. this.scheduleProofing(1000) @@ -1702,7 +1702,7 @@ class BesQuillService extends BesTreeService { this.clearProofing(domElement) setTimeout(() => { - this.repositionAllMarkup() + this.redrawAllMistakeMarkup() this.scheduleProofing(1000) }, 0) } @@ -1888,7 +1888,7 @@ class BesPlainTextService extends BesService { ), match: match } - this.addMistakeMarkup(m) + this.drawMistakeMarkup(m) matches.push(m) }) this.markProofed(paragraphRange, matches) @@ -1979,7 +1979,7 @@ class BesPlainTextService extends BesService { this.results = this.results.filter( result => !BesPlainTextService.isSameParagraph(result.range, range) ) - this.repositionAllMarkup() + this.redrawAllMistakeMarkup() } /** @@ -2148,7 +2148,7 @@ class BesDOMPlainTextService extends BesPlainTextService { delete this.textBeforeChange // Now that the text is done changing, we can correctly calculate markup position. - this.repositionAllMarkup() + this.redrawAllMistakeMarkup() this.dismissPopup() // Defer grammar-checking to reduce stress on grammar-checking server. this.scheduleProofing(1000) @@ -2417,7 +2417,7 @@ class BesTAService extends BesPlainTextService { }) // Now that the text is done changing, we can correctly calculate markup position. - this.repositionAllMarkup() + this.redrawAllMistakeMarkup() // Defer grammar-checking to reduce stress on grammar-checking server. this.scheduleProofing(1000)