问题
I am having trouble with TinyMCE. When it is searching for the lang, theme, and plugins, it is supposed to look in the directory where the base script files are located. however, instead of doing that, it is using the current loaded page as the root for searching. I am looking at the "loadScripts" function in the src file, but changing the path doesn't seem to provide any meaningful effect.
Here is the unmodified loadScripts function for your review:
// Load scripts
function loadScripts() {
if (s.language)
sl.add(tinymce.baseURL + '/langs/' + s.language + '.js');
if (s.theme && s.theme.charAt(0) != '-' && !ThemeManager.urls[s.theme])
ThemeManager.load(s.theme, 'themes/' + s.theme + '/editor_template' + tinymce.suffix + '.js');
each(explode(s.plugins), function(p) {
if (p && p.charAt(0) != '-' && !PluginManager.urls[p]) {
// Skip safari plugin for other browsers
if (!isWebKit && p == 'safari')
return;
PluginManager.load(p, 'plugins/' + p + '/editor_plugin' + tinymce.suffix + '.js');
}
});
// Init when que is loaded
sl.loadQueue(function() {
if (!t.removed)
t.init();
});
};
loadScripts();
}
回答1:
I was/am having this same issue with a "single page" application I am working on. The JS to load the JS for tinymce is in a some other directory, and this was giving me the same issue you were talking about.
There are a couple things I learned here that might help you.
window.tinyMCEPreInit = {
suffix : '_1',
base : '/static/js/plugins/tiny_mce', // your path to tinyMCE
query : 'something'
};
The 'base' argument is crucial if you are running into these issues.
Additionally, I was using the jquery plugin. However, if you manually include both the jquery plugin AND the tinymce, then the jquery plugin's script_src appears to be ignored. This is important too for some unknown reason.
Finally, in my case, I use the suffix as part of our cachebusting. When we do a build, all JS and CSS files have a hash added before the file extension. Unfortunately, I think the tinymce developers had a different idea in mind for the suffix setting and as such the lang and template css files do not obey it, resulting in 404s. The quick fix for lang was to set the language argument to 'en_1' where '_1" is the cacehbuster suffix. Finally, I had to manually edit the theme files to include the tinymce.suffix arg.
Hopefully that helps you. It took me 6 hours to get to this point.
来源:https://stackoverflow.com/questions/7325364/tinymce-loading-lang-plugins-theme-from-incorrect-directory