mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-08-29 09:59:48 +02:00
fix to not re-resolve plugins on every update, closes #112
This commit is contained in:
@@ -57,8 +57,13 @@ class Editor extends React.Component {
|
||||
*/
|
||||
|
||||
componentWillReceiveProps = (props) => {
|
||||
this.setState({ plugins: this.resolvePlugins(props) })
|
||||
this.setState({ state: this.resolveState(props.state) })
|
||||
if (props.plugins != this.props.plugins) {
|
||||
this.setState({ plugins: this.resolvePlugins(props) })
|
||||
}
|
||||
|
||||
if (props.state != this.props.state) {
|
||||
this.setState({ state: this.resolveState(props.state) })
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -19,6 +19,14 @@ class Void extends React.Component {
|
||||
state: React.PropTypes.object.isRequired
|
||||
};
|
||||
|
||||
shouldComponentUpdate = (props) => {
|
||||
return (
|
||||
props.node != this.props.node ||
|
||||
props.state.selection.hasEdgeIn(props.node) ||
|
||||
this.props.state.selection.hasEdgeIn(this.props.node)
|
||||
)
|
||||
}
|
||||
|
||||
render = () => {
|
||||
const { children, node } = this.props
|
||||
const Tag = node.kind == 'block' ? 'div' : 'span'
|
||||
|
@@ -51,7 +51,6 @@ function Plugin(options = {}) {
|
||||
renderPlaceholder = () => {
|
||||
if (!placeholder) return null
|
||||
const { node, state } = this.props
|
||||
|
||||
return (
|
||||
<Placeholder
|
||||
className={placeholderClassName}
|
||||
|
Reference in New Issue
Block a user