<!DOCTYPE html>
<html>
<head>
    {% if includeAssets %}
        {{ include("@FMElfinder/Elfinder/helper/assets_css.html.twig") }}
    {% endif %}
</head>
<body>
{% if includeAssets %}
    {{ include("@FMElfinder/Elfinder/helper/assets_js.html.twig") }}
{% endif %}
<script type="text/javascript" charset="utf-8">
    $(document).ready(function() {
        var elf = $('.elfinder').elfinder({
            url : '{{ path('ef_connect', {'instance': instance, 'homeFolder': homeFolder }) }}',  // connector URL
            lang : '{{locale}}',
            onlyMimes: {{ onlyMimes|raw }},
            destroyOnClose : true,
            getFileCallback : function(files, fm) {
                            if (files.mime.match('application')) {
                                window.opener.$('.summernote').summernote('createLink', {
                                    text: files.name,
                                    url: files.url,
                                    newWindow: true
                                });
                                window.close();
                            }
                            if(files.mime.match('image')){
                                window.opener.$('.summernote').summernote('editor.insertImage', files.url);
                                window.close();
                            }
                        }
        }).elfinder('instance');
    });
</script>
<div class="elfinder"></div>
</body>
</html>
