MCPcopy Create free account
hub / github.com/ckeditor/ckeditor5-react / shouldUpdateEditorData

Function shouldUpdateEditorData

src/ckeditor.tsx:445–464  ·  view source on GitHub ↗

* 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
)

Source from the content-addressed store, hash-verified

443 * @param editor Current editor instance.
444 */
445function 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.

Callers 1

shouldComponentUpdateMethod · 0.85

Calls 1

getMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…