Global Configuration in Admin UI Classic
You can add a Global Configuration for all WYSIWYG Editors for all documents by setting pimcore.document.editables.wysiwyg.defaultEditorConfig.
You can add a Global Configuration for all WYSIWYG Editors for all data objects by setting pimcore.object.tags.wysiwyg.defaultEditorConfig.
For this purpose, you can create a Pimcore Bundle and add the
configuration in a file in the Resources/public directory of your bundle (e.g. Resources/public/js/editmode.js).
pimcore.document.editables.wysiwyg = pimcore.document.editables.wysiwyg || {};
pimcore.document.editables.wysiwyg.defaultEditorConfig = { menubar: true };
This will show you the default menubar from TinyMCE in all document editables.
For the data object settings, you should put them in the startup.js in your bundle.
pimcore.registerNS("pimcore.plugin.YourTinymceEditorConfigBundle");
pimcore.plugin.YourTinymceEditorConfigBundle = Class.create({
initialize: function () {
document.addEventListener(pimcore.events.pimcoreReady, this.pimcoreReady.bind(this));
},
pimcoreReady: function (e) {
pimcore.object.tags.wysiwyg = pimcore.object.tags.wysiwyg || {};
pimcore.object.tags.wysiwyg.defaultEditorConfig = { menubar: true };
}
});
const YourTinymceEditorConfigBundlePlugin = new pimcore.plugin.YourTinymceEditorConfigBundle();
To load the editmode.js file in editmode, you need to implement getEditmodeJsPaths in your bundle class. Given your bundle is named
AppAdminBundle and your editmode.js and startup.js created before was saved to src/AppAdminBundle/public/js/editmode.js and src/AppAdminBundle/public/js/startup.js:
<?php
namespace AppAdminBundle;
use Pimcore\Extension\Bundle\AbstractPimcoreBundle;
class AppAdminBundle extends AbstractPimcoreBundle
{
public function getEditmodeJsPaths(): array
{
return [
'/bundles/appadmin/js/pimcore/editmode.js'
];
}
public function getJsPaths()
{
return [
'/bundles/appadmin/js/pimcore/startup.js'
];
}
}
Registering global configuration via events
You can also add the file which should be loaded in editmode through an event listener to avoid having to implement a
PimcoreBundle just for the sake of adding a file. Given you already have an App bundle and put the JS config from above
to public/js/editmode.js you can create an event listener to add the path to the list of loaded
files in editmode (please see Events for details on how
to implement and register event listeners):
<?php
namespace App\EventListener;
use Pimcore\Event\BundleManager\PathsEvent;
use Pimcore\Bundle\AdminBundle\Event\BundleManagerEvents;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
class EditmodeListener implements EventSubscriberInterface
{
public static function getSubscribedEvents(): array
{
return [
BundleManagerEvents::EDITMODE_JS_PATHS => 'onEditmodeJsPaths'
];
}
public function onEditmodeJsPaths(PathsEvent $event): void
{
$event->addPaths([
'/bundles/app/js/pimcore/editmode.js'
]);
}
}
Loading additional TinyMCE plugins that are not shipped with this bundle
You can load additional plugins that are not shipped by default with Pimcore's TinyMCE bundle.
The following example adds the plugin charmap (Note: Included since Pimcore 11.4):
- Download a TinyMCE dist package matching the version the bundle is currently shipped with.
- Extract the desired plugin from the TinyMCE dist package and place it in your app's or bundle's resource folder,
e.g. copy
js/tinymce/plugins/charmap/plugin.min.jstopublic/static/js/tinymce_plugins/charmap/plugin.min.js. - Use TinyMCE's config option
external_pluginsto load the plugin:
{
// ...
external_plugins: {
charmap: '/static/js/tinymce_plugins/charmap/plugin.min.js',
},
// ...
charmap: [/* ... */], // plugin's configuration
}