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

Feature/update installation method #363

Draft
wants to merge 30 commits into
base: 5.x
Choose a base branch
from

Conversation

brianjhanson
Copy link
Contributor

@brianjhanson brianjhanson commented Feb 7, 2025

Updates CKEditor to use the new installation methods. The big change between old and new is that the new no longer supports DDLs and leans all in to JavaScript imports and import maps.

Updating Plugins

For the most part, plugin authors should follow the instructions in the migrating custom plugins documentation from CKEditor.

On the Craft side, the updates aren't too involved.

  • Classes extending BaseCkeditorPackageAsset must now include a $namespace property that will be the module for the import statement generated. It can technically be almost anything, but using a @{author}/ckeditor5-{handle} format is recommended.
  • Register the JS import for your plugin via View::registerJsImport()
public function init()
{
    parent::init();

    if (Craft::$app->getRequest()->getIsCpRequest()) {
        $assetManager = Craft::$app->getAssetManager();
        $view = Craft::$app->getView();

        $bundle = $assetManager->getBundle(MyAssetBundle::class);

        $view->registerJsImport('@craftcms/ckeditor5-tokens', $assetManager->getAssetUrl($bundle, 'index.js'));
    }
}

First Party plugins

If all you want to do is add a first party plugin (like ImageResize the Field class has gained an extraPlugins property on the Field::EVENT_MODIFY_CONFIG event.

Event::on(
    Field::class,
    Field::EVENT_MODIFY_CONFIG,
    handler: function(ModifyConfigEvent $event) {
        $event->extraPlugins = ['ImageResize'];
    }
);

Extra plugins will be included into the ckeditor5 JavaScript import statement.

Todo

  • Make sure translations are handled

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant