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:
@@ -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) {
|
||||
|
@@ -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()
|
||||
|
@@ -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 })
|
||||
|
Reference in New Issue
Block a user