Jump to content

[SOLVED]TinyMCE removes HTML tags


Recommended Posts

Hi, prestashop community. I've been trying to edit the HTML code using prestashop's integrated TinyMCE Editor, but it keeps removing my html tags oce I click on the ok button.

 

I've already tried to solve this by modyfing validate.php isCleanHtml() function, but it keeps doing it again and again :/.

 

Any other trick (besides editing the entry directly in the database) that you could share with me to get this done?

 

Thanks in advance.

Edited by moy2010 (see edit history)
Link to comment
Share on other sites

Yep, just gone :/.

 

My code looks like this:

<h4><a>Title Here</a></h4>

 

I'm trying to insert a <span> tag within that, like this:

<h4><a><span>Title Here</span></a></h4>

 

But everytime I do this, it removes the <span> tag no matter what I do or where do I place it :S. This happens only to the <span> tag.

Edited by moy2010 (see edit history)
Link to comment
Share on other sites

  • 3 months later...

WHat if you try this

 

<span class="emptyClass">

 

Hello,

 

This doesn't work for me.

I have a similar issue. Just that instead of span I use an empty <em class="someClass"></em>. On one product this worked but on another when I hit ok on source code editor the <em> is removed. There doesn't seem to be a reason why on one products this worked and another it doesn't.

Does this trick work on all products for you guys?

Link to comment
Share on other sites

Maybe it's contained in a different tag?

 

Hey, thanks for replying. Btw I have watched some of your youtube videos and read a couple of your tutorials and they are awesome. Keep up the good work.

 

Yes, it was contained in a <div> tag. However I noticed that it's doing this on Firefox. After messing around with Tinymce plugin to try to find and remove the JS code handling the "ok" button I tried it in Google Chrome and it didn't remove any markup.

I have no idea why it behaves this way on Firefox and on Chrome works.

 

I'm thinking of removing tinymce as I'm mostly writing html in the decription of my products.

 

So in conclusion if anyone else has this issues and what Nemo suggested doesn't work, the simplest thing to try is in another browser.

Link to comment
Share on other sites

  • 1 month later...
  • 5 weeks later...

Prestashop 1.6.1, but I guess the solution applies to all versions.
You have to make changes in tinymce config file: prestashop/js/admin/tinymce.inc.js
 
In default_config of tinymce two options should be added and set to false:

is:

...
        entity_encoding: "raw",
        extended_valid_elements : "em[class|name|id]",
        valid_children : "+body[style], +style[type]",
        menu: {
            edit: {title: 'Edit', items: 'undo redo | cut copy paste | selectall'},
            insert: {title: 'Insert', items: 'media image link | pagebreak'},
            view: {title: 'View', items: 'visualaid'},
            format: {title: 'Format', items: 'bold italic underline strikethrough superscript subscript | formats | removeformat'},
            table: {title: 'Table', items: 'inserttable tableprops deletetable | cell row column'},
            tools: {title: 'Tools', items: 'code'}
        }
...

should be:

...
        entity_encoding: "raw",
        extended_valid_elements : "em[class|name|id]",
        valid_children : "+body[style], +style[type]",
        apply_source_formatting : false,                //added option
        verify_html : false,                            //added option
        menu: {
            edit: {title: 'Edit', items: 'undo redo | cut copy paste | selectall'},
            insert: {title: 'Insert', items: 'media image link | pagebreak'},
            view: {title: 'View', items: 'visualaid'},
            format: {title: 'Format', items: 'bold italic underline strikethrough superscript subscript | formats | removeformat'},
            table: {title: 'Table', items: 'inserttable tableprops deletetable | cell row column'},
            tools: {title: 'Tools', items: 'code'}
        }
...

You're welcome.

 

  • Like 1
Link to comment
Share on other sites

Prestashop 1.6.1, but I guess the solution applies to all versions.

You have to make changes in tinymce config file: prestashop/js/admin/tinymce.inc.js

 

In default_config of tinymce two options should be added and set to false:

 

is:

...
        entity_encoding: "raw",
        extended_valid_elements : "em[class|name|id]",
        valid_children : "+body[style], +style[type]",
        menu: {
            edit: {title: 'Edit', items: 'undo redo | cut copy paste | selectall'},
            insert: {title: 'Insert', items: 'media image link | pagebreak'},
            view: {title: 'View', items: 'visualaid'},
            format: {title: 'Format', items: 'bold italic underline strikethrough superscript subscript | formats | removeformat'},
            table: {title: 'Table', items: 'inserttable tableprops deletetable | cell row column'},
            tools: {title: 'Tools', items: 'code'}
        }
...

should be:

...
        entity_encoding: "raw",
        extended_valid_elements : "em[class|name|id]",
        valid_children : "+body[style], +style[type]",
        apply_source_formatting : false,                //added option
        verify_html : false,                            //added option
        menu: {
            edit: {title: 'Edit', items: 'undo redo | cut copy paste | selectall'},
            insert: {title: 'Insert', items: 'media image link | pagebreak'},
            view: {title: 'View', items: 'visualaid'},
            format: {title: 'Format', items: 'bold italic underline strikethrough superscript subscript | formats | removeformat'},
            table: {title: 'Table', items: 'inserttable tableprops deletetable | cell row column'},
            tools: {title: 'Tools', items: 'code'}
        }
...

You're welcome.

 

Thank you for sharing :)

Link to comment
Share on other sites

  • 1 year later...

I'm running PS 1.6 but there is no such file, /js/admin/tinymce.inc.js

 

The closest I can find is /js/tiny_mce/tinymce.min.js 

 

But that file doesn't contain the right code to modify. Not to mention it's almost impossible to read because it's minified with all the line breaks removed.

Link to comment
Share on other sites

  • 2 years later...

My apology for hijacking this post but it doesn't make sense to me to wrap (part of) a paragraph or a header text in a <span>bla bla</span> if their isn't a class or style for it. What for the whole span thing?

That said, there are some interesting replies for the original issue, which raises the question why those actions may need to be taken.

Wouldn't is make more sense for the developers to look into their code because it all appears to me being a poor coding issue. 

Just a thought.

Link to comment
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
×
×
  • Create New...