有人已经尝试将elFinder整合到新的(4b1)版本的TinyMCE中吗? 看起来previous implementation无效。 请发一些片段,非常感谢。
答案 0 :(得分:7)
确定。我找到了解决方案:
tinymce.PluginManager.add(“elfinder”,function(editor,url){
editor.settings.file_browser_callback = function(id,value,type, 赢){
$('<div />').dialogelfinder({ url: url + '/php/connector.php', commandsOptions: { getfile: { oncomplete: 'destroy' } }, getFileCallback: function (url) { var fieldElm = win.document.getElementById(id); fieldElm.value = editor.convertURL(url, null, true); if ("fireEvent"in fieldElm) { fieldElm.fireEvent("onchange") } else { var evt = document.createEvent("HTMLEvents"); evt.initEvent("change", false, true); fieldElm.dispatchEvent(evt) } } });
}; },[“elfinder / js”]);
答案 1 :(得分:5)
我更新了Wiki,现在应该按照以下步骤进行操作:https://github.com/Studio-42/elFinder/wiki/Integration-with-TinyMCE-4.x
主要更改是TinyMCE不再使用InlinePopup插件,更改了回调,而不是file_browser_callback : 'elFinderBrowser'
您必须删除引号:
在TinyMCE init中:
file_browser_callback : elFinderBrowser
将elFinderBrowser回调添加到您的javascript:
function elFinderBrowser (field_name, url, type, win) {
tinymce.activeEditor.windowManager.open({
file: '/elfinder/elfinder.html',// use an absolute path!
title: 'elFinder 2.0',
width: 900,
height: 450,
resizable: 'yes'
}, {
setUrl: function (url) {
win.document.getElementById(field_name).value = url;
}
});
return false;
}
最后修改/复制elfinder.html文件以使用回调:
<!-- Include jQuery, jQuery UI, elFinder (REQUIRED) -->
<script type="text/javascript">
var FileBrowserDialogue = {
init: function() {
// Here goes your code for setting your custom things onLoad.
},
mySubmit: function (URL) {
// pass selected file path to TinyMCE
top.tinymce.activeEditor.windowManager.getParams().setUrl(URL);
// close popup window
top.tinymce.activeEditor.windowManager.close();
}
}
$().ready(function() {
var elf = $('#elfinder').elfinder({
// set your elFinder options here
url: 'php/connector.php', // connector URL
getFileCallback: function(file) { // editor callback
FileBrowserDialogue.mySubmit(file.url); // pass selected file path to TinyMCE
}
}).elfinder('instance');
});
</script>