N1ED Blog

CKEditor modules in Drupal 8

02 September 2019

This article shows how you can extend functionality of CKEditor in Drupal 8, and also explains peculiarities of Drupal 8 architecture and the official CKEditor module.

Text formats in Drupal 8

CKEditor is completely integrated to the existing editing mechanisms of Drupal. Whenever a user edits an HTML content in the edit box (be that just a comment or an article content), the CMS loads the editor corresponding to the given role of the user. If the role of the user permits several editing options, the combo box allows switching between them. In Drupal, each such editor option with all the associated settings is called the text format.

In order for a user (either authorized or anonymous) to use CKEditor in some textbox of a form, the following conditions must be met:

  • 1. The CKEditor module must not be disable or deleted

    By default CKEditor is active unless you disabled it manually.

  • 2. In the ConfigurationText formats section, there must be a format where CKEditor is specified as an editor

    If you do not have a format with CKEditor (for example, if you used the Minimum installation option in Drupal 8), then create a new format and specify Editor: CKEditor in it.

  • 3.The current user must have enough permissions to use this format

    To configure this, open the format settings and in the Roles box set checkmarks near user types this format should be available to.

CKEditor plugins in Drupal

Unlike previous versions of Drupal, in 8th version you cannot simply copy a CKEditor plugin and then enable it in the config. The entire plugin connection process as well as extraPlugins config option control is automated and delegated to the CKEditor module.

The CKEditor module for Drupal finds all installed CKEditor add-ons in the system and plugs them in. So, to make the CKEditor module find a particular plugin, you should install the corresponding Drupal module first. Such a module is basically a wrapper for the plugin, and it simply tells the CKEditor module for Drupal what this plugin is and what settings it has. Also, it includes a component to visually configure these settings. Hence, connecting a CKEditor plugins that does not have a corresponding Drupal module is not possible. On the other hand, if the plugin is popular and is supported, it surely has a module, so this is a win-win situation.

It is worth mentioning that the module itself does not contain JavaScripts of the plugin. They should be copied manually to the libraries/ directory in the installation folder of the website. This is for a purpose and in compliance with the architecture of Drupal and the CKEditor module. Specifically, to allow you update the plugin independently of its module.

Install N1ED on your Drupal website

The easiest way to install N1ED is to use Installation Wizard. It will lead you through all these steps to the perfect editor on your website. Your first installation should be done using Wizard due to it will register a free API key for you.

Install now

If an article is useful, please share