helios-ag / FMElfinderBundle

:file_folder: ElFinderBundle provides ElFinder integration with TinyMCE, CKEditor, Summernote editors
MIT License
274 stars 127 forks source link

Summernote insertion of an image or a link to a pdf file #372

Closed pibrom closed 4 years ago

pibrom commented 4 years ago

Short description of what this feature will allow to do: update summernote getFileCallback behavior in order to insert a link to a pdf file if mime type is 'application' or, default behaviour, insert image if mime type is 'image'

Example of how to use this feature here is the update I've made on file helios-ag/fm-elfinder-bundle/src/Resources/views/Elfinder :

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();
                }
            }

summernote.html.twig.txt