mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-08-18 13:11:17 +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 text = node.getFirstText()
|
||||||
const range = Range.create()
|
const range = Range.create()
|
||||||
return isPrevious
|
|
||||||
? range.moveToEndOf(document.getPreviousText(text.key))
|
if (isPrevious) {
|
||||||
: range.moveToStartOf(document.getNextText(text.key))
|
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.
|
// Else resolve a range from the caret position where the drop occured.
|
||||||
|
Reference in New Issue
Block a user