1

Ckeditor is stripping out all attributes from the source code.

This is the case I'm going through: When I add html code to the source of the Ckeditor, and then want to preview the changes by selecting source again, I find that no styling was taken. When I go back to check the source all styling attributes are removed and some HTML tags.

I found a way to save the content, without stripping by directly saving after pasting the html code in the source. But if I try to re-edit the content it strips all styling attributes and some html tags.

I am using Full HTML Text format, and did try previous versions of the ckeditor module. Also tried to modify the config.js file by adding "config.allowedContent = true;" as referred by the following post

<nav class="footer-wrapper"><section class="col-md-3">
<h3 class="block-title h5">
  About
</h3>
<ul class="list-unstyled"><li>
    <a href="/bio" title="">Biography</a>
  </li>
  <li>
    <a href="/timeline" title="Plans and Billing">Timeline</a>
  </li>
  <li>
    <a href="/quotes" target="_blank">Quotations</a>
  </li>
  <li>
    <a href="/philo" target="_blank" title="">Philosophy</a>
  </li>
</ul></section>

CKeditor Stripped HTMl:

<p>About</p>
<ul>
    <li><a href="/bio" title="">Biography</a></li>
    <li><a href="/timeline" title="Plans and Billing">Timeline</a></li>
    <li><a href="/quotes" target="_blank">Quotations</a></li>
    <li><a href="/philo" target="_blank" title="">Philosophy</a></li>
</ul>
<p>Intellectual Legacy</p>

Any way to resolve the following?

  • Which version of Drupal are you using? – Aram Boyajyan Mar 8 '16 at 13:45
  • Drupal 7.42 and latest ckeditor module and js – Hicham Mar 8 '16 at 14:06
2

You shouldn't really hack the config.js file. You can pass any custom configuration values through the admin:

  1. Go to /admin/config/content/ckeditor.

  2. Click on the "Edit" link next to the profile you are working with.

  3. Expand the "Advanced options" fieldset.

  4. Enter the following code in the "Custom JavaScript configuration":

    // Instruct CKEditor to disable the filter. You can also limit this to specific tags.
    config.allowedContent = true;
    // Allow p, div, li and ul tags to have any attributes attached to them.
    config.extraAllowedContent = 'p(*)[*]{*};div(*)[*]{*};li(*)[*]{*};ul(*)[*]{*}';
    

See docs for CKEDITOR.config.allowedContent and CKEDITOR.config.extraAllowedContent. If you are insterested in having this in every Drupal installation, check out my Drupal 7 installation profile.
The file in question is here.

Hope this helps.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.