1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-03-07 14:30:04 +01:00

Fallback to last leaf node when inserting change ()

This commit is contained in:
Blake Embrey 2017-10-31 21:07:27 -07:00 committed by Ian Storm Taylor
parent cfa8cf6834
commit 6dc3c6441c

@ -428,25 +428,25 @@ function AfterPlugin() {
// Get the text node and leaf in question.
const { document, selection } = value
const node = document.getDescendant(point.key)
const block = document.getClosestBlock(node.key)
const leaves = node.getLeaves()
const lastText = block.getLastText()
const lastLeaf = leaves.last()
let start = 0
let end = 0
const leaf = leaves.find((r) => {
start = end
end += r.text.length
if (end >= point.offset) return true
start = end
})
}) || lastLeaf
// Get the text information.
const { text } = leaf
let { textContent } = anchorNode
const block = document.getClosestBlock(node.key)
const lastText = block.getLastText()
const lastLeaf = leaves.last()
const lastChar = textContent.charAt(textContent.length - 1)
const isLastText = node == lastText
const isLastLeaf = leaf == lastLeaf
const lastChar = textContent.charAt(textContent.length - 1)
// COMPAT: If this is the last leaf, and the DOM text ends in a new line,
// we will have added another new line in <Leaf>'s render method to account