Note: This is an experimental plugin. Do not use this on production sites.
CKEditor for CraftCMS
This plugin requires Craft CMS 4.4.0 or later, and PHP 8.2.0 or later.
You can install this plugin with Composer.
Add the repo to your composer.json folder:
{
"repositories": [
{
"type": "vcs",
"url": "https://github.com/newism/craft-ckeditor.git"
}
]
}
Open your terminal and run the following commands:
# go to the project directory
cd /path/to/my-project.test
# tell Composer to load the plugin
composer require newism/craft-ckeditor
# tell Craft to install the plugin
./craft plugin/install newism-ckeditor
This CraftCMS plugin ships with two CKEditor Plugins:
- Craft Link: Enables linking to CraftCMS Assets and Entries
- Craft Image: Enables inserting images from the CraftCMS Assets modal
To use this plugin you will need to provide a CKEditor 5 build. Note only "Classic" build has been tested at this time.
To get up and running quickly we've provided a build in the plugins src/web/ckeditor5-custom-build/build
.
Copy the build folder to your web folder:
cp vendor/newism/craft-ckeditor/src/web/ckeditor5-custom-build/build web/ckedior5
Note: This is not for the faint of heart.
Alternatively you can create a custom build here: https://ckeditor.com/ckeditor-5/online-builder/. Copy the custom
build folder to the root of your project and rename it to ckeditor5
.
Once you've created the custom build you'll need to include the Craft CKEditor plugins and toolbar items.
{
"devDependencies": {
"@newism/ckeditor5-craft": "file:../vendor/newism/craft-ckeditor/src/web/ckeditor5-craft-plugin"
}
}
Add the CraftLink
and CraftImage
CKEditor plugins and toolbar items to your ckeditor5/src/ckeditor.js
file:
Import the plugins
import CraftLink from '@newism/ckeditor5-craft/src/craft-link/index.js';
import CraftImage from '@newism/ckeditor5-craft/src/craft-image/index.js';
Include the plugins in your Editor.builtinPlugins
config:
Editor.builtinPlugins = [
CraftLink,
CraftImage,
// Other plugins
// …
];
Add the craftImage
button to the Editor.defaultConfig.toolbar.items
:
Editor.defaultConfig = {
toolbar: {
items: [
"craftImage"
// Other toolbar items
]
}
};
cd ckeditor5 && npm run build