我正在做一个项目,在这个项目中我必须在angular 4项目中实现CKEditor。我已经为我的项目使用了this编辑器。现在,CKEditor的最新版本(1.2.0)给出了错误。因此,我将其降级(至1.1.9)。我正在让它工作。很好,但这里发生的情况是,当我尝试使用任何工具栏时,它都不起作用。我尝试了图像工具栏,如下图所示。我正在尝试插入指向它的链接,但我无法在任何文本框中插入任何内容。
我甚至没有收到错误。我遗漏了什么吗?
下面是我使用的代码:
html
<div class="form-group">
<ckeditor formControlName="Description" #myckeditor [config]="ckeConfig" debounce="500">
</ckeditor>
</div>
TS FIle
export class myclass implements OnInit {
@ViewChild("myckeditor") ckeditor: any;
ckeConfig: any;
ngOnInit(){
this.ckeConfig = {
allowedContent: true
};
}
编辑:
发现我一直在弹出窗口中使用CKEditor。所以这就是我不能使用所有属性的原因。所以我想现在需要弄清楚我可以用来使它工作的任何东西?
发布于 2018-05-31 17:29:03
已找到此问题的解决方法:
在你的angular项目中,你必须维护js。您所需要做的就是将此代码放入其中。并在使用Modal Popup之前加载它。
$.fn.modal.Constructor.prototype.enforceFocus = function() {
$( document )
.off( 'focusin.bs.modal' ) // guard against infinite focus loop
.on( 'focusin.bs.modal', $.proxy( function( e ) {
if (
this.$element[ 0 ] !== e.target && !this.$element.has( e.target ).length
// CKEditor compatibility fix start.
&& !$( e.target ).closest( '.cke_dialog, .cke' ).length
// CKEditor compatibility fix end.
) {
this.$element.trigger( 'focus' );
}
}, this ) );
};
这将使ckeditor工作。尽管这非常不正统。
https://stackoverflow.com/questions/50618814
复制相似问题