petehouston / laravel-tinymce-simple-imageupload

Simple image upload for TinyMCE in Laravel.
69 stars 25 forks source link

TinyMCE 5 #13

Open qurgh opened 5 years ago

qurgh commented 5 years ago

This doesn't work with TinyMCE 5.

file_browser_callback was removed in version 5. The code to get the dialog box to display would be:

        file_picker_callback: function(callback, value, meta) {
            // trigger file upload form
            if (meta.filetype == 'image') {
                $('#formUpload input').click();
            }
        }

However, the javascript returned to fill in the dialog box isn't working. Laravel returns it, but it does nothing (probably due to how they changed the dialog box). I'm going to work on it and see if I can figure it out, but my javascript isn't strong, so it may take a while.

qurgh commented 5 years ago

This is probably kind of hacky, but this updated function now works with TinyMCE 5:

    function mce_back($filename)
    {
        return ("
            <script>
                top.$('.tox-browse-url').parent().find('.tox-textfield').val('/img/$filename');
                top.$(\"button[title|='Save']\").click();
            </script>
        ");
    }

There's probably a way to do this in one line, but at least it works!

azrulhaifan commented 4 years ago

This is probably kind of hacky, but this updated function now works with TinyMCE 5:

    function mce_back($filename)
    {
        return ("
            <script>
                top.$('.tox-browse-url').parent().find('.tox-textfield').val('/img/$filename');
                top.$(\"button[title|='Save']\").click();
            </script>
        ");
    }

There's probably a way to do this in one line, but at least it works!

you saved my life, thanks