mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-08-18 05:01:17 +02:00
fix shouldComponentUpdate logic for code highlighing
This commit is contained in:
@@ -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.
|
||||
|
Reference in New Issue
Block a user