Admin Adminhtml WYSIWYG TinyMCE – How to Edit Admin TinyMCE JavaScript Code Without Modifying Core Files

adminadminhtmltinymcewysiwyg

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!

Best Answer

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));