Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

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 the 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.

...

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 Bootstrap provided by Bootstrap, including : table-striped, table-small, table-bordered, and table-responsive.

...

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 small class in Bootstrap adds zebra-striping to a table, which alternates the background color of rows to make the table easier to readcondenses the size of the table.

...

Table Bordered

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

...

Info

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 contact Drupal ITS for further enhancements.

...

Info

These Bootstrap table styles can be used individually or combined as needed to enhance the presentation of tabular data presentation 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 can upload inline images directly inside of CKEditor to add alongside body text.

...

  • 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 The 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

Note

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.

...

  • Hover over the image in the editor to locate the move handle found in the image's 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 can 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

...

If you are embedding an image that has not been uploaded via CKEditor as above, you will not have the benefit of from 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 will you be able to bring up the Image toolbar.

All edits to the width, height, and placement edits 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

...

Uploading Inline Files

  • When editing content, you You should now see the Insert File button in the CKEditor5 toolbar when editing content.

  • 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 the 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.

Note

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.

...

  • 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 it with a new file. You must upload a file.

    replace.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.

Inserting Bootstrap Icons and Font Awesome Icons

...

Info

To use this functionality, your site must have either icon option (or both) enabled in your theme. See the image below for where these settings are located in your theme. If you need help enabling this, please contact the ITS Drupal Team.

...

  • When inserting icons, you should hard code the icons by switching to Source mode (Full HTML) in the CKEditor5 toolbar.

  • Once you are in Source mode. You can now hard code any Bootstrap Icon and or Font Awesome Icon by wrapping them it with an a <p> tag and <em> tag and adding a %nbsp; inside the <i> tag. See below for an example.

...

  • To verify they are ‘sticky’, switch back to WYSIWYG mode, and the icon should be visible. Then switch to Source again and make sure the code is there.

Note: If no text is present (ie, only an icon), CKEditor removes everything. We believe this ‘design’ feature in CKEditor does not allow empty content.

Note: The &nbsp; is required inside the <i></i> tag, or CKEditor will remove the entire tag.

Info

For more information on finding the right icon for you, please refer back to the Bootstrap Icons and Font Awesome Icons libraries online.

Line Break and Empty Paragraph Handling in CKEditor 5

In CKEditor5, the automatic insertion of <br> tags typically occurs due to the editor’s handling of line breaks and empty paragraphs. This behavior is part of the editor’s design to ensure proper formatting and a consistent user experience.

Three Reasons Why CKEditor5 does Automatic <br> Insertions:

Empty Paragraph Handling
CKEditor5 often inserts <br> tags in empty paragraphs to maintain consistency and ensure that empty lines are rendered properly.

Soft Line Breaks
When users press Shift+Enter, CKEditor5 inserts a <br> tag to create a line break within the same paragraph rather than ending the paragraph.

Browser Compatibility
Different browsers handle empty elements and line breaks in varying ways. CKEditor5 uses <br> tags to standardize this behavior across all browsers.