Skip to content

Commit 240d82b

Browse files
arddormarcbachmann
authored andcommitted
fix: on highlightText dispatch a change event
1 parent e4f86a4 commit 240d82b

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

src/core.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ export class Editable {
382382
*/
383383
highlight ({editableHost, text, highlightId, textRange, raiseEvents, type = 'comment'}) {
384384
if (!textRange) {
385-
return highlightSupport.highlightText(editableHost, text, highlightId, type)
385+
return highlightSupport.highlightText(editableHost, text, highlightId, type, raiseEvents ? this.dispatcher : undefined)
386386
}
387387
if (typeof textRange.start !== 'number' || typeof textRange.end !== 'number') {
388388
error(

src/highlight-support.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const highlightSupport = {
77

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

@@ -19,6 +19,7 @@ const highlightSupport = {
1919
if (matches && matches.length) {
2020
if (highlightId) matches[0].id = highlightId
2121
highlightText.highlightMatches(editableHost, matches)
22+
if (dispatcher) dispatcher.notify('change', editableHost)
2223
return matches[0].startIndex
2324
}
2425
},

0 commit comments

Comments
 (0)