Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 17 Next »

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

CKEditor 5 is a widely-used WYSIWYG text editor tailored for web applications. When incorporating CKEditor 5 with content management systems like Drupal, understanding its interaction with filters such as the Basic HTML Filter and Full HTML Filter becomes essential. This knowledge base page sheds light on the primary differences and compatibility of CKEditor 5 with these filters, offering insights into its functionality for content filtering and security within the context of web development.


CKEditor 5 and Basic HTML Filter

  1. Modularity: CKEditor 5 is more modular and modern. 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. 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. 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

  • Available in Text blocks that load the CKEditor

  • Click on the Image button in the toolbar. 

    • Looks like a photo.

  • You will be prompted to upload an image file.

    • Images must be smaller than 5 MB

  • Alternative text field is required

  • Align field is available to set how text wraps around the image

    • Stylings and margins for image alignment will be improved in future CFW3 releases

  • You can make basic changes to an uploaded image by double-clicking on the image to bring up the Image Properties toolbar.

    • Available properties in this modal are very limited and you will not have access to certain fields (width, height, class) as in CFW2.

  • Inline images uploaded in this manner are added to the files managed by Drupal

  • Images are uploaded to an /inline-images directory on your website

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

  • Hover over the image in the editor to locate the move handle found in the upper left corner of the image itself.

  • Your cursor will change to a move icon

  • Click, drag, and release the cursor to your desired location alongside your body text

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.

  • Hover over the image in the editor to locate the resize handle found in the lower corner of the image itself.

  • Your cursor will change to a resize icon

  • Click, drag, and release the handle to your desired dimensions.

  • The modal Image Properties popup for an image does not have width and height fields available due to a Drupal 9 limitation

  • Any specific image dimensions must be made directly in the HTML source

Aligning Inline Images

  • Double-click on the image to bring up an Image toolbar.

  • Select one of the Align options: None, Left, Center, Right

    • Stylings and margins for image alignment will be improved in future CFW3 releases

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 editing content, you should now see the Insert File button in the CKEditor5 toolbar.

  • Use the Insert File button to upload and insert files. You can either select a blank space in Ckeditor5 to designate the file location or you can highlight a piece of text, then select Insert File button to upload and insert files.

  • You will then be prompted to upload a file.

    • Files must be smaller than 5 MB

    • Allowed types: pdf doc docx xls xlsx txt.

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

  • When replacing a file, select the text of the file you want to replace, you should now see the File Toolbar where there is a Replace file button.

  • Use the Replace file dialog window to Remove, then replace with a new file. You must upload a file.

    replace.png

Delete File

  • When deleting a file, select the text of the file you want to delete, you should now see the File Toolbar where there is a Delete file button.

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

  • When the window prompts you “Are you sure you want to delete this file?“ You can now either click OK to accept or Cancel.

  • No labels