Hier fand ich eine Lösung, um CKEditor anzupassen und Plugins wie FontAwesome hinzuzufügen.
Zuerst müssen wir Fett Erweiterung erstellen.
Erstellen Sie den Erweiterungsordner /extension/local/mycompany/customckeditor
.
In diesem Erweiterungsordner müssen wir Unterordner erstellen
Nachdem wir Datei Bolt Erweiterung erstellen müssen src/CustomCkeditorExtension.php
<?php
namespace Bolt\Extension\MyCompany\CustomCkeditor;
use Bolt\Asset\File\JavaScript;
use Bolt\Extension\SimpleExtension;
use Bolt\Controller\Zone;
/**
* Custom CKEditor extension class.
*/
class CustomCkeditorExtension extends SimpleExtension
{
/**
* {@inheritdoc}
*/
protected function registerAssets()
{
$asset = new JavaScript();
$asset->setFileName('/extensions/mycompany/customckeditor/ckeditor-extended.js')
->setLate(true)
->setPriority(99)
->setZone(Zone::BACKEND);
return [
$asset,
];
}
}
Erstellen
Komponist Datei /extension/local/mycompany/customckeditor/composer.json
{
"name": "mycompany/customckeditor",
"description": "An extension to allow for CKEditor customisations.",
"type": "bolt-extension",
"keywords": [
"ckeditor"
],
"require": {
"bolt/bolt": "^3.2"
},
"require-dev": {
"phpunit/phpunit": "^4.7"
},
"license": "MIT",
"authors": [
{
"name": "Bogdan",
"email": "[email protected]"
}
],
"minimum-stability": "dev",
"prefer-stable": true,
"autoload": {
"psr-4": {
"Bolt\\Extension\\MyCompany\\CustomCkeditor\\": "src"
}
},
"extra": {
"bolt-assets": "web",
"bolt-class": "Bolt\\Extension\\MyCompany\\CustomCkeditor\\CustomCkeditorExtension"
}
}
Gehen Sie zu Ihrer Konsole zu /extensions
Ordner und führen:
$ composer update
erstellen JS-Datei /web/ckeditor-extended.js
if (typeof CKEDITOR !== 'undefined') {
CKEDITOR.dtd.$removeEmpty['span'] = false;
}
jQuery(document).ready(function ($) {
var CKEDITORPluginExtras = false;
if (typeof(CKEDITOR) != 'undefined') {
CKEDITOR.plugins.addExternal('fontawesome', '/extensions/mycompany/customckeditor/plugins/fontawesome/plugin.js', '');
CKEDITOR.on('instanceReady', function (event, instance) {
if (CKEDITORPluginExtras) {
return;
}
var config = event.editor.config,
name;
config.toolbar.push(
{ name: 'insert', items: [ 'FontAwesome' ] }
);
config.contentsCss.push(CKEDITOR.plugins.getPath('fontawesome') + 'font-awesome/css/font-awesome.min.css');
config.extraPlugins += (config.extraPlugins ? ',' : '') + 'widget,fontawesome';
for (name in CKEDITOR.instances) {
if (CKEDITOR.instances.hasOwnProperty(name)) {
CKEDITOR.instances[name].destroy();
CKEDITOR.replace(name, config);
}
}
CKEDITORPluginExtras = true;
});
}
});
Kopieren fontawesome.zip
Inhalt /web/plugins
Und schließlich laden Sie Ihr Admin-Panel neu.