TinyMCE configuration
Since first days a lot of attention was towards perfect TinyMCE configuration. But if there is something you don't like, you are free to change it.
Introduction
By default ImpressPages CMS has four TinyMCE configuration sets:
- ipTinyMceConfigMin - minimal tool set (always try to use this one)
- ipTinyMceConfigMed - medium tool set
- ipTinyMceConfigMax - almost all available tools
- ipTinyMceConfigTable - table tools
They are used to initialize text editor on widgets and all over the system.
In administration mode all four configurations are by default available as global javascript variables. This is how TinyMCE can be initialized on textarea field in widget initialization function:
this.widgetObject.find('textarea').tinymce(ipTinyMceConfigMin);
This is how you can get the content from TinyMCE in your widget Javascript file prepareData function:
this.widgetObject.find('textarea').val()
Customize configuration for your own widget
If you need custom TinyMCE config only in your custom code (not globaly in all system), then you can duplicate one of standard configurations and apply it. Definitely, you can create completely new configuration. Below is an example that uses default configuration and modifies the width of text editor:
var myOwnConfig = jQuery.extend(true, {}, ipTinyMceConfigMin); //duplicate configuration object
myOwnConfig.width = 200; //modify | add | delete any value
this.widgetObject.find('textarea').tinymce(myOwnConfig); //use new configuration
Overriding global configuration to influence all occurencies of TinyMCE
Not the best way, but easy one.
TinyMCE configuration files are located in: ip_cms/modules/standard/configuration/tinymce/ folder. You can override these configurationfiles in your theme in the same way as you do override any view.
Below is an example that overrides min.js configuration file. Just extract the content of this archive into your theme directory and IpText and many other widgets will have only three items in the toolbox.
Modifying global configuration to influence all occurencies of TinyMCE
The best slution!!!
Above example shows how to override TinyMCE configuration. But in this way you discharge any fixes to default configuration on updates. Time to time we improve default configuration. If you override, we have no influence on it. So the better way is to modify existing configuration instead of overriding. In this case if our new changes does not conflict with your customizations, they will be applied.
This is done using Javascript. To achieve that we need to load our own Javascript file immediately after default configuration file has been loaded and modify configuration object. When later scripts will access that object, it will be already modified.
To do so, we need to create a plugin with system.php file. This file will be automatically executed on system initialization and register our Javascript file to be loaded after default configuration file. See example and comments in it. It is a working example. You can install it. It will remove half of the tools from default TinyMCE configuration.
Write a comment
You must be logged in to comment.