Skip to content

Commit

Permalink
fix: on highlightText dispatch a change event
Browse files Browse the repository at this point in the history
  • Loading branch information
arddor authored and marcbachmann committed Jun 28, 2024
1 parent e4f86a4 commit 240d82b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ export class Editable {
*/
highlight ({editableHost, text, highlightId, textRange, raiseEvents, type = 'comment'}) {
if (!textRange) {
return highlightSupport.highlightText(editableHost, text, highlightId, type)
return highlightSupport.highlightText(editableHost, text, highlightId, type, raiseEvents ? this.dispatcher : undefined)
}
if (typeof textRange.start !== 'number' || typeof textRange.end !== 'number') {
error(
Expand Down
3 changes: 2 additions & 1 deletion src/highlight-support.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const highlightSupport = {

// Used to highlight arbitrary text in an editable. All occurrences
// will be highlighted.
highlightText (editableHost, text, highlightId, type) {
highlightText (editableHost, text, highlightId, type, dispatcher) {
if (this.hasHighlight(editableHost, highlightId)) return
const blockText = highlightText.extractText(editableHost)

Expand All @@ -19,6 +19,7 @@ const highlightSupport = {
if (matches && matches.length) {
if (highlightId) matches[0].id = highlightId
highlightText.highlightMatches(editableHost, matches)
if (dispatcher) dispatcher.notify('change', editableHost)
return matches[0].startIndex
}
},
Expand Down

0 comments on commit 240d82b

Please sign in to comment.