Fix highlight positioning when scrolling

This commit is contained in:
Aljaž Grilc 2025-02-27 08:43:12 +01:00
parent ad13e9849f
commit 5d8b620abc

View File

@ -699,7 +699,6 @@ class BesService {
* @param {*} match Grammar checking rule match
*/
highlightMistake(match) {
// TODO: Če sta 2 napaki v istem rectu, se prikaže samo zgornja/zadnja (oz. tista, ki jo uporabnik klikne). To pa pomeni, da se lahko podčrtana barva razlikuje od "highlight" barve.
match.highlights.forEach(rect => {
const el = document.createElement('div')
el.classList.add('bes-highlight-rect')
@ -708,8 +707,8 @@ class BesService {
? 'bes-highlight-spelling-rect'
: 'bes-highlight-grammar-rect'
)
el.style.left = `${rect.x}px`
el.style.top = `${rect.y}px`
el.style.left = `${rect.x + window.scrollX}px`
el.style.top = `${rect.y + window.scrollY}px`
el.style.width = `${rect.width}px`
el.style.height = `${rect.height}px`
document.body.appendChild(el)
@ -1792,7 +1791,6 @@ class BesPlainTextService extends BesService {
for (let m of result.matches) {
for (let rect of m.highlights) {
if (BesService.isPointInRect(source.clientX, source.clientY, rect)) {
console.log(result.range)
pointsInRect.push({ el: result.range, match: m })
}
}