5121 Posts in 1527 Topics by 1119 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 2644 Views |
-
Customizing TinyMCE: Adding Setup Event

14 July 2010 at 1:04pm
TinyMCE allows you to create a JavaScript function to be executed when the editor first loads. Here is an example of how to do this with TinyMCE:
tinyMCE.init({
mode : "textareas",
theme : "simple",
setup : function() { alert('This function runs when TinyMCE has fully loaded.') );
}
});In older versions of TinyMCE I could accomplish this by hacking cms/javascript/tinymce.template.js but now that file seems to be replaced with a dynamic alternative.
How can I add a setup : function() to TinyMCE in SilverStripe version 2.4+?
-
Re: Customizing TinyMCE: Adding Setup Event

14 July 2010 at 2:04pm Last edited: 14 July 2010 2:09pm
I've had mixed results configuring TinyMCE in the CMS but you should be able to add options via HtmlConfigEditor in your _config.php e.g.
and include your javascript file with the setup function using LeftAndMain::require_javascript()HtmlEditorConfig::get('cms')->setOption('setup', 'yourSetupFunction');
The main issues I've had are mostly to do with the version of TinyMCE but that should work. take a look at _config.php in cms for the setup of the default editor profile.
-
Re: Customizing TinyMCE: Adding Setup Event

14 July 2010 at 11:54pm
This does not work. It gives a JavaScript error: "F is undefined"
HtmlEditorConfig::get('cms')->setOption('setup', "window.onload = function() {alert('Editor Loaded')}");
Am I doing anything wrong? Is this a TinyMCE bug?
Thanks!
-
Re: Customizing TinyMCE: Adding Setup Event

15 July 2010 at 9:33am
Well, it sounds like the option is being set at least.
At this point I think you'll need to look at the javascript with firebug or similar. It's possible that there's already a window.onload already being called and you can't have more than one AFAIK or some other syntax conflict, try something else so you can test it's being called correctly. There's a LOT of javascript in the CMS.
Beyond that, I'm afraid I won't be of much more help.
Rich
-
Re: Customizing TinyMCE: Adding Setup Event

15 July 2010 at 10:00am
Okay, so I've tried it quickly myself.
"setup" is definitely being set, however, you're correct that as soon as you have any value in there it produces two errors in the CMS;
f is undefined - tiny_mce_src.js Line 9365
tree.setCurrentByIdx is not a function - LeftAndMain_left.js Line 26So, it could be a conflict between TinyMCE and one of the many other scripts, and that's way beyond me, sorry.
Perhaps there's a better place to fire a setup event?
-
Re: Customizing TinyMCE: Adding Setup Event

15 July 2010 at 10:54am
Thanks for the help. Yes, the JavaScript is definitely being set however it seems to destroy TinyMCE in the process.
Does anyone else have any experience with this?
-
Re: Customizing TinyMCE: Adding Setup Event

17 January 2011 at 4:56pm
I also need to do this - I need to add a character count to TinyMCE, and I was hoping to do it using this code snippet:
http://tinymce.moxiecode.com/forum/viewtopic.php?pid=42558#p42558Does anyone have any tips on how I can create a setup event, or if there are better ways of adding a character count to TinyMCE?
| 2644 Views | ||
|
Page:
1
|
Go to Top |

