Jump to content

Text Editor keeps deleting code


Lastwolf

Recommended Posts

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
Link to comment
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
Link to comment
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
Link to comment
Share on other sites

  • 4 months later...

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

Link to comment
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.

Link to comment
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.

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...