/**
* 2007-2024 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
*  @author    PrestaShop SA <contact@prestashop.com>
*  @copyright 2007-2024 PrestaShop SA
*  @license   http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
*  International Registered Trademark & Property of PrestaShop SA
*
* Don't forget to prefix your containers with your own identifier
* to avoid any conflicts with others containers.
*/
var root_path = base_dir_ssl;
window.tinyMCEPreInit = {};
window.tinyMCEPreInit.base = root_path + '/js/tiny_mce';
window.tinyMCEPreInit.suffix = '.min';
$('head').append($('<script>').attr('type', 'text/javascript').attr('src', root_path + '/js/tiny_mce/tinymce.min.js'));

function tinySetup(config) {
    if (!config)
        config = {};

    if (typeof config.editor_selector != 'undefined')
        config.selector = '.' + config.editor_selector;

    default_config = {
        selector: ".rte",
        plugins: "colorpicker link image paste pagebreak table contextmenu  table code media autoresize textcolor anchor",
        browser_spellcheck: true,
        toolbar1: "code,|,bold,italic,underline,strikethrough,|,alignleft,aligncenter,alignright,alignfull,formatselect,|,blockquote,colorpicker,pasteword,|,bullist,numlist,|,outdent,indent,|,link,unlink,|,anchor,|,media,image",
        toolbar2: "",
        // external_filemanager_path: ad + "/filemanager/",
        // filemanager_title: "File manager",
        // external_plugins: { "filemanager": ad + "/filemanager/plugin.min.js" },
        language: iso,
        skin: "prestashop",
        statusbar: false,
        relative_urls: false,
        convert_urls: false,
        entity_encoding: "raw",
        extended_valid_elements: "em[class|name|id]",
        valid_children: "+*[*]",
        valid_elements: "*[*]",
        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;
    });

    tinyMCE.init(config);
}
