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 40 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.
  • Add the main entry point to your Plugin::registerCkeditorPackage() call so we can properly format the import statement for your plugin.
public function init()
{
    parent::init();

    if (Craft::$app->getRequest()->getIsCpRequest()) {
        Plugin::registerCkeditorPackage(MyAssetBundle::class, 'index.js')
    }
}

First Party plugins

If all you want to do is add a first party plugin (like ImageResize we've added a CkeditorConfig::registerFirstPartyPackage() method you can call from your plugin or module's init method.

use craft\ckeditor\helpers\CkeditorConfig;

CkeditorConfig::registerFirstPartyPackage(['SpecialCharacters', 'SpecialCharactersEssentials'], ['specialCharacters']);
CkeditorConfig::registerFirstPartyPackage(['ImageResize']);

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

Browser Support

Because the new installation methods rely on importmaps this plugin includes a shim for older browsers that may not support them.

@brianjhanson brianjhanson force-pushed the feature/update-installation-method branch from 95cadf1 to 347af19 Compare February 18, 2025 19:53
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