Submitted by admin on Thu, 06/08/2023 - 06:48
Do you feel annoying when CKEditor in Drupal keeps on changing your HTML code?
Sometimes you have HTML code that must be preserved in order to work. You are as the administrator, have no problems with code security. But when you paste your code, CKEditor in Drupal filters or alters your code structure, and it does not work as expected.
Some of the examples of HTML code altered:
- <a> can't wrap around <div>
- <img> tag can't stand alone, it is wrapped with <p>
- empty <span>, <i>, <div> is not allowed
- and etc ...
The workaround is quite simple:
- Please browse Admin - Configuration - Content Authoring - Text formats and editors, select + Add text format
- Then please create a new text format, "Full HTML withour CKeditor" for example,
- Set it for administrator only, select editor as None, and don't check any options. Below is the screenshot of a Drupal 10 site:
- When edit your content, please select this new format option, then you are able to paste your HTML code without being modified by CKEditor
Good luck and have fun with Drupal.