1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-09-01 19:22:35 +02:00

fix deprecate node access without key

This commit is contained in:
Ian Storm Taylor
2016-11-17 12:34:10 -08:00
parent 590b024468
commit 508d2b15b7
3 changed files with 9 additions and 9 deletions

View File

@@ -188,7 +188,7 @@ class RichText extends React.Component {
else {
const isList = this.hasBlock('list-item')
const isType = state.blocks.some((block) => {
return !!document.getClosest(block, parent => parent.type == type)
return !!document.getClosest(block.key, parent => parent.type == type)
})
if (isList && isType) {

View File

@@ -104,8 +104,8 @@ class Tables extends React.Component {
const startNode = document.getDescendant(startKey)
if (selection.isAtStartOf(startNode)) {
const previous = document.getPreviousText(startNode)
const prevBlock = document.getClosestBlock(previous)
const previous = document.getPreviousText(startNode.key)
const prevBlock = document.getClosestBlock(previous.key)
if (prevBlock.type == 'table-cell') {
e.preventDefault()

View File

@@ -492,14 +492,14 @@ function Plugin(options = {}) {
if (data.isOpt) return
if (state.isExpanded) return
const { document, startText } = state
const hasVoidParent = document.hasVoidParent(startText.key)
const { document, startKey, startText } = state
const hasVoidParent = document.hasVoidParent(startKey)
if (
startText.text == '' ||
hasVoidParent
) {
const previousText = document.getPreviousText(startText.key)
const previousText = document.getPreviousText(startKey)
if (!previousText) return
debug('onKeyDownLeft', { data })
@@ -530,14 +530,14 @@ function Plugin(options = {}) {
if (data.isOpt) return
if (state.isExpanded) return
const { document, startText } = state
const hasVoidParent = document.hasVoidParent(startText)
const { document, startKey, startText } = state
const hasVoidParent = document.hasVoidParent(startKey)
if (
startText.text == '' ||
hasVoidParent
) {
const nextText = document.getNextText(startText)
const nextText = document.getNextText(startKey)
if (!nextText) return state
debug('onKeyDownRight', { data })