簡體   English   中英

將Elfinder與TinyMCE 4集成,“ TypeError:parent.tinymce.activeEditor.windowManager.getParams不是函數

[英]Integrating elfinder with TinyMCE 4, "TypeError: parent.tinymce.activeEditor.windowManager.getParams is not a function

我仍然是集成elfinder和tinymce的新手,我已經按照elfinder Wiki中的教程進行操作了

在tinymce初始化的form.php中已經添加了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窗口中選擇/選擇圖像時,它在firegbug中顯示錯誤:

“ TypeError:parent.tinymce.activeEditor.windowManager.getParams不是函數”

並已經讓我發瘋了,伙計們,有什么暗示嗎?

您是否嘗試過top.tinymce.activeEditor.windowManager.getParams(); 如tinyMce 4文檔中所述? 所以top而不是parent

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

使用較新的tinymce版本,對我有幫助

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM