1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-09-02 03:32:36 +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 { else {
const isList = this.hasBlock('list-item') const isList = this.hasBlock('list-item')
const isType = state.blocks.some((block) => { 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) { if (isList && isType) {

View File

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

View File

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