We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 3558b83 commit 5a5d397Copy full SHA for 5a5d397
src/highlight-support.js
@@ -45,8 +45,9 @@ const highlightSupport = {
45
this.win
46
)
47
48
- const actualStartIndex = startIndex
49
- const actualEndIndex = endIndex
+ // Do not let highlight exceed text range
+ const actualStartIndex = Math.min(Math.max(startIndex, 0), blockText.length - 1)
50
+ const actualEndIndex = Math.min(Math.max(endIndex, 1), blockText.length)
51
52
// If text is provided then validate that it matches
53
if (text) {
@@ -116,7 +117,7 @@ const highlightSupport = {
116
117
if (position) res[highlightId] = position
118
}
119
- return res
120
+ return Object.keys(res).length > 0 ? res : undefined
121
},
122
123
extractMarkerNodePosition (editableHost, markers) {
0 commit comments