Integration with ElFinder

You can use elFinder if you need more opportunities You can completely replace a standard Jodit's filebrowser on elFinder

  • Download and unzip one of the releases elFinder
  • Rename /php/connector.minimal.php-dist to /php/connector.minimal.php
  • And include a few files in you HTML code
  • Also you need setting elFinder PHP connector, but that's another story
<script src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
<link rel="stylesheet" type="text/css" href="//ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/themes/smoothness/jquery-ui.css">
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min.js"></script>
<link rel="stylesheet" type="text/css" media="screen" href="./elfinder/css/elfinder.min.css">
<link rel="stylesheet" type="text/css" href="./elfinder/css/theme.css">

Now you need decide, will you change the default FileBrowser or will use both. Create FileBrowserEl.js with that code

Jodit.defaultOptions.filebrowser = {
    resizable: true,
    width: 600,
    height: 400,
    url: './build/js/elfinder/php/connector.php',
    lang: 'en' // full option list {@link https://github.com/Studio-42/elFinder/wiki/Client-configuration-options|here}
};

Jodit.modules.FileBrowser = function (editor) {
    this.jodit = editor;

    var dialog,
        $elfinderbox = editor.helper.dom('<div class="jodit_elfinder"></div>');

    dialog = new Jodit.modules.Dialog(editor, {resizable: false});
    editor.options.filebrowser.getFileCallback = function (file) {
        if (callbackSelect && callbackSelect.call) {
            callbackSelect.call(editor, [file.url]);
        } else {
            editor.selection.insertNode(editor.helper.dom('<img src="' + file.url + '">'));
        }
        dialog.close();
    };

    jQuery($elfinderbox).elfinder(editor.options.filebrowser)
    dialog.setContent($elfinderbox);

    this.open = function () {
        dialog.open();
        jQuery($elfinderbox).resize();
    };
};

If you want use both filebrowser, you need replace FileBrowser and filebrowser for example ElFinder and elfinder Above we replace FileBrowser and do not need to do anything more. Just initializes Jodit as usual

<textarea class="editor" name="editor"></textarea>

For elFinder need jQuery

jQuery(function () {
    new Jodit('.editor', {
        buttons: [{
            name: 'image',
            exec: function (editor) {
                editor.getInstance('FileBrowser').open();
            }
        }]
    });
});