mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-08-20 14:11:35 +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
|
// 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.
|
// see if the block has changed, which has caused the decorations to change.
|
||||||
if (
|
if (props.node.kind == 'text') {
|
||||||
props.node.kind == 'text' &&
|
const { node, schema, state } = props
|
||||||
props.block != this.props.block
|
const { document } = state
|
||||||
) {
|
const decorators = document.getDescendantDecorators(node.key, schema)
|
||||||
const nextRanges = props.node.getRanges(props.decorators)
|
const ranges = node.getRanges(decorators)
|
||||||
const ranges = this.props.node.getRanges(this.props.decorators)
|
|
||||||
if (!ranges.equals(nextRanges)) return true
|
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.
|
// Otherwise, don't update.
|
||||||
|
Reference in New Issue
Block a user