1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-08-21 06:31:28 +02:00

fix findNativePoint in empty blocks, add error reporting to examples

This commit is contained in:
Ian Storm Taylor
2017-10-13 18:34:35 -07:00
parent 576fb5a133
commit e815c2752c
3 changed files with 68 additions and 10 deletions

View File

@@ -33,6 +33,16 @@ function findNativePoint(key, offset) {
start = end
}
// COMPAT: For empty blocks with only a single empty text node, we will have
// rendered a `<br/>` instead of a text node.
if (
el.childNodes.length == 1 &&
el.childNodes[0].childNodes.length == 1 &&
el.childNodes[0].childNodes[0].tagName == 'BR'
) {
return { node: el.childNodes[0], offset: 0 }
}
return null
}