mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-07-31 04:20:26 +02:00
fix for non-br void nodes
This commit is contained in:
@@ -17,8 +17,9 @@ function normalizeNodeAndOffset(node, offset) {
|
|||||||
const index = isLast ? offset - 1 : offset
|
const index = isLast ? offset - 1 : offset
|
||||||
node = getNonComment(node, index, direction)
|
node = getNonComment(node, index, direction)
|
||||||
|
|
||||||
// If the node is not a text or a <br> node, traverse until we have one.
|
// If the node has children, traverse until we have a leaf node. Leaf nodes
|
||||||
while (node.nodeType == 1 && node.tagName != 'BR') {
|
// can be either text nodes, or other void DOM nodes.
|
||||||
|
while (node.nodeType == 1 && node.childNodes.length) {
|
||||||
const i = isLast ? node.childNodes.length - 1 : 0
|
const i = isLast ? node.childNodes.length - 1 : 0
|
||||||
node = getNonComment(node, i, direction)
|
node = getNonComment(node, i, direction)
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user