laravel-tinymce-simple-imageupload icon indicating copy to clipboard operation
laravel-tinymce-simple-imageupload copied to clipboard

TinyMCE 5

Open qurgh opened this issue 6 years ago • 2 comments

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 avatar Oct 09 '19 19:10 qurgh

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!

qurgh avatar Oct 09 '19 21:10 qurgh

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

azrulhaifan avatar Jun 10 '20 14:06 azrulhaifan