One of the features of CKEditor is that it has an API, which allows to extend the editor with more functionality. In this post I will show you, how you can add CKEditor plugins to the TYPO3 implementation.

The last post about CKeditor  was about the basic configuration of the editor. Todays post is about how to extend the editors functionality with add-on. There are only four steps to add more functionality to the new RTE CKEditor in TYPO3.

Provide a place to serve the add-on

There must be a place where the add-on will be loaded from. This might be an existing template extension or, in case it should be published on the TER (TYPO3 Extension Repository), a slim extension.

Basically such an add-on provider extension only must include

  • ext_emconf.php
  • composer.json (if it should be installable via composer, which is highly recommended)
  • the plugin code in the directory “Resources/Public/JavaScript/Plugins/”
  • the editor configuration in “Configuration/RTE” ans
  • an extension icon

Provide the js code

The add-on sources must reside in the directory Resources/Public/JavaScript/Plugins/. The file and directory structure must be copied to here without any modification as the javascript code depends on this structure.

Provide the RTE config

The second step is to provide the rte config and to tell the CKEditor where to find the add-on. It is a very small yaml file with the following content:

It is possible to provide more than one plugin. This is done by repeating the <myplugin> section with other values.

If other values than the default values of the provided plugin, these must be set on the same level as the value for “resource”.

Import the config in a RTE preset

The following yaml configuration must be inserted into a preset, that can be applied in an installation and be happy to use it.

Currently the configuration of your preset of an plugin will be always overwritten. This is IMHO a bug. I filed a report on forge and also provided a patch to fix this on review.typo3.org. (I’d be happy if you could review and test the patch 😉 ) .

Example extension

Often it is easier to have a working example. So I created an extension, which is available at github. It provides the wordcount add-on, which is able to show several metrics about words, characters and paragraphs, while typing the content.

The add-on itsself resides at http://ckeditor.com/addon/wordcount. The extension can be installed via composer or can be downloaded from github.

Conclusion

Thanks to Riccardo di Contardi, who pointed me to this topic, which was on my mind since a couple of weeks.

Thanks to Netresearch, who published an add-on extension for the CKEditor, which allows you to add images within the CKEditor. It is available on Github and via TER. This extensions served me as some kind of blue print for the example on github. Thank you!

I hope, that this post has been interesting for you. If so or if you know somebody, who will profit from it, please share this post via your favorite social network. For your convenience I added some share buttons at the end of this page.

Credits
I found the blogpost image on unsplash. It was created by Sergey Zolkinand published unter the “Unsplash license“. I modified it using the service of Pablo on Buffer