CKEditor 嵌入图像、视频、link 和许多其他不在模态中工作的
CKEditor embed Image, Video, link and many others not working in Modal
您好,我正在使用 bootstrap 模式弹出窗口打开 ckeditor。它正在工作,但是当我单击图像时,视频 link 和该对话框中的任何其他图标都会打开,但不可单击。我找到了这个 JS 修复程序,但它似乎不适用于 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>
演示:https://jsfiddle.net/waraywarayako/swxr110h/
来自这个主题:
所以在发现此修复程序 (https://gist.github.com/kaddopur/9996231) 在 Bs 3.1.1 中有效后,我比较了 3.1.1 和新 v4 之间的功能。 enforceFocus
函数更改为 _enforceFocus
。更改它似乎解决了问题:
$.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()
}
})
};
您好,我正在使用 bootstrap 模式弹出窗口打开 ckeditor。它正在工作,但是当我单击图像时,视频 link 和该对话框中的任何其他图标都会打开,但不可单击。我找到了这个 JS 修复程序,但它似乎不适用于 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>
演示:https://jsfiddle.net/waraywarayako/swxr110h/
来自这个主题:
所以在发现此修复程序 (https://gist.github.com/kaddopur/9996231) 在 Bs 3.1.1 中有效后,我比较了 3.1.1 和新 v4 之间的功能。 enforceFocus
函数更改为 _enforceFocus
。更改它似乎解决了问题:
$.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()
}
})
};