From 10d1f1eaaeb47be0291a34af59a2e909566745f1 Mon Sep 17 00:00:00 2001 From: Mateusz Baginski Date: Tue, 20 Aug 2024 09:10:04 +0200 Subject: [PATCH 1/4] Add `onChangeInitializedEditors` property description to `CKEditorContext` component documentation --- docs/getting-started/integrations/react.md | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/docs/getting-started/integrations/react.md b/docs/getting-started/integrations/react.md index 77dd09139fe..575ef2f8392 100644 --- a/docs/getting-started/integrations/react.md +++ b/docs/getting-started/integrations/react.md @@ -129,7 +129,13 @@ import 'ckeditor5/ckeditor5.css'; function App() { return ( - + { + console.info( editors.editor1?.instance, editors.editor1?.yourAdditionalData ); + } } + > { // You can store the "editor" and use when it is needed. console.log( 'Editor 1 is ready to use!', editor ); @@ -169,6 +179,7 @@ The `CKEditorContext` component supports the following properties: * `config` – The CKEditor 5 context configuration. * `isLayoutReady` – 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 5 annotations or a presence list are used. * `id` – The context ID. When this property changes, the component restarts the context with its editor and reinitializes it based on the current configuration. +* `onChangeInitializedEditors` – A function called when any editor is initialized or destroyed in the tree. This function is called with dictionary of fully initialized editors and the `contextItemMetadata.name` property set on `CKEditor` component is used as a key of such map. When `contextItemMetadata` property is not present on `CKEditor` component then it's ID will be used as a key in such dictionary. It's possible to add additional data besides `name` to `contextItemMetadata` in `CKEditor` component, that will be forwarded to the `onChangeInitializedEditors`. * `onReady` – 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` – 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'` – Informs when the error has occurred (during the editor or context initialization, or after the initialization). From 9a10cb7637383100d2fcd42dafa0102b1c49f400 Mon Sep 17 00:00:00 2001 From: Mateusz Baginski Date: Tue, 20 Aug 2024 09:13:01 +0200 Subject: [PATCH 2/4] Adjust doc --- docs/getting-started/integrations/react.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/getting-started/integrations/react.md b/docs/getting-started/integrations/react.md index 575ef2f8392..3f0ee95ab65 100644 --- a/docs/getting-started/integrations/react.md +++ b/docs/getting-started/integrations/react.md @@ -179,7 +179,7 @@ The `CKEditorContext` component supports the following properties: * `config` – The CKEditor 5 context configuration. * `isLayoutReady` – 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 5 annotations or a presence list are used. * `id` – The context ID. When this property changes, the component restarts the context with its editor and reinitializes it based on the current configuration. -* `onChangeInitializedEditors` – A function called when any editor is initialized or destroyed in the tree. This function is called with dictionary of fully initialized editors and the `contextItemMetadata.name` property set on `CKEditor` component is used as a key of such map. When `contextItemMetadata` property is not present on `CKEditor` component then it's ID will be used as a key in such dictionary. It's possible to add additional data besides `name` to `contextItemMetadata` in `CKEditor` component, that will be forwarded to the `onChangeInitializedEditors`. +* `onChangeInitializedEditors` – This function is 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. If the `contextItemMetadata` property is not present, the editor's ID is used as the key. Additional data can be added to the `contextItemMetadata` in the `CKEditor` component, which will be passed to the `onChangeInitializedEditors` function. * `onReady` – 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` – 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'` – Informs when the error has occurred (during the editor or context initialization, or after the initialization). From 4626e02bff004ee9b094c6b83d165d1334990b12 Mon Sep 17 00:00:00 2001 From: Mateusz Baginski Date: Tue, 20 Aug 2024 09:13:29 +0200 Subject: [PATCH 3/4] Adjust doc --- docs/getting-started/integrations/react.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/getting-started/integrations/react.md b/docs/getting-started/integrations/react.md index 3f0ee95ab65..44e21871454 100644 --- a/docs/getting-started/integrations/react.md +++ b/docs/getting-started/integrations/react.md @@ -179,7 +179,7 @@ The `CKEditorContext` component supports the following properties: * `config` – The CKEditor 5 context configuration. * `isLayoutReady` – 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 5 annotations or a presence list are used. * `id` – The context ID. When this property changes, the component restarts the context with its editor and reinitializes it based on the current configuration. -* `onChangeInitializedEditors` – This function is 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. If the `contextItemMetadata` property is not present, the editor's ID is used as the key. Additional data can be added to the `contextItemMetadata` in the `CKEditor` component, which will be passed to the `onChangeInitializedEditors` function. +* `onChangeInitializedEditors` – 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. If the `contextItemMetadata` property is not present, the editor's ID is used as the key. Additional data can be added to the `contextItemMetadata` in the `CKEditor` component, which will be passed to the `onChangeInitializedEditors` function. * `onReady` – 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` – 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'` – Informs when the error has occurred (during the editor or context initialization, or after the initialization). From 45b437f214852d993eaefeb6c3786450bb626bcc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Bagi=C5=84ski?= Date: Thu, 22 Aug 2024 11:54:59 +0200 Subject: [PATCH 4/4] Update docs/getting-started/integrations/react.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Mateusz Gorzeliński --- docs/getting-started/integrations/react.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/getting-started/integrations/react.md b/docs/getting-started/integrations/react.md index 44e21871454..66b7f3acdd1 100644 --- a/docs/getting-started/integrations/react.md +++ b/docs/getting-started/integrations/react.md @@ -179,7 +179,7 @@ The `CKEditorContext` component supports the following properties: * `config` – The CKEditor 5 context configuration. * `isLayoutReady` – 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 5 annotations or a presence list are used. * `id` – The context ID. When this property changes, the component restarts the context with its editor and reinitializes it based on the current configuration. -* `onChangeInitializedEditors` – 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. If the `contextItemMetadata` property is not present, the editor's ID is used as the key. Additional data can be added to the `contextItemMetadata` in the `CKEditor` component, which will be passed to the `onChangeInitializedEditors` function. +* `onChangeInitializedEditors` – 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` – 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` – 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'` – Informs when the error has occurred (during the editor or context initialization, or after the initialization).