Failed to initialize plugin: filemanager

193 Views Asked by At

I'm trying to integrate responsive file manager with TinyMCE on my php project, However I'm now getting an error Failed to initialize plugin: filemanager

I have searched everywhere I can't find solution, can someone please help. I'm using tinymce 6

Below is the plugin initialization code

tinymce.init({
  selector: '#intro',
  plugins: 'advlist autolink list link image charmap print preview hr anchor pagebreak media filemanager responsivefilemanager',
  toolbar1: "undo redo | bold italic underline | forecolor backcolor",
  toolbar2: "| responsivefilemanager | link unlink | image media | code",
  image_advtab: true,

  toolbar_mode: 'floating',
  images_upload_url: '../../proccessimages.php',
  relative_urls : false,
  external_filemanager_path: "filemanager",
  filemanager_title: "Responsive Filemanager",
  external_plugins: {
    "responsivefilemanager": "/admin/quiz/tinymce/plugins/responsivefilemanager/plugin.min.js",
    "filemanager": "/admin/quiz/filemanager/plugin.min.js"
  },
remove_script_host : false,
convert_urls : true,
    images_upload_credentials: true,
    width : "800",
    height: "300",
    onchange_callback: function(editor) {
  tinyMCE.triggerSave();
  $("#" + editor.id).valid();
}

});

$(function() {
  var validator = $("#addquizform").submit(function() {
      // update underlying textarea before submit validation
      tinyMCE.triggerSave();
  }).validate({
    ignore : ':hidden,.note-editable.card-block',
      rules :{

          quizname : {required:!0},
          intro: "required",
          introtype  : {required:!0}
      },
      messages :{

        quizname : {required:"Enter quiz name"},
        intro   : {required:"Enter quiz introduction section"}
      },
      errorPlacement: function(label, element) {
          // position error label after generated textarea
          if (element.is("textarea")) {
              label.insertAfter(element.next());
          } else {
              label.insertAfter(element)
          }
      },

      submitHandler : function(){

          tinyMCE.triggerSave();

          var formData = new FormData($("#addquizform")[0]);
          $.ajax({
              type : "POST",
              url  : "../../classes/controllers/quiz/quiz.php",
              data : formData,
              dataType: "json",
              encode: true,
              processData: false,
              contentType: false,
              beforeSend : function(){

                $('#loader').html('<div class="loading">Loading&#8230;</div>');
              },
              success : function (response) {

                $('#loader').empty();
                  if(response.status === "success"){
                      swal.fire({
                          type: 'success',
                          title: 'Success',
                          text : response.message,
                          showConfirmButton: false,
                          timer: 5000
                      });
                      setTimeout(' window.location.href = "quiz"; ', 6000);
                  }else{
                      swal.fire({
                          type: 'error',
                          title: 'Error',
                          text: response.message,
                      });
                  }  
              }
            });

          return false;
      }
  });
  validator.focusInvalid = function() {
      // put focus on tinymce on submit validation
      if (this.settings.focusInvalid) {
          try {
              var toFocus = $(this.findLastActive() || this.errorList.length && this.errorList[0].element || []);
              if (toFocus.is("textarea")) {
                  tinyMCE.get(toFocus.attr("id")).focus();
              } else {
                  toFocus.filter(":visible").focus();
              }
          } catch (e) {
              // ignore IE throwing errors when focusing hidden elements
          }
      }
  }
});

});

I'm using the cloud hosted tinymce.

Console Error :

tinymce.min.js:9 Failed to initialize plugin: filemanager TypeError: Cannot set properties of undefined (setting 'file_picker_types')

1

There are 1 best solutions below

0
sam nikzad On

The error is related this part of yout code :

external_plugins: {
    "responsivefilemanager": "/admin/quiz/tinymce/plugins/responsivefilemanager/plugin.min.js",
    "filemanager": "/admin/quiz/filemanager/plugin.min.js"
  },

You are using tinymce version 6 which is not supported by responsivefilemanager . see this image :

enter image description here