mirror of
https://github.com/strapi/strapi.git
synced 2025-09-22 14:59:07 +00:00
Add shouldComponent to Wysiwyg
This commit is contained in:
parent
9e9353cba4
commit
34e5ca8010
@ -51,9 +51,9 @@ class Wysiwyg extends React.Component {
|
|||||||
editorState: EditorState.createEmpty(),
|
editorState: EditorState.createEmpty(),
|
||||||
isDraging: false,
|
isDraging: false,
|
||||||
isFocused: false,
|
isFocused: false,
|
||||||
|
isFullscreen: false,
|
||||||
isPreviewMode: false,
|
isPreviewMode: false,
|
||||||
headerValue: '',
|
headerValue: '',
|
||||||
isFullscreen: false,
|
|
||||||
};
|
};
|
||||||
this.focus = () => {
|
this.focus = () => {
|
||||||
this.setState({ isFocused: true });
|
this.setState({ isFocused: true });
|
||||||
@ -84,6 +84,38 @@ class Wysiwyg extends React.Component {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
shouldComponentUpdate(nextProps, nextState) {
|
||||||
|
if (nextState.editorState !== this.state.editorState) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (nextProps.resetProps !== this.props.resetProps) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (nextState.isDraging !== this.state.isDraging) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (nextState.isFocused !== this.state.isFocused) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (nextState.isFullscreen !== this.state.isFullscreen) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (nextState.isPreviewMode !== this.state.isPreviewMode) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (nextState.headerValue !== this.state.headerValue) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
componentDidUpdate(prevProps) {
|
componentDidUpdate(prevProps) {
|
||||||
// Handle resetProps
|
// Handle resetProps
|
||||||
if (prevProps.resetProps !== this.props.resetProps) {
|
if (prevProps.resetProps !== this.props.resetProps) {
|
||||||
@ -362,7 +394,7 @@ class Wysiwyg extends React.Component {
|
|||||||
|
|
||||||
handleDrop = e => {
|
handleDrop = e => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
console.log('kkks');
|
||||||
if (this.state.isPreviewMode) {
|
if (this.state.isPreviewMode) {
|
||||||
return this.setState({ isDraging: false });
|
return this.setState({ isDraging: false });
|
||||||
}
|
}
|
||||||
|
@ -57,7 +57,7 @@ const decorator = new CompositeDecorator([
|
|||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
|
|
||||||
class PreviewWysiwyg extends React.Component {
|
class PreviewWysiwyg extends React.PureComponent {
|
||||||
state = { editorState: EditorState.createEmpty(), isMounted: false };
|
state = { editorState: EditorState.createEmpty(), isMounted: false };
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user