mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-08-29 18:09:49 +02:00
Fix range normalization in remove node. (#2971)
This commit is contained in:
committed by
Ian Storm Taylor
parent
9c2d55e800
commit
f4283866f2
@@ -622,18 +622,18 @@ class Value extends Record(DEFAULTS) {
|
||||
value = value.set('document', document)
|
||||
|
||||
value = value.mapRanges(range => {
|
||||
const { start, end } = range
|
||||
const { anchor, focus } = range
|
||||
|
||||
if (node.hasNode(start.key)) {
|
||||
if (node.hasNode(anchor.key)) {
|
||||
range = prev
|
||||
? range.moveStartTo(prev.key, prev.text.length)
|
||||
: next ? range.moveStartTo(next.key, 0) : range.unset()
|
||||
? range.moveAnchorTo(prev.key, prev.text.length)
|
||||
: next ? range.moveAnchorTo(next.key, 0) : range.unset()
|
||||
}
|
||||
|
||||
if (node.hasNode(end.key)) {
|
||||
if (node.hasNode(focus.key)) {
|
||||
range = prev
|
||||
? range.moveEndTo(prev.key, prev.text.length)
|
||||
: next ? range.moveEndTo(next.key, 0) : range.unset()
|
||||
? range.moveFocusTo(prev.key, prev.text.length)
|
||||
: next ? range.moveFocusTo(next.key, 0) : range.unset()
|
||||
}
|
||||
|
||||
range = range.updatePoints(point => point.setPath(null))
|
||||
|
Reference in New Issue
Block a user