CKEditor embed Image, Video, link and many others not working in Modal

扶醉桌前 提交于 2019-12-11 04:27:36

问题


Hello I am using bootstrap modal popup to open ckeditor. It's working but when I to click the image, video link and any others icon in that dialog opens, but is not clickable. I found this JS fix but it doesn't seem to work with Bootstrap 4.

<script>
    CKEDITOR.replace('help_ldesc');
    //CKEDITOR.replace('help_ldesc1');

    $.fn.modal.Constructor.prototype.enforceFocus = function() {
        var $modalElement = this.$element;
        $(document).on('focusin.modal',function(e) {
                var $parent = $(e.target.parentNode);
                if ($modalElement[0] !== e.target && !$modalElement.has(e.target).length && $(e.target).parentsUntil('*[role="dialog"]').length === 0) {
                        $modalElement.focus();
                }
        });
};
</script>

Demo: https://jsfiddle.net/waraywarayako/swxr110h/

From this topic: CKEditor image dialog forms not clickable when in a modal dialog


回答1:


So after finding out that this fix (https://gist.github.com/kaddopur/9996231) worked in Bs 3.1.1 I compared the functions between 3.1.1 and the new v4. The enforceFocus function was changed to _enforceFocus. Changing it seems to have fixed the issue:

$.fn.modal.Constructor.prototype._enforceFocus = function() {
  modal_this = this
  $(document).on('focusin', function (e) {
    if (modal_this.$element[0] !== e.target && !modal_this.$element.has(e.target).length 
    && !$(e.target.parentNode).hasClass('cke_dialog_ui_input_select') 
    && !$(e.target.parentNode).hasClass('cke_dialog_ui_input_text')) {
      modal_this.$element.focus()
    }
  })
};

https://jsfiddle.net/q3xbw8o7/7/



来源:https://stackoverflow.com/questions/47763304/ckeditor-embed-image-video-link-and-many-others-not-working-in-modal

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!