将 elfinder 与 TinyMCE 4 集成,"TypeError: parent.tinymce.activeEditor.windowManager.getParams 不是一个函数



我仍然是集成elfinder和tinymce的新手,我已经遵循elfinder wiki中的教程

in form.php in tinymce init已添加file_browser_callback:elFinderBrowser:

tinyMCE.init({
                mode : "exact",
                elements : "txt_content",
                theme : "advanced",
                file_browser_callback : elFinderBrowser,
                plugins : "advimage,advlink,media,contextmenu",
                theme_advanced_buttons1_add_before : "newdocument,separator",
                theme_advanced_buttons1_add : "fontselect,fontsizeselect",
                theme_advanced_buttons2_add : "separator,forecolor,backcolor,liststyle",
                theme_advanced_buttons2_add_before: "cut,copy,separator,",
                theme_advanced_buttons3_add_before : "",
                theme_advanced_buttons3_add : "media",
                theme_advanced_toolbar_location : "top",
                theme_advanced_toolbar_align : "left",
                extended_valid_elements : "hr[class|width|size|noshade]",
                paste_use_dialog : false,
                theme_advanced_resizing : true,
                theme_advanced_resize_horizontal : true,
                apply_source_formatting : true,
                force_br_newlines : true,
                force_p_newlines : false,
                relative_urls : true
        });

并添加elFinderBrowser函数:

function elFinderBrowser (field_name, url, type, win) {
  tinymce.activeEditor.windowManager.open({
    file: 'elfinder.html',// use an absolute path!
    title: 'elFinder 2.0',
    width: 900,  
    height: 450,
    resizable: 'yes',
    inline:true
  }, {
    setUrl: function (url) {
      win.document.getElementById(field_name).value = url;
    }
  });
  return false;
}

elfinder.html

<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
        <title>elFinder 2.0</title>
        <!-- jQuery and jQuery UI (REQUIRED) -->
        <link rel="stylesheet" type="text/css" media="screen" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/themes/smoothness/jquery-ui.css">
        <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
        <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/jquery-ui.min.js"></script>
        <!-- elFinder CSS (REQUIRED) -->
        <link rel="stylesheet" type="text/css" media="screen" href="<?php echo base_url() ?>assets/vendor/elfinder/css/elfinder.min.css">
        <link rel="stylesheet" type="text/css" media="screen" href="<?php echo base_url() ?>assets/vendor/elfinder/css/theme.css">
        <!-- elFinder JS (REQUIRED) -->
        <script type="text/javascript" src="<?php echo base_url() ?>assets/vendor/elfinder/js/elfinder.min.js"></script>
        <!-- elFinder initialization (REQUIRED) -->
    </head>
    <body>
        <!-- Element where elFinder will be created (REQUIRED) -->
        <div id="elfinder"></div>
        <script type="text/javascript" charset="utf-8">
            var FileBrowserDialogue = {
            init: function() {
              // Here goes your code for setting your custom things onLoad.
            },
            mySubmit: function (URL) {
              // pass selected file path to TinyMCE
              parent.tinymce.activeEditor.windowManager.getParams().setUrl(URL);
              // close popup window
              parent.tinymce.activeEditor.windowManager.close();
            }
          }
            $().ready(function() {
                var elf = $('#elfinder').elfinder({
                    url : 'connector.php',
                    getFileCallback: function(file) { // editor callback
                        // file.url - commandsOptions.getfile.onlyURL = false (default)
                        // file     - commandsOptions.getfile.onlyURL = true
                        FileBrowserDialogue.mySubmit(file); // pass selected file path to TinyMCE 
                      }
                }).elfinder('instance');
            });
        </script>
    </body>
</html>

但是当我在elfinder窗口中选择/选择图像时,它显示firebug错误:

"TypeError: parent.tinymce.activeEditor.windowManager.getParams不存在一个函数"

它已经让我发疯了,有什么提示吗,伙计们?

您是否尝试过tinyMce 4文档中所述的top.tinymce.activeEditor.windowManager.getParams(); ?用top代替parent

http://www.tinymce.com/wiki.php/api4 method.tinymce.WindowManager.getParams

使用较新的tinymce版本,它对我有帮助

相关内容

  • 没有找到相关文章

最新更新