我试图使用这个inline模式,但我有很多问题.有些人认为这种风格是如何被删除的,我得到了关于reading 'config'的这个错误.我想确保我正在使用对象editor为这个控件设置配置.任何帮助都会很好.

无法读取未定义的属性(读取'config')

enter image description here

看法

<div class="col-sm-10">
    <div class="controls">
        <textarea id="indicationElementId" 
            formControlName="indicationContent" 
            class="form-control" 
            [(ngModel)]="item.ValueName"
            placeholder="Indication text"
            [class.has-error]="indicationContentNeedsErrorClass">
        </textarea>
    </div>
</div>

ts

CKEDITORInitializer() {
    if ((<any>window).CKEDITOR.instances.indicationElementId)
        (<any>window).CKEDITOR.instances.indicationElementId.destroy(); 
        (<any>window).CKEDITOR.instances["indicationElementId"];
        let editor = (<any>window).CKEDITOR.inline("indicationElementId", {
                keystrokes: [
                    [13 /*Enter*/, 'doNothing'],
                    [(<any>window).CKEDITOR.SHIFT + 13, 'doNothing']
                ],
                enterMode: 2,
                toolbar: [
                    { name: 'basicstyles', items: ['Bold', 'Italic', 'Subscript', 'Superscript'] },
                    { name: 'insert', items: ['SpecialChar'] },
                    { name: 'source', items: ['Sourcedialog'] }
                ],
                specialChars: ['&copy;', '&reg;', '&ndash;', '&frac34;', '&ge;', '&le;'],
                removeButtons: '',
                extraPlugins: 'sourcedialog'
        });

        editor.CKEDITOR.config.allowedContent = true;
        editor.CKEDITOR.config.autoParagraph = false;
        editor.CKEDITOR.disableAutoInline = true;

        editor.on("change", () => {
            this.ngZone.run(() => {
                this.item.ValueName = this.getContent();
                this.indicationContentChanged.next(null);
            });

        });

输出

enter image description here

推荐答案

问题是试图设置配置.你可以试试:

editor.config.set('allowedContent', true);
editor.config.set('autoParagraph', false);
editor.config.set('disableAutoInline', true);

Typescript相关问答推荐

Typescript自定义键映射

返回对象的TypScript构造函数隐式地替换This的值来替换super(.)的任何调用者?

TypeScript实用程序类型—至少需要一个属性的接口,某些指定属性除外

rxjs forkJoin在错误后不会停止后续请求

react 路由6操作未订阅从react 挂钩表单提交+也不使用RTK查询Mutations

如何编写一个类型脚本函数,将一个对象映射(转换)为另一个对象并推断返回类型?

在另一个类型的函数中,编译器不会推断模板文字类型

如何创建一家Reduxstore ?

Angular:ngx-echart 5.2.2与Angular 9集成错误:NG 8002:无法绑定到选项,因为它不是div的已知属性'

确保对象列表在编译时在类型脚本中具有唯一键

是否可以强制静态方法将同一类型的对象返回其自己的类?

从类型脚本中元组的尾部获取第n个类型

如何从接口中省略接口

如何在Reaction 18、Reaction-Rout6中的导航栏中获取路由参数

为什么类型脚本使用接口来声明函数?他的目的是什么.

如何在TypeScrip中使用数组作为字符串的封闭列表?

基于属性值的条件类型

如何调整项目数组,但允许权重影响顺序

为什么 Typescript 无法正确推断数组元素的类型?

元素隐式具有any类型,因为string类型的表达式不能用于索引类型{Categories: Element;管理员:元素; }'