Skip to content

Commit 6d12cf8

Browse files
committed
fix(highlight): dont remove highlights when spellchecking
1 parent ca0b998 commit 6d12cf8

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

src/highlight-support.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const highlightSupport = {
1212
let blockText = highlightText.extractText(editableHost)
1313

1414
const marker = '<span class="highlight-comment"></span>'
15-
const markerNode = highlightSupport.createMarkerNode(marker, this.win)
15+
const markerNode = highlightSupport.createMarkerNode(marker, 'highlight', this.win)
1616

1717
const textSearch = new TextHighlighting(markerNode, 'text')
1818
const matches = textSearch.findMatches(blockText, [text])
@@ -46,15 +46,15 @@ const highlightSupport = {
4646
return !!matches.length
4747
},
4848

49-
createMarkerNode (markerMarkup, win) {
49+
createMarkerNode (markerMarkup, highlightType, win) {
5050
let marker = $(markerMarkup)[0]
5151

5252
if (win) {
5353
marker = content.adoptElement(marker, win.document)
5454
}
5555

5656
marker.setAttribute('data-editable', 'ui-unwrap')
57-
marker.setAttribute('data-highlight', 'highlight')
57+
marker.setAttribute('data-highlight', highlightType)
5858
return marker
5959
}
6060

src/highlighting.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,10 @@ export default class Highlighting {
4141
let spellcheckService = this.config.spellcheck.spellcheckService
4242
const spellcheckMarker = this.config.spellcheck.marker
4343
const whitespaceMarker = this.config.whitespace.marker
44-
const spellcheckMarkerNode = highlightSupport.createMarkerNode(spellcheckMarker, this.win)
45-
const whitespaceMarkerNode = highlightSupport.createMarkerNode(whitespaceMarker, this.win)
44+
const spellcheckMarkerNode = highlightSupport
45+
.createMarkerNode(spellcheckMarker, 'spellcheck', this.win)
46+
const whitespaceMarkerNode = highlightSupport
47+
.createMarkerNode(whitespaceMarker, 'spellcheck', this.win)
4648

4749
this.spellcheckService = new SpellcheckService(spellcheckService)
4850
this.spellcheck = new WordHighlighting(spellcheckMarkerNode)
@@ -161,7 +163,7 @@ export default class Highlighting {
161163
}
162164

163165
removeHighlights (editableHost) {
164-
$(editableHost).find('[data-highlight]')
166+
$(editableHost).find('[data-highlight="spellcheck"]')
165167
.each((index, elem) => {
166168
content.unwrap(elem)
167169
})

0 commit comments

Comments
 (0)