Jump to content
Lastwolf

Text Editor keeps deleting code

Recommended Posts

<i class="fa fa-arrow-circle-right" aria-hidden="true"></i>

I have that in one of my descriptions, if I save while still in "Source" it'll work just fine, as long as I never try to preview it, which means if I view it to edit, it's gone again.

Share this post


Link to post
Share on other sites

It can be a pain as it removes html that your browser doesn't think is valid.

It might be worth asking at the CKEditor website as there will be more specialists there.

Share this post


Link to post
Share on other sites

I am looking at the CKEditor API docs, specifically the Advanced Content Filter (ACF) to determine the pattern rule that the editor will accept.

The rule will either be that characters are required between the open and close tags, or the element has disallowed any attributes, styles, and/or classes. It is probably a combination of both.

On the other hand, the editor's config.js file specifically sets 'allowedContent' to "true", and this (supposedly) switches off the filtering - allowing anything to be entered.

On the third hand, the ACF filters "pasted" content from the clipboard. Content already present (loaded on editor initialization or currently being edited) is managed by other sets of rules.

Edited by bsmither

Share this post


Link to post
Share on other sites

Try this:

In includes/ckeditor/config.js, at the bottom, find:

	config.allowedContent = true;
};


Change to:

	config.allowedContent = true;
	config.coreStyles_italic = {element : 'em'};
	config.extraAllowedContent = 'i[*]{*}(*)';
};
CKEDITOR.dtd.$removeEmpty = '{i: 0}';

The same added statements can be used for other HTML tags used in unorthodox ways.

  • Like 2

Share this post


Link to post
Share on other sites

Yeah, that does the trick, thanks, as always bsmither you are a font of problem solving.

 

On using it more, it's doing some weird things, but it's workable, for some reason it keeps hard forcing a linebreak like a <br> but not visable anywhere. 

 

I looked for solutions on ckeditor forums, but they seem to really break it hard and it just spams every blank space with the <i class

Edited by Lastwolf
  • Like 1

Share this post


Link to post
Share on other sites

Could you better explain the linebreak issue? And I do not understand the last sentence.

Share this post


Link to post
Share on other sites

I was talking nonsense, so it's not surprising you didn't understand.

 

It was another part of my css that wasn't set to  "display: inline;" so it was sitting below where I wanted.

Share this post


Link to post
Share on other sites
Just now, foz1234 said:

Surprised this edit was not added to 6.2.1

 

Nobody raised an issue on GitHub. If they did it didn't make the release for whatever reason.  

Share this post


Link to post
Share on other sites

the above edit no longer seems to work in 6.2.1, when i add google AdSense script into a source page/box it changes the code after save from this:-

<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- Right Box #3 content -->
<ins class="adsbygoogle"
     style="display:block"
     data-ad-client="ca-pub-xxxxxxxxxxx"
     data-ad-slot="2445020xxx"
     data-ad-format="auto"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>

to this

<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script><!-- Right Box #3 content --><script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>

using the above edit in 6.1.x seemed to work and it saved the code as is

Share this post


Link to post
Share on other sites

The above solution was for a specific situation (<i> tags used for Font Awesome).

Please determine if the technical docs for this "adsbygoogle" require the use of the <ins></ins> tag pair. If not, try using a <div></div> tag pair.

Share this post


Link to post
Share on other sites

Hi Brian, I posted about this previously and you recommended looking at this thread here

On previous version the edit worked but no longer seems to work in 6.2.1

Share this post


Link to post
Share on other sites

I have yet to install CC621, but a CC620 installation gets me this:

<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script><!-- Right Box #3 content -->
<p><ins class="adsbygoogle" data-ad-client="ca-pub-xxxxxxxxxxx" data-ad-format="auto" data-ad-slot="2445020xxx" style="display:block"></ins> <script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script></p>

This is after having made the edits to config.js as described earlier. Specifically, the $removeEmpty being switched off. (Since a change has been made to this file, be sure to force your browser to reload it - usually with CTRL-F5.)

Note that CKEditor still wants to wrap things in <p></p> tags.

 

Share this post


Link to post
Share on other sites

Hi Brian, sorry mate it must have been a cache issue just opened it this morning and now the code is showing correctly.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×