1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-08-30 18:39:51 +02:00

Fix range normalization in remove node. (#2971)

This commit is contained in:
themithy
2019-08-22 04:42:07 +02:00
committed by Ian Storm Taylor
parent 9c2d55e800
commit f4283866f2

View File

@@ -622,18 +622,18 @@ class Value extends Record(DEFAULTS) {
value = value.set('document', document) value = value.set('document', document)
value = value.mapRanges(range => { 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 = prev
? range.moveStartTo(prev.key, prev.text.length) ? range.moveAnchorTo(prev.key, prev.text.length)
: next ? range.moveStartTo(next.key, 0) : range.unset() : next ? range.moveAnchorTo(next.key, 0) : range.unset()
} }
if (node.hasNode(end.key)) { if (node.hasNode(focus.key)) {
range = prev range = prev
? range.moveEndTo(prev.key, prev.text.length) ? range.moveFocusTo(prev.key, prev.text.length)
: next ? range.moveEndTo(next.key, 0) : range.unset() : next ? range.moveFocusTo(next.key, 0) : range.unset()
} }
range = range.updatePoints(point => point.setPath(null)) range = range.updatePoints(point => point.setPath(null))