As of 11/1/2023, CKEditor 5 is now what is installed in all Drupal sites.

CKEditor is a widely-used WYSIWYG text editor for web applications. It offers different versions, with CKEditor 4 (CKEditor 4.x) and CKEditor 5 (CKEditor 5.x) being two of the most prominent ones. When using CKEditor with content management systems like Drupal, it's important to understand how these versions interact with the Basic HTML Filter and Full HTML Filter, which are commonly used for content filtering and security. This knowledge base page highlights the primary differences between CKEditor 4 and CKEditor 5 in conjunction with these filters.


CKEditor 5 and Basic HTML Filter

  1. Modularity: CKEditor 5 is more modular and modern compared to CKEditor 4. It allows for easy integration with various filters, including the Basic HTML Filter.

  2. Security: CKEditor 5, when used with the Basic HTML Filter, offers enhanced security features, making it more robust against security threats by filtering out potentially harmful code by default.

  3. Customization: CKEditor 5 provides a flexible configuration system, enabling users to customize the editor's toolbar and behavior. This makes it easier to tailor the editor to specific needs.

  4. Accessibility: CKEditor 5 has improved accessibility features out of the box, making it a better choice for ensuring that content created is accessible to all users.


CKEditor 5 and Full HTML Filter

  1. Advanced Editing: CKEditor 5 can be integrated with the Full HTML Filter for users who need advanced content editing capabilities. It allows the use of complex HTML, but with enhanced security features.

  2. Security Enhancements: CKEditor 5, when combined with the Full HTML Filter, maintains a higher level of security compared to CKEditor 4. It mitigates security risks by providing better filtering and validation of user input.

  3. Customization: CKEditor 5 offers extensive customization options for the Full HTML Filter, allowing administrators to define which HTML elements and attributes are allowed, further enhancing content control.


CKEditor 5 Table Styles

Bootstrap is a popular front-end framework that provides a set of pre-designed styles and components to help you create responsive and visually appealing web applications. Out of the box, CKEditor5 did not have options for Table Styles, unlike CKEditor4. Here at Drupal ITS, we included several table styles provided by Bootstrap, including table-striped, table-small, table-bordered, and table-responsive.

Table Striped

The table-striped class in Bootstrap adds zebra-striping to a table, which alternates the background color of rows to make the table easier to read.

Table Small

The table-striped class in Bootstrap adds zebra-striping to a table, which alternates the background color of rows to make the table easier to read.

Table Bordered

The table-bordered class adds borders to the table, making it visually distinct from the surrounding content.

Table Responsive

The table-responsive class makes tables horizontally scrollable on smaller screens to ensure the entire table is visible without the need for zooming or horizontal scrolling.

A table should only be wrapped by a registered parent div element in CKEditor5 such as div.table-responsive. Any other wrapper will break the table toolbar in the CKEditor5 view. For a new table div wrapper, please reach out to Drupal ITS for further enhancements.

<div class="table-responsive">
  <table class="table" data-responsive="enabled">
    <!-- Your table content goes here -->
  </table>
</div>

These Bootstrap table styles can be used individually or combined as needed to enhance the presentation of tabular data in your web application.

Inline Images

It is recommended that you use Paragraph Bundles when dealing with content that has images, as your page’s layout will be more consistent. However, you do have the ability to upload inline images directly inside of CKEditor to add alongside body text.

Uploading Inline Images

When uploading an Inline image, CKEditor will add these attributes:
data-entity-type="file"
data-entity-uuid="random_string_of_characters"
filename="filename.extension"

These attributes are how Drupal ‘knows’ if a file should be Temporary or Permanent. Temporary files are removed with an automatic cron job. If you remove these attributes, the image will be marked Temporary and will still be available until Drupal deletes your image with the next cron.

To check if a file is Temporary or Permanent, check for it on the /admin/content/files page.

Inline Image Placement

Resizing Inline Images

For the best results, it is recommended that your image is already saved at your desired size before you upload. However, you are able to resize your image in the editor.

Aligning Inline Images

Offsite Images

If you are embedding an image that has not been uploaded via CKEditor as above, you will not have the benefit of CKEditor’s image toolbar and features. This is due to Drupal 9’s CKEditor file management integration. 

You will not see any image handles, nor be able to bring up Image toolbar.

All edits to the width, height, and placement must be made inside the source HTML itself. An example of an offsite image might be an image for a logo that isn’t hosted on your website, or an image that was uploaded on a separate webpage of your website.

Inline Files

2024-03-05_15-07-06.png

Uploading Inline Files

When uploading an inline file, CKEditor5 will add these attributes:
data-entity-type="file"
data-entity-uuid="random_string_of_characters"
href="filename.extension"

These attributes are how Drupal ‘knows’ if a file should be Temporary or Permanent. Temporary files are removed with an automatic cron job. If you remove these attributes, the image will be marked Temporary and will still be available until Drupal deletes your image with the next cron.

To check if a file is Temporary or Permanent, check for it on the /admin/content/files page.

Replace File

Delete File

2024-03-06_13-53-58.png