diff --git a/service.js b/service.js index 0e3026d..5f312ba 100644 --- a/service.js +++ b/service.js @@ -454,13 +454,14 @@ class BesService { * @param {*} match Grammar checking rule match * @param {PointerEvent} source Click event source */ - popupCorrectionPanel(el, match, source) { + popupCorrectionPanel(pointsInRect, source) { this.dismissPopup() const popup = document.querySelector('bes-popup-el') - // TODO: popup.setContent(elements, matches, this, this.isContentEditable()) - popup.changeMessage(match.match.message) - popup.appendReplacements(el, match, this, this.isContentEditable()) - this.highlightMistake(match) + BesPopup.clearReplacements() + pointsInRect.forEach(({ el, match }) => { + popup.setContent(el, match, this, this.isContentEditable()) + this.highlightMistake(match) + }) popup.show(source.clientX, source.clientY) } @@ -910,18 +911,18 @@ class BesTreeService extends BesService { const source = event?.detail !== 1 ? event?.detail : event const el = this.getBlockParent(source.targetElement || source.target) if (!el) return - + const pointsInRect = [] for (let result of this.results) { for (let m of result.matches) { for (let rect of m.highlights) { if (BesService.isPointInRect(source.clientX, source.clientY, rect)) { - this.popupCorrectionPanel(el, m, source) - return + pointsInRect.push({ el, match: m }) } } } } this.dismissPopup() + if (pointsInRect.length) this.popupCorrectionPanel(pointsInRect, source) } } @@ -1563,18 +1564,19 @@ class BesPlainTextService extends BesService { const source = event?.detail !== 1 ? event?.detail : event const el = source.targetElement || source.target || this.hostElement if (!el) return - + const pointsInRect = [] for (let result of this.results) { for (let m of result.matches) { for (let rect of m.highlights) { if (BesService.isPointInRect(source.clientX, source.clientY, rect)) { - this.popupCorrectionPanel(result.range, m, source) - return + console.log(result.range) + pointsInRect.push({ el: result.range, match: m }) } } } } this.dismissPopup() + if (pointsInRect.length) this.popupCorrectionPanel(pointsInRect, source) } /** @@ -2043,6 +2045,7 @@ class BesPopup extends HTMLElement { background-color: #eee; padding: 10px; border-radius: 5px; + border: 1px solid #f1f3f9; } .bes-replacement-btn{ margin: 4px 1px; @@ -2083,6 +2086,7 @@ class BesPopup extends HTMLElement { .bes-text-div { font-weight: lighter; background-color: #333; + border: 1px solid #57585A; } } @@ -2091,12 +2095,6 @@ class BesPopup extends HTMLElement {