1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-08-29 09:59:48 +02:00

Merge branch 'master' of github.com:ianstormtaylor/slate

This commit is contained in:
Ian Storm Taylor
2017-09-06 09:35:12 -07:00
3 changed files with 13 additions and 9 deletions

View File

@@ -17,7 +17,7 @@ class Video extends React.Component {
isSelected = () => {
const { node, state } = this.props
const isSelected = state.selection.hasEdgeIn(node)
const isSelected = state.isFocused && state.blocks.includes(node)
return isSelected
}

View File

@@ -28,7 +28,7 @@ const schema = {
nodes: {
image: (props) => {
const { node, state } = props
const active = state.isFocused && state.selection.hasEdgeIn(node)
const active = state.isFocused && state.blocks.includes(node)
const src = node.data.get('src')
const className = active ? 'active' : null
return (

View File

@@ -111,14 +111,18 @@ class Node extends React.Component {
if (nextProps.node != props.node) return true
// If the node is a block or inline, which can have custom renderers, we
// include an extra check to re-render if the node's focus changes, to make
// it simple for users to show a node's "selected" state.
// include an extra check to re-render if the node either becomes part of,
// or leaves, a selection. This is to make it simple for users to show a
// node's "selected" state.
if (nextProps.node.kind != 'text') {
const hasEdgeIn = props.state.selection.hasEdgeIn(props.node)
const nextHasEdgeIn = nextProps.state.selection.hasEdgeIn(nextProps.node)
const hasFocus = props.state.isFocused || nextProps.state.isFocused
const hasEdge = hasEdgeIn || nextHasEdgeIn
if (hasFocus && hasEdge) return true
const nodes = `${props.node.kind}s`
const isInSelection = props.state[nodes].includes(props.node)
const nextIsInSelection = nextProps.state[nodes].includes(nextProps.node)
const hasFocus = props.state.isFocused
const nextHasFocus = nextProps.state.isFocused
const selectionChanged = isInSelection != nextIsInSelection
const focusChanged = hasFocus != nextHasFocus
if (selectionChanged || focusChanged) return true
}
// If the node is a text node, re-render if the current decorations have