Angular 打字稿 CKEDITOR
Angular Typescript CKEDITOR
我正在尝试使用这种 inline
模式,但遇到了很多问题。一些样式被删除的方式,我收到关于 reading 'config'
的错误。我想确保我正在使用对象 editor
为这个控件设置配置。任何帮助都会很棒。
Cannot read properties of undefined (reading 'config')
查看
<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: ['©', '®', '–', '¾', '≥', '≤'],
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);
});
});
产出
问题在于尝试设置配置。可以试试:
editor.config.set('allowedContent', true);
editor.config.set('autoParagraph', false);
editor.config.set('disableAutoInline', true);
我正在尝试使用这种 inline
模式,但遇到了很多问题。一些样式被删除的方式,我收到关于 reading 'config'
的错误。我想确保我正在使用对象 editor
为这个控件设置配置。任何帮助都会很棒。
Cannot read properties of undefined (reading 'config')
查看
<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: ['©', '®', '–', '¾', '≥', '≤'],
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);
});
});
产出
问题在于尝试设置配置。可以试试:
editor.config.set('allowedContent', true);
editor.config.set('autoParagraph', false);
editor.config.set('disableAutoInline', true);