Skip to content

Commit

Permalink
Detect non-width spaces
Browse files Browse the repository at this point in the history
  • Loading branch information
Wout Van Den Driessche committed Jul 17, 2023
1 parent 2d03516 commit 1226b32
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/TributeRange.js
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,10 @@ class TributeRange {
}
}

convertNonWidthSpacesToRealOnes(text) {
return text.replace(/[\u200B-\u200D\uFEFF]/g, ' ')
}

getTextPrecedingCurrentSelection() {
let context = this.tribute.current,
text = ''
Expand All @@ -260,7 +264,7 @@ class TributeRange {
let selectedElem = this.getWindowSelection().anchorNode

if (selectedElem != null) {
let workingNodeContent = selectedElem.textContent
let workingNodeContent = this.convertNonWidthSpacesToRealOnes(selectedElem.textContent)
let selectStartOffset = this.getWindowSelection().getRangeAt(0).startOffset

if (workingNodeContent && selectStartOffset >= 0) {
Expand Down

0 comments on commit 1226b32

Please sign in to comment.