1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-03-05 13:39:04 +01:00

rebuild selection from anchorPath and focusPath if keys were dropped ()

This commit is contained in:
Michael Telatynski 2018-07-19 20:07:22 +01:00 committed by Ian Storm Taylor
parent 6e749e2f0e
commit f83b3114db

@ -100,6 +100,18 @@ class Value extends Record(DEFAULTS) {
let data = new Map()
document = Document.fromJSON(document)
// rebuild selection from anchorPath and focusPath if keys were dropped
const { anchorPath, focusPath, anchorKey, focusKey } = selection
if (anchorPath !== undefined && anchorKey === undefined) {
selection.anchorKey = document.assertPath(anchorPath).key
}
if (focusPath !== undefined && focusKey === undefined) {
selection.focusKey = document.assertPath(focusPath).key
}
selection = Range.fromJSON(selection)
schema = Schema.fromJSON(schema)