From fa32f8deca4549a2c9016518cbaa571b1a03130b Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Thu, 14 Sep 2023 15:10:09 +0200 Subject: [PATCH] Add the documentation for CKEditor5 plugins --- docs/javascript/components_ckeditor5.md | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/docs/javascript/components_ckeditor5.md b/docs/javascript/components_ckeditor5.md index 751cd770..e96c7d09 100644 --- a/docs/javascript/components_ckeditor5.md +++ b/docs/javascript/components_ckeditor5.md @@ -85,3 +85,24 @@ listenToCkeditor(element).submitOnEnter(({ ckeditor, html }) => { // Do something with the resulting `html`. }); ``` + +## Creating Plugins + +CKEditor 5 was designed to be compiled as a single bundle, relying a lot on identity checks to access and associate data. +Any extra plugin that should be added to the editor must be built using the modules exposed through the `setupConfiguration()` event otherwise the identity checks will fail. + +```ts +listenToCkeditor(element).setupConfiguration(({ configuration, CKEditor5 }) => { + class FooPlugin extends CKEditor5.Core.Plugin { + static get pluginName() { + return "FooPlugin"; + } + + init(): void { + // … + } + } + + configuration.extraPlugins.push(FooPlugin); +}); +``` -- 2.20.1