Search code examples
phpcodemirrorelfinder

Theme is not working when use codemirror with elfinder


I am using elfinder with codemirror editor.When i used codemirror theme without elfinder its working well.But in elfinder theme not works.Here is my code that i use:

$(document).ready(function() {
 $('#elfinder').elfinder({
url: 'path of connector file'
// add more options here
commandsOptions: {
  edit: {
    mimes: ['text/plain', 'text/html', 'text/javascript','text/css','application/x-httpd-php'],
    editors: [{
      mimes: ['text/plain', 'text/html', 'text/javascript','text/css','application/x-httpd-php'],
      load: function(textarea) {
        var mimeType = this.file.mime;
        return CodeMirror.fromTextArea(textarea, {
          mode: mimeType,
          lineNumbers: true,
          indentUnit: 4,
          theme: "dracula",
         styleActiveLine: true,
            matchBrackets: true,
        });
      },
      save: function(textarea, editor) {
        $(textarea).val(editor.getValue());
      }
    }]
  }
  }
});
});

I already includes all neede css files.Please help why theme not works.


Solution

  • I am solving this problem.Actually the problem is in mimes.Now the woeking code is:

     $(document).ready(function() {
          $('#elfinder').elfinder({
           url: 'path of connector file'
         // add more options here
          commandsOptions: {
     edit: {
    
    editors: [{
      mimes: [],
      load: function(textarea) {
        var mimeType = this.file.mime;
        return CodeMirror.fromTextArea(textarea, {
          mode: mimeType,
          lineNumbers: true,
          indentUnit: 4,
          theme: "dracula",
         styleActiveLine: true,
            matchBrackets: true,
        });
      },
      save: function(textarea, editor) {
        $(textarea).val(editor.getValue());
      }
        }]
        }
         }
            });
           });