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.
*
* @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
*/
preparePopup(elMatch, source) {
preparePopup(hits, source) {
this.dismissPopup()
const popup = document.querySelector('bes-popup-el')
BesPopup.clearReplacements()
elMatch.forEach(({ el, match }) => {
hits.forEach(({ el, match }) => {
popup.setContent(el, match, this, this.isContentEditable())
this.highlightMistake(match)
})
@ -1521,19 +1521,19 @@ class BesTreeService extends BesService {
const canvasPanelRect = this.canvasPanel.getBoundingClientRect()
let x = source.clientX - canvasPanelRect.x
let y = source.clientY - canvasPanelRect.y
const pointsInRect = []
const hits = []
for (let result of this.results) {
for (let m of result.matches) {
for (let rect of m.highlights) {
if (BesService.isPointInRect(x, y, rect, 5)) {
pointsInRect.push({ el, match: m })
hits.push({ el, match: m })
break
}
}
}
}
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()
let x = source.clientX - canvasPanelRect.x
let y = source.clientY - canvasPanelRect.y
const pointsInRect = []
const hits = []
for (let result of this.results) {
for (let m of result.matches) {
for (let rect of m.highlights) {
if (BesService.isPointInRect(x, y, rect, 5)) {
pointsInRect.push({ el: result.range, match: m })
hits.push({ el: result.range, match: m })
break
}
}
}
}
this.dismissPopup()
if (pointsInRect.length) this.preparePopup(pointsInRect, source)
if (hits.length) this.preparePopup(hits, source)
}
/**