mardi 31 juillet 2018

TinyMce doesn't call audio_template_callback, but call instead video_template_callback

I am using TinyMce editor with laravel 5.6, and laravel-elfinder. I have to upload audio file, but editor doesn't recognize the audio file, so it render as video format by calling video_template_callback. So I change the editor_config like:

var editor_config = {
            selector: "textarea",
            plugins: [
            "image link lists textcolor imagetools table codesample textpattern media code"
            ], 
            video_template_callback: function(data){
                console.log('call video');
                return '<audio controls>' + '\n<source src="' + data.source1 + '"' + (data.source1mime ? ' type="' + data.source1mime + '"' : '') + ' />\n' + '</audio>';
            },
            audio_template_callback: function(data) {
                console.log('call audio');
                return '<audio controls>' + '\n<source src="' + data.source1 + '"' + (data.source1mime ? ' type="' + data.source1mime + '"' : '') + ' />\n' + '</audio>';
            },
            toolbar: "insertfile undo redo | styleselect | bold italic strikethrough | alignleft aligncenter alignright alignjustify | ltr rtl | bullist numlist outdent indent removeformat formatselect| link image media | emoticons charmap | code codesample | forecolor backcolor",
            browser_spellcheck: true,
            relative_urls: false,
            remove_script_host: false,
            media_poster: false,
            media_filter_html: false,
            file_browser_callback : function(field_name, url, type, win) {

                tinymce.activeEditor.windowManager.open({
                    file: '<?= route('elfinder.tinymce4') ?>',// use an absolute path!
                    title: 'File Manager',
                    width: 900,
                    height: 450,
                    resizable: 'yes'
                }, {
                    setUrl: function (url) {
                    win.document.getElementById(field_name).value = url;
                    }
                });
            },
            setup:function(ed) {
                ed.on('change', function(e) {
                    console.log('the content ', ed.getContent({ format: 'text' }));
                });
            }
        };
    [![tinymce.init(editor_config);][1]][1]

when test this setting, console output only "call video".



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire