当我将脚本标记<script src="../Scripts/tinymce.min.js"></script>
添加到我的页面时,TinyMCE加载正常 - 插件和主题引用.min版本。但是,当我删除脚本标记并尝试使用jQuery加载它时,它会引用非缩小版本,如控制台日志中所述。我正在使用TinyMCE v4.1.7(2014-11-27)
$.getScript('http://localhost:52417/Scripts/tinymce.min.js', function () {
window.tinymce.dom.Event.domLoaded = true;
tinymce.baseURL = 'http://localhost:52417/Scripts';
tinymce.init({
selector: '#announcementText',
plugins: ['link image'],
toolbar: 'undo redo | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist | outdent indent | link image',
menubar: false,
statusbar: false
});
});
GET http://localhost:52417/Scripts/themes/modern/theme.js 404 (Not Found)
GET http://localhost:52417/Scripts/plugins/link/plugin.js 404 (Not Found)
GET http://localhost:52417/Scripts/plugins/image/plugin.js 404 (Not Found)
domLoaded和baseURL行是从SO上的其他示例中找到的,并没有什么区别。如何让它引用主题和插件的正确路径?
答案 0 :(得分:20)
在调用tinymce.suffix = '.min';
tinymce.init()
答案 1 :(得分:0)
我能想到的唯一解决方案是将theme.min.js和plugin.min.js文件复制并重命名为theme.js和plugin.js,并将这些文件与缩小版本一起发布。
答案 2 :(得分:0)
Best solution is to include plugins in html in <script>
tag.
Then use some lib to pack those files into one to reduce number of requests to serwer for example for Symfony2 (in twig template):
{% javascripts output='js/tinymce_plugins.js' filter='?uglifyjs2'
'@BrokerStarCommonBundle/Resources/public/js/tinymce/themes/modern/theme.min.js'
'@BrokerStarCommonBundle/Resources/public/js/tinymce/plugins/advlist/plugin.min.js'
'@BrokerStarCommonBundle/Resources/public/js/tinymce/plugins/autolink/plugin.min.js'
.............
'@BrokerStarCommonBundle/Resources/public/js/tinymce/plugins/textpattern/plugin.min.js'
'@BrokerStarCommonBundle/Resources/public/js/tinymce/plugins/tabbutton/plugin.min.js'
'@BrokerStarCommonBundle/Resources/public/js/tinymce/plugins/checkboxes/plugin.min.js'
'@BrokerStarCommonBundle/Resources/public/js/tinymce/plugins/noneditable/plugin.min.js'
%}
<script type="text/javascript" src="{{ asset_url }}"></script>
{% endjavascripts %}
<script>