* Returns true when the editor should be updated. * * @param prevProps Previous react's properties. * @param nextProps React's properties. * @param editor Current editor instance.
( prevProps: Readonly<Props<TEditor>>, nextProps: Readonly<Props<TEditor>>, editor: TEditor )
| 443 | * @param editor Current editor instance. |
| 444 | */ |
| 445 | function shouldUpdateEditorData<TEditor extends Editor>( |
| 446 | prevProps: Readonly<Props<TEditor>>, |
| 447 | nextProps: Readonly<Props<TEditor>>, |
| 448 | editor: TEditor |
| 449 | ): boolean { |
| 450 | // Check whether `nextProps.data` is equal to `this.props.data` is required if somebody defined the `#data` |
| 451 | // property as a static string and updated a state of component when the editor's content has been changed. |
| 452 | // If we avoid checking those properties, the editor's content will back to the initial value because |
| 453 | // the state has been changed and React will call this method. |
| 454 | if ( prevProps.data === nextProps.data ) { |
| 455 | return false; |
| 456 | } |
| 457 | |
| 458 | // We should not change data if the editor's content is equal to the `#data` property. |
| 459 | if ( editor.data.get() === nextProps.data ) { |
| 460 | return false; |
| 461 | } |
| 462 | |
| 463 | return true; |
| 464 | } |
| 465 | |
| 466 | /** |
| 467 | * Checks if currently installed version of the editor is supported by the integration. |
no test coverage detected
searching dependent graphs…