mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-08-17 20:51:20 +02:00
Fix invalid ranges in getEventRange (#1849)
This commit is contained in:
committed by
Ian Storm Taylor
parent
ffb19cac1a
commit
b4422ad6b3
@@ -36,9 +36,17 @@ function getEventRange(event, value) {
|
||||
|
||||
const text = node.getFirstText()
|
||||
const range = Range.create()
|
||||
return isPrevious
|
||||
? range.moveToEndOf(document.getPreviousText(text.key))
|
||||
: range.moveToStartOf(document.getNextText(text.key))
|
||||
|
||||
if (isPrevious) {
|
||||
const previousText = document.getPreviousText(text.key)
|
||||
|
||||
if (previousText) {
|
||||
return range.moveToEndOf(previousText)
|
||||
}
|
||||
}
|
||||
|
||||
const nextText = document.getNextText(text.key)
|
||||
return nextText ? range.moveToStartOf(nextText) : null
|
||||
}
|
||||
|
||||
// Else resolve a range from the caret position where the drop occured.
|
||||
|
Reference in New Issue
Block a user