This commit is contained in:
Simon Rozman 2025-03-04 10:49:12 +01:00
parent 2b54735175
commit ef0d35ccee

View File

@ -1040,14 +1040,14 @@ class BesService {
/** /**
* Prepares and displays popup. * Prepares and displays popup.
* *
* @param {*} elMatch Array containing block element/paragraph containing grammar checking rule match and a match * @param {*} hits Array containing block element/paragraph containing grammar checking rule match and a match
* @param {PointerEvent} source Click event source * @param {PointerEvent} source Click event source
*/ */
preparePopup(elMatch, source) { preparePopup(hits, source) {
this.dismissPopup() this.dismissPopup()
const popup = document.querySelector('bes-popup-el') const popup = document.querySelector('bes-popup-el')
BesPopup.clearReplacements() BesPopup.clearReplacements()
elMatch.forEach(({ el, match }) => { hits.forEach(({ el, match }) => {
popup.setContent(el, match, this, this.isContentEditable()) popup.setContent(el, match, this, this.isContentEditable())
this.highlightMistake(match) this.highlightMistake(match)
}) })
@ -1521,19 +1521,19 @@ class BesTreeService extends BesService {
const canvasPanelRect = this.canvasPanel.getBoundingClientRect() const canvasPanelRect = this.canvasPanel.getBoundingClientRect()
let x = source.clientX - canvasPanelRect.x let x = source.clientX - canvasPanelRect.x
let y = source.clientY - canvasPanelRect.y let y = source.clientY - canvasPanelRect.y
const pointsInRect = [] const hits = []
for (let result of this.results) { for (let result of this.results) {
for (let m of result.matches) { for (let m of result.matches) {
for (let rect of m.highlights) { for (let rect of m.highlights) {
if (BesService.isPointInRect(x, y, rect, 5)) { if (BesService.isPointInRect(x, y, rect, 5)) {
pointsInRect.push({ el, match: m }) hits.push({ el, match: m })
break break
} }
} }
} }
} }
this.dismissPopup() this.dismissPopup()
if (pointsInRect.length) this.preparePopup(pointsInRect, source) if (hits.length) this.preparePopup(hits, source)
} }
} }
@ -2189,19 +2189,19 @@ class BesPlainTextService extends BesService {
const canvasPanelRect = this.canvasPanel.getBoundingClientRect() const canvasPanelRect = this.canvasPanel.getBoundingClientRect()
let x = source.clientX - canvasPanelRect.x let x = source.clientX - canvasPanelRect.x
let y = source.clientY - canvasPanelRect.y let y = source.clientY - canvasPanelRect.y
const pointsInRect = [] const hits = []
for (let result of this.results) { for (let result of this.results) {
for (let m of result.matches) { for (let m of result.matches) {
for (let rect of m.highlights) { for (let rect of m.highlights) {
if (BesService.isPointInRect(x, y, rect, 5)) { if (BesService.isPointInRect(x, y, rect, 5)) {
pointsInRect.push({ el: result.range, match: m }) hits.push({ el: result.range, match: m })
break break
} }
} }
} }
} }
this.dismissPopup() this.dismissPopup()
if (pointsInRect.length) this.preparePopup(pointsInRect, source) if (hits.length) this.preparePopup(hits, source)
} }
/** /**