diff --git a/lib/components/node.js b/lib/components/node.js index 89ac39326..7b29e7a68 100644 --- a/lib/components/node.js +++ b/lib/components/node.js @@ -116,13 +116,19 @@ class Node extends React.Component { // For text nodes, which can have custom decorations, we need to check to // see if the block has changed, which has caused the decorations to change. - if ( - props.node.kind == 'text' && - props.block != this.props.block - ) { - const nextRanges = props.node.getRanges(props.decorators) - const ranges = this.props.node.getRanges(this.props.decorators) - if (!ranges.equals(nextRanges)) return true + if (props.node.kind == 'text') { + const { node, schema, state } = props + const { document } = state + const decorators = document.getDescendantDecorators(node.key, schema) + const ranges = node.getRanges(decorators) + + const prevNode = this.props.node + const prevSchema = this.props.schema + const prevDocument = this.props.state.document + const prevDecorators = prevDocument.getDescendantDecorators(prevNode.key, prevSchema) + const prevRanges = prevNode.getRanges(prevDecorators) + + if (!ranges.equals(prevRanges)) return true } // Otherwise, don't update.