TinyMCE icon indicating copy to clipboard operation
TinyMCE copied to clipboard

unable to use templates, html is "cleaned" by Tiny as soon as inserted

Open elz64 opened this issue 13 years ago • 6 comments

While I setup everything to get the tpl button in tiny, and being happy it works puddy well displaying the html templates I made... Once chosen, the tpl code is here in the template plugin pop up windows (I can inspect its html markup) But: as soon as it is validated and inserted in the editing area of tiny, I can see this code as been "cleaned" and the only thing actually inserted in the doc is a new

(whatever the tpl html was).

Really need a solution.

Thank you

elz64 avatar May 31 '12 15:05 elz64

Same problem here... :-(

kudykam avatar Aug 16 '12 09:08 kudykam

Same problem also..

Tracing through template/editor_plugin.js thinking this is where the problem might lay. I stumbled upon this.. http://forums.modx.com/index.php?topic=61467.msg%msg_id% However, it did not solve my issue..

Tracing through tiny_mce_src.js I discovered around line 11743:

   t.startContent = t.getContent({format : 'raw'});

t.getContent({format : 'raw'}) is only returning my templates root element..

Any ideas why this is happening?

case303 avatar Aug 28 '12 17:08 case303

I am using Joomla! with tinymce version: 3.5.2. However, found some success editing tiny_mce.js

Specific edits: approx. line #11251

//----- Original code
if(!G.invalid){
//  K=J.serialize(F);
//  A=E.firstChild;
//  M=E.lastChild;
//  if(!A||(A===M&&A.nodeName==="BR")){
//      m.setHTML(E,K)
//  }else{
//      p.setContent(K)
//  }

//----- changed to
if(!G.invalid){
      p.setContent(K);

and approx. line #2831

//----- Original code
if(z&&M.length){
    if(!m.context){
        j(M)

//----- changed to
    if(m.context){

setContent() was never called within mceInsertContent, only setHTML(). It appears to me that tinymce's parse function is not comparing inserted elements with acceptable elements correctly.. thinking standard tags were invalid.. Also, stripping templates tags when serializing..

Hopefully this leads to a proper solution..

case303 avatar Aug 28 '12 22:08 case303

Hey, is it html5 code you have in your template? It seems to be cleaned up by tiny (the version used by the modx package). See: http://forums.modx.com/thread/?thread=78709&page=1

wuuti avatar Nov 21 '12 09:11 wuuti

I have the same issue using TinyMCE 4.3.3, Revo 2.2.7-pl. If I have HTML5 tags in the template they are stripped out completely, which I expected because I don't think TinyMCE supports HTML5 yet. But when I use lowly old paragraph tags in the template, with content in between the tags such as images or text, the content is stripped out and the paragraph tags are inserted empty. Before inserting the template it displays in the preview window perfectly.

LucyI avatar Sep 12 '13 19:09 LucyI

Had the same issue using TinyMCE 4.3.3, Revo 2.2.10-pl. Found that template content is stripped when it contains HTML attribute class.

For example, my template contained:

<ol class="steps">
    <li>Step1</li>
    <li>Step2</li>
</ol>

As usual - it showed up in preview, but after clicking Insert button everything was gone. Nothing really was inserted.

After removing class atribute, my template looked like this:

<ol>
    <li>Step1</li>
    <li>Step2</li>
</ol>

This was working fine. But didn't satisfied my needs. I desperately needed a template with class attribute.

Found a solution. You need to provide some class name for this setting: tiny.template_selected_content_classes It's empty by default and that's why template content is stripped. When you enter some CSS class name (I used fake one), everything works great again. So my setting looked like this:

tiny.template_selected_content_classes  .fakeCssClass

Important! Dot (.) before class name is the key. When using class name like this: fakeCssClass (without dot in front), nothing worked.

Hope this helps!

keidzi avatar Jan 23 '14 08:01 keidzi