Is there a way to load an external javascript file inside a tinymce iframe?

Is there an easy way to load external javascript that will work inside TinyMCE iframe?

The only thing I found (this may be the answer): http://www.tinymce.com/wiki.php/API3:class.tinymce.dom.ScriptLoader

But I'm not sure how to download it correctly or if it works at all. I tried to load it before and after the tinymce.init directive, even inside it, but nothing works. Just wondering how to intiailize the "ScriptLoader" function.

+4
source share
3 answers

You can use the script loader using the initialization configuration configuration parameter

 tinyMCE.init({ ... setup : function(ed) { ed.onInit.add(function(ed, evt) { // Load a script from a specific URL using the global script loader tinymce.ScriptLoader.load('somescript.js'); // Load a script using a unique instance of the script loader var scriptLoader = new tinymce.dom.ScriptLoader(); scriptLoader.load('somescript.js'); }); } }); 
+6
source

To do this with the jquery plugin, I needed to do this:

 $('textarea').tinymce({ ... setup: function(editor) { var scriptLoader = new tinymce.dom.ScriptLoader(); scriptLoader.add("Your first script"); scriptLoader.add("Your second script"); scriptLoader.loadQueue(); ... }); }); 
+1
source
 tinyMCE.init({ ... setup : function(ed) { ed.onInit.add(function(ed, evt) { // Load a script from a specific URL using the global script loader tinymce.ScriptLoader.load('somescript.js'); // Load a script using a unique instance of the script loader var scriptLoader = new tinymce.dom.ScriptLoader(); scriptLoader.load('somescript.js'); }); } }); 
-2
source

Source: https://habr.com/ru/post/1433913/


All Articles