Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docs: Add onChangeInitializedEditors property description to CKEditorContext component documentation #16939

Merged
merged 4 commits into from
Aug 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion docs/getting-started/integrations/react.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,14 +129,24 @@ import 'ckeditor5/ckeditor5.css';

function App() {
return (
<CKEditorContext context={ Context } contextWatchdog={ ContextWatchdog }>
<CKEditorContext
context={ Context }
contextWatchdog={ ContextWatchdog }
onChangeInitializedEditors={ ( editors ) => {
console.info( editors.editor1?.instance, editors.editor1?.yourAdditionalData );
} }
>
<CKEditor
editor={ ClassicEditor }
config={ {
plugins: [ Essentials, Bold, Italic, Paragraph ],
toolbar: [ 'undo', 'redo', '|', 'bold', 'italic' ],
} }
data='<p>Hello from the first editor working with the context!</p>'
contextItemMetadata={{
name: 'editor1',
yourAdditionalData: 2
}}
onReady={ ( editor ) => {
// You can store the "editor" and use when it is needed.
console.log( 'Editor 1 is ready to use!', editor );
Expand Down Expand Up @@ -169,6 +179,7 @@ The `CKEditorContext` component supports the following properties:
* `config` &ndash; The CKEditor&nbsp;5 context configuration.
* `isLayoutReady` &ndash; A property that delays the context creation when set to `false`. It creates the context and the editor children once it is `true` or unset. Useful when the CKEditor&nbsp;5 annotations or a presence list are used.
* `id` &ndash; The context ID. When this property changes, the component restarts the context with its editor and reinitializes it based on the current configuration.
* `onChangeInitializedEditors` &ndash; A function called when any editor is initialized or destroyed in the tree. It receives a dictionary of fully initialized editors, where the key is the value of the `contextItemMetadata.name` property set on the `CKEditor` component. The editor's ID is the key if the `contextItemMetadata` property is absent. Additional data can be added to the `contextItemMetadata` in the `CKEditor` component, which will be passed to the `onChangeInitializedEditors` function.
* `onReady` &ndash; A function called when the context is initialized but before the editors in the tree are set up. After this function is executed, you can track additions and removals in the context tree using the `context.editors.on('change', () => {})` method.
* `onError` &ndash; A function called when the context has crashed during the initialization or during the runtime. It receives two arguments: the error instance and the error details. Error details is an object that contains two properties:
* `{String} phase`: `'initialization'|'runtime'` &ndash; Informs when the error has occurred (during the editor or context initialization, or after the initialization).
Expand Down