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