Integrate TinyMce and ResponsiveFilemanager

function init_editor(){
    /*
    tinymce.init({
      selector: '.editor'
    });
    return;
    */
    var editor_config = {
        path_absolute : "/",
        selector: "textarea.editor",
        plugins: [
            "advlist autolink lists link image charmap print preview hr anchor pagebreak",
            "searchreplace wordcount visualblocks visualchars code fullscreen",
            "insertdatetime media nonbreaking save table contextmenu directionality",
            "emoticons template paste textcolor colorpicker textpattern"
        ],
        toolbar: "insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image media",
        relative_urls: false,
        height: 300, 
        file_browser_callback : function(field_name, url, type, win) {
            var x = window.innerWidth || document.documentElement.clientWidth || document.getElementsByTagName('body')[0].clientWidth;
            var y = window.innerHeight|| document.documentElement.clientHeight|| document.getElementsByTagName('body')[0].clientHeight;

            var cmsURL = editor_config.path_absolute + 'vendor/filemanager/dialog.php?type=0&field_id=' + field_name;
  

            tinyMCE.activeEditor.windowManager.open({
              file : cmsURL,
              title : 'Filemanager',
              width : x * 0.8,
              height : y * 0.8,
              resizable : "yes",
              close_previous : "no"
            });
        },
        setup: function (editor) {
            editor.on('change', function () {
                tinymce.triggerSave();
            });
        }
    };

    tinymce.init(editor_config);
}

JS for RFM callback

function responsive_filemanager_callback(field_id){
    var $e = jQuery('#'+field_id);
    var url = $e.val();
    //alert('update '+field_id+" with "+url);
    url = url.replace(base_url + '/storage/app/media', '');
    $e.val(url);

    //判斷有沒有客製的callback, 如果有的話就不會執行after_select
    if(typeof rf_callback == 'function'){
        rf_callback.call(null, url, field_id);
        return;
    }

    console.log('Callback ' + field_id);

    var $e = $('#' + field_id);

    if($e.hasClass('mce-textbox') == true){
        var url = $e.val();
        url = '/storage/app/media' + url;
        $e.val(url);

        tinyMCE.activeEditor.windowManager.close();
        return;
    }

    if($e.hasClass('dynamic_value_file') == true){
        return;
    }

    rfm_app.after_select(field_id);
}

https://www.tiny.cloud/docs/ui-components/urldialog/