Extended tinyMCE rich text editor in prestashop 1.6

PrestaShop 1.6  uses a bit different method to generate tinyMCE rich text editor than older releases of PS engine. The most important thing now is fact, that editor is executed from one file, not from many different files as it was before . This is definitely an advantage of new engine, because you can easily extend editor globally , for whole shop. It just mean that one file decides how the textbox tinyMCE editor looks like for product description, short description, category descriptions, cms page editor etc. Tutorial for PrestaShop 1.7 is available here: Rich text editor in PrestaShop 1.7. If you dont want to alter files by yourself - you can try our module that does everything + includes some additional not available in this article features: tinyMCE pro - extended rich text editor in PrestaShop



extended rich text editor prestashop 1.6



How to change simple text editor to full featured editor?

In this prestashop version it's very easy. As i already mentioned it's necessary to modify only one file. This file is a js (javascript) file with tinymce execurtion and configuration code. Path to this file is: /js/tinymce.inc.js or  /js/admin/tinymce.inc.js  So, please open this file and change whole file contents to:


function tinySetup(config)
   if (typeof tinyMCE === 'undefined') {
      setTimeout(function() {
      }, 100);
        config = {};
    var editor_selector = 'rte';
    //if (typeof config['editor_selector'] !== 'undefined')
    //var editor_selector = config['editor_selector'];
    if (typeof config['editor_selector'] != 'undefined')
        config['selector'] = '.'+config['editor_selector'];
        default_config = {
        selector: ".rte" ,
        plugins : "visualblocks, preview searchreplace print insertdatetime, hr charmap colorpicker anchor code link image paste pagebreak table contextmenu filemanager table code media autoresize textcolor emoticons",
        toolbar2 : "newdocument,print,|,bold,italic,underline,|,strikethrough,superscript,subscript,|,forecolor,colorpicker,backcolor,|,bullist,numlist,outdent,indent",
        toolbar1 : "styleselect,|,formatselect,|,fontselect,|,fontsizeselect,", 
        toolbar3 : "code,|,table,|,cut,copy,paste,searchreplace,|,blockquote,|,undo,redo,|,link,unlink,anchor,|,image,emoticons,media,|,inserttime,|,preview ",
        toolbar4 : "visualblocks,|,charmap,|,hr,",
        external_filemanager_path: ad+"/filemanager/",
        filemanager_title: "File manager" ,
        external_plugins: { "filemanager" : ad+"/filemanager/plugin.min.js"},
        extended_valid_elements: 'pre[*],script[*],style[*]', 
        valid_children: "+body[style|script|iframe|section],pre[iframe|section|script|div|p|br|span|img|style|h1|h2|h3|h4|h5],*[*]",
        valid_elements : '*[*]', 
        force_p_newlines : false, 
        cleanup: false,
        forced_root_block : false, 
        force_br_newlines : true,  
        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'}
    $.each(default_config, function(index, el)
        if (config[index] === undefined )
            config[index] = el;
$().ready(function() {


Extended tinyMCE rich text editor in PrestaShop 1.6

tinyMCE rich text editor full featured prestashop 1.6


And you know what? that's all! Now your tinyMCE rich text editor will be with many new features! For each apge in your back office! Your editor will accept javascripts, iframes and other stuff that with default editor is automatically removed. The only one thing you have to do now is validate.php class change . It's because by default while "saving" new contents you will see this error (for example, for product description):

The description_short field (English (English)) is invalid.


Validate.php class change

It's also easy. Open file: /classes/Validate.php and search for isCleanHtml function. This function is a textbox contents validate function. It removes unaccepted code from textboxes witch rich text editor. We must change this function from:

    public static function isCleanHtml($html, $allow_iframe = false) { $events = 'onmousedown|onmousemove|onmmouseup|onmouseover|onmouseout|onload|onunload|onfocus|onblur|onchange';
    $events .= '|onsubmit|ondblclick|onclick|onkeydown|onkeyup|onkeypress|onmouseenter|onmouseleave|onerror|onselect|onreset|onabort|ondragdrop|onresize|onactivate|onafterprint|onmoveend';
    $events .= '|onafterupdate|onbeforeactivate|onbeforecopy|onbeforecut|onbeforedeactivate|onbeforeeditfocus|onbeforepaste|onbeforeprint|onbeforeunload|onbeforeupdate|onmove';
    $events .= '|onbounce|oncellchange|oncontextmenu|oncontrolselect|oncopy|oncut|ondataavailable|ondatasetchanged|ondatasetcomplete|ondeactivate|ondrag|ondragend|ondragenter|onmousewheel';
    $events .= '|ondragleave|ondragover|ondragstart|ondrop|onerrorupdate|onfilterchange|onfinish|onfocusin|onfocusout|onhashchange|onhelp|oninput|onlosecapture|onmessage|onmouseup|onmovestart';
    $events .= '|onoffline|ononline|onpaste|onpropertychange|onreadystatechange|onresizeend|onresizestart|onrowenter|onrowexit|onrowsdelete|onrowsinserted|onscroll|onsearch|onselectionchange';
    $events .= '|onselectstart|onstart|onstop'; if (preg_match('/<[\s]*script/ims', $html) || preg_match('/('.$events.')[\s]*=/ims',
    $html) || preg_match('/.*script\:/ims', $html)) return false; if (!$allow_iframe && preg_match('/<[\s]*(i?frame|form|input|embed|object)/ims',
    $html)) return false; return true; }


    public static function isCleanHtml($html, $allow_iframe = false) { return true; }


Still do not see the extended editor?

If after changes to files you do not see new editor in shop's back office this means that your browser probably do not see new .js files. It is because of browser caching feature. In this case please clear browser cache or refresh page where you still see old editor (like product edit page) with key combination: ctrl+f5 (it is a "hard" refresh with quick cache clear).




here you can find quick videoguide:




Module that does everything + new fancy features

Module that does everything automatically + includes some additional features not available in this article.

If you're interested in solution that will add font awesome icons, youtube videos insert tool or some other additonal things,

check official page of this module, it's available here: tinyMCE pro - extended rich text editor in PrestaShop


tinyMCE pro - extended version of editor





author milos myszczuk
Article by Milosz Myszczuk PrestaShop expert, official PrestaShop community moderator. PHP developer, specialist in relative and spatial databases management, GIS Analyst, CEO & founder of VEKIA interactive agency. Read more about VEKIA company
If you like my articles and want much more valuable tips, feel free to send me donation
1.4 version 1.4.11 1.6 404 addon admin advertise ahref ajax alpha animation api app application authentication back office backup badge banner basics block bootstrap button cache carrier cart catalog category certificate changelog chat class clear client clip cms code colors columns comments configuration contact container content controller cookie counter country coupon css csv currency customer dashboard database debug default delete delivery desktop developer device disable discount displayNav displayTop download dynamic editor effect empty encrypt engine error exchange exclude export facebook faceshop fade fancoupon fancybox fanpage fatal feature feed field file fix fixed font footer free friendly url front ftp full gallery generate gift global godaddy google google+ gray grid groupon header help hide highlight homefeatured homepage hook hosting hover howto htaccess html html5 ID image import include input instagram installation integration iPhone issue javascript jquery kgb knowhow languages law left likebox link list livingsocial loading log login logo loyality mail mailing maintenance manufacturer marketing marquee mcrypt menu meta mobile modification module movie moving multilanguage multiupload must have mysql news newsletter notification number open graph order override page password performance PHP phpmyadmin picture pinterest plugin popup post prestashop prestashop 1.0 prestashop 1.1 prestashop 1.2 prestashop 1.3 prestashop 1.4 prestashop 1.5 price rules problem product profile promotion proslider purifier quantity query quick tip random rates register reinsurance release reporting reset responsive restore results ribbon rich text right sales search security seo service shadow share shipping shop shopmania slider smarty social networks SQL SSL statistics stock store style subcategory superuser support switcher tab tablet tag tax template text theme tinyMCE tips and tricks tpl tracking translations tree trends trigger tumblr tutorial twitter update upgrade upload variables video visits voucher vulnerability web2print wide widget width window wishlist wysiwyg youtube zip zopim