When I click out of "Source" mode and then back to it, my code changes to the example below. This renders the AddThis widget incorrectly

<!-- AddThis Button BEGIN -->
<div class="addthis_toolbox addthis_default_style"></div>
<script type="text/javascript">var addthis_config = {"data_track_addressbar":true};</script>
<script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js#pubid=ra-4fbe53be7786769b"></script>
<!-- AddThis Button END -->

This is the original code before it got changed:

<!-- AddThis Button BEGIN -->
<div class="addthis_toolbox addthis_default_style">
<a class="addthis_button_facebook_like" fb:like:layout="button_count"></a>
<a class="addthis_button_tweet"></a>
<a class="addthis_button_google_plusone" g:plusone:size="medium"></a>
<a class="addthis_counter addthis_pill_style"></a>
</div>
<script type="text/javascript">var addthis_config = {"data_track_addressbar":true};</script>
<script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js#pubid=ra-4fbe53be7786769b"></script>
<!-- AddThis Button END -->
CommentFileSizeAuthor
#4 missing.jpg12.28 KBkrymp
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

krymp’s picture

bump

mkesicki’s picture

Status: Active » Closed (works as designed)

It looks that CKEditor 'strips' invalid a tags. CKEditor always validate code to proper HTML.
This option can not disabled. I will consult this case with CKEditor developers.

mkesicki’s picture

One more thing:
As a workaround you can change
<a class="addthis_button_tweet"></a>
to
<a class="addthis_button_tweet"> &nbsp;</a>
Than editor will not remove your code.

krymp’s picture

FileSize
12.28 KB

I've tried adding

&nbsp;

But it still renders the section incorrectly. Part of the widget is missing now. See attached image.

I suspect it may have something to do with the 2 class names here:

<a class="addthis_counter addthis_pill_style">&nbsp;</a>

mkesicki’s picture

@krymp this code from attached image is from 'inside' CKEditor or after save a node with your code ?
Can you try paste your code (with &nbsp;) into source mode and than check what happens after change to wysiwyg mode ?

krymp’s picture

Before:

<!-- AddThis Button BEGIN -->
<div class="addthis_toolbox addthis_default_style">
<a class="addthis_button_facebook_like" fb:like:layout="button_count">&nbsp;</a>
<a class="addthis_button_tweet">&nbsp;</a>
<a class="addthis_button_google_plusone" g:plusone:size="medium">&nbsp;</a>
<a class="addthis_counter addthis_pill_style">&nbsp;</a>
</div>
<script type="text/javascript">var addthis_config = {"data_track_addressbar":true};</script>
<script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js#pubid=ra-4fbe53be7786769b"></script>
<!-- AddThis Button END -->

After

<!-- AddThis Button BEGIN -->
<div class="addthis_toolbox addthis_default_style"><a class="addthis_button_facebook_like" fb:like:layout="button_count">&nbsp;</a> <a class="addthis_button_tweet">&nbsp;</a> <a class="addthis_button_google_plusone" g:plusone:size="medium">&nbsp;</a> <a class="addthis_counter addthis_pill_style">&nbsp;</a></div>
<script type="text/javascript">var addthis_config = {"data_track_addressbar":true};</script><script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js#pubid=ra-4fbe53be7786769b"></script><!-- AddThis Button END -->

It looks like it retains the code, but it fails to display the last a class correctly. (see screenshot from previous post)

Yuri’s picture

It still happens, ckeditor just deletes any content when switching in and out of source mode.

Any progress here??

wooody’s picture

Hi,
Try to Go to modules/ckeditor/ckeditor.config.js file and add this line :
config.allowedContent = true;

and check your textformat if you allow the tags there.

wooody’s picture

Issue summary: View changes

added code tags

bdombro’s picture

Agree with Wooody, but here are some more instructions I got from this question:
https://drupal.org/comment/7706699#comment-7706699

Posted by John Carbone on July 31, 2013 at 5:41pm
I didn't see anyone mention this method but you can customize CKEditor in the module's settings like so. Use this for any filter format you need to adjust. This assumes you just want to ignore the new feature in CK and let Drupal handle stripping tags using the filter system as usual.

admin/config/content/ckeditor/edit/Full
->
ADVANCED OPTIONS
->
Custom JavaScript configuration
->
Paste in:
config.allowedContent = true;

SAVE

kenorb’s picture

cabplan’s picture

#9 suggestion worked for me, thank you!!!

my_super_username’s picture

i have something strange also...

using fresh install of D7, wysiwyg + wysiwyg_ckeditor modules and insert module and colorbox module.
when im trying to insert some picture with insert module feature using some colorbox styles in ckeditor - it does nothing. it works only if im inserting some picture with no styles. seems strange cause few years ago it worked well, i tested it :)

so im editing my text with ckeditor, then switching to "Plain text" mode, inserting image with colorbox styles and then back to "Full HTML" mode and save. too complicated, dont you think so? :) especially for my content manager who is not so familiar with html (telling honest i need ckeditor features just for this person)
and even after that if i rightclick at image to edit something like text alignment or so, and all styles that were before - will gone :)

i think its because insert module inserts something like
<a hreff=original_image><img src=colorbox_thumbnail></a>

sorry if i choose the wrong issue branch or something... just commented the most similar i found :)

jatorresdev’s picture

#9 Work for me thanks