3

I'm looking to change the init of TinyMCE for Magento admin.

I'm just not satisfied with the default options and want to give my client a more user-friendly way of working with. So I want to remove some plugins, change some options and perhaps add some other plugins. But I want to keep the integrated Magento functionality.

I have not yet found a way to acomplish this without editing the js/mage/adminhtml/wysiwyg/tiny_mce/setup.js directly.

Is there a working solution?


UPDATE

Tobias' solution works very well! As you can read below, I had some trouble getting it to work due to 403 forbidden errors on my localhost. On my staging server however it worked as expected.

After some more testing, I found that the Fooman_Speedster extension I had installed was the cause of the problem. After disabling that, everything works fine!

4

You can esily create your own module (depends on Mage_Adminhtml) which is extending that js file:

config.xml:

<?xml version="1.0"?>
<config>
    <modules>
        <Your_Module>
            <version>0.0.1</version>
        </Your_Module>
    </modules>

    <adminhtml>
        <layout>
            <updates>
                <your_module>
                    <file>your/module.xml</file>
                </your_module>
            </updates>
        </layout>
    </adminhtml>
</config>

In your layout file you add a custom js to the header:

<?xml version="1.0"?>
<layout>
    <default>
        <reference name="head">
            <action method="addItem">
                <type>skin_js</type>
                <name>your_module/wysiwyg/tiny_mce/setup.js</name>
                <params/>
                <if/>
                <condition>can_load_tiny_mce</condition>
            </action>
        </reference>
    </default>
</layout>

And in the new setup.js you can overwrite the prototype object:

(function (getSettings) {
    tinyMceWysiwygSetup.prototype.getSettings = function (mode) {
        var oSettings = getSettings.call(this, mode);
        oSettings.extended_valid_elements = "article[class]";
        return oSettings;
    };
}(tinyMceWysiwygSetup.prototype.getSettings));
  • Thank you for you answer! Looks like it's the way to go. However, when I follow your instructions, I'm getting a network error 403 forbidden on the /skin/m/... url. Do you know what I might be doing wrong? – Maurice May 31 '14 at 15:27
  • what's the exact name of your file and where did you store it? – Tobias Jun 1 '14 at 10:27
  • I've given it the name application_adminhtml/tiny_mce/setup.js. When I inspect with firebug, the file is included as /skin/adminhtml/base/default/application_adminhtml/tiny_mce/setup.js - which is directly reachable via browser. As content I just have an alert('...'); statement in the file - but changing or deleting the content has no effect on the error. – Maurice Jun 2 '14 at 7:12
  • Ehm there seems to be a typo or something like that. in your first comment you wrote that you get a 403 on /skin/m/ ... what's the m? in your second comment there's no m mentioned – Tobias Jun 2 '14 at 20:04
  • There's no typo, but perhaps I could've been clearer. Magento aggregates multiple files into one call. The full url is quite long so I had to trim it: https://www...com.dev/skin/m/1401549822/js/prototype/prototype.js,/js/extjs/fix-defer-before.js,/js/prototype/window.js,/js/scriptaculous/builder.js,/js/scriptaculous/effects.js,/js/scriptaculous/dragdrop.js,....,/skin/adminhtml/base/default/application_adminhtml/tiny_mce/setup.js – Maurice Jun 3 '14 at 6:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.