function initImageDrag(elem, editor) {
        $(elem).on("dragenter", function (ev) {
            ev.preventDefault();
            $("#red-ui-drop-target-markdown-editor").css({
                display:'table',
                top: $(elem).offset().top,
                left: $(elem).offset().left,
                width: $(elem).width(),
                height: $(elem).height()
            }).focus();
            currentEditor = editor;
        });

        if (!initialized) {
            initialized = true;
            $("#red-ui-drop-target-markdown-editor").on("dragover", function (ev) {
                ev.preventDefault();
            }).on("dragleave", function (ev) {
                $("#red-ui-drop-target-markdown-editor").hide();
            }).on("drop", function (ev) {
                ev.preventDefault();
                if ($.inArray("Files",ev.originalEvent.dataTransfer.types) != -1) {
                    var files = ev.originalEvent.dataTransfer.files;
                    if (files.length === 1) {
                        var file = files[0];
                        var name = file.name.toLowerCase();
                        var fileType = file.type.toLowerCase();
                        
                        if (name.match(/\.(apng|avif|gif|jpeg|png|svg|webp)$/)) {
                            file2base64Image(file, function (image) {
                                var session = currentEditor.getSession();
                                var img = `<img src="${image}"/>\n`;
                                var pos = session.getCursorPosition();
                                session.insert(pos, img);
                                $("#red-ui-drop-target-markdown-editor").hide();
                            });
                            return;
                        }

                        if ( fileType.startsWith("text/") ) {
                            file2Text(file, function (txt) {
                                var session = currentEditor.getSession();
                                var pos = session.getCursorPosition();
                                session.insert(pos, txt);
                                $("#red-ui-drop-target-markdown-editor").hide();
                            });
                            return;
                        }                       
                    }
                } else if ($.inArray("text/plain", ev.originalEvent.dataTransfer.types) != -1) {
                    let item = Object.values(ev.originalEvent.dataTransfer.items).filter(d => d.type == "text/plain")[0]

                    if (item) {
                         item.getAsString(txt => {
                            var session = currentEditor.getSession();
                            var pos = session.getCursorPosition();
                            session.insert(pos, txt);
                            $("#red-ui-drop-target-markdown-editor").hide();
                         })
                         return
                    }                    
                }
                $("#red-ui-drop-target-markdown-editor").hide();
            });
        }
    }
Initialize handler for image file drag events