tinymce-angular
tinymce-angular copied to clipboard
Types of property 'entity_encoding' are incompatible.
What is the current behavior?
When I add entity_encoding: 'raw'
to my config, I get a compiler error.
Error: src/app/shared/rich-text-editor/rich-text-editor.component.html:2:27 - error TS2322: Type '{ base_url: string; suffix: string; initOnClick: boolean; menubar: boolean; plugins: string[]; toolbar: string; style_formats: ({ title: string; inline: string; classes: string; format?: undefined; } | { ...; })[]; ... 8 more ...; language_url: string; } & { ...; }' is not assignable to type 'RawEditorOptions | undefined'.
Type '{ base_url: string; suffix: string; initOnClick: boolean; menubar: boolean; plugins: string[]; toolbar: string; style_formats: ({ title: string; inline: string; classes: string; format?: undefined; } | { ...; })[]; ... 8 more ...; language_url: string; } & { ...; }' is not assignable to type 'RawEditorOptions'.
Types of property 'entity_encoding' are incompatible.
Type 'string' is not assignable to type 'EntityEncoding | undefined'.
2 <editor *ngIf="showFull" [init]="config" [formControl]="control"></editor>
~~~~
src/app/shared/rich-text-editor/rich-text-editor.component.ts:8:16
8 templateUrl: './rich-text-editor.component.html',
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Error occurs in the template of component RichTextEditorComponent.
Please provide the steps to reproduce and if possible a minimal demo of the problem via codesandbox.io or similar.
<editor *ngIf="showFull" [init]="config" [formControl]="control"></editor>
Editor is working, until I add entity_encoding: 'raw'
to config
.
What is the expected behavior?
Should set entity_encoding to raw
.
Which versions of TinyMCE/TinyMCE-Angular, and which browser / OS are affected by this issue? Did this work in previous versions of TinyMCE or TinyMCE-Angular?
"@tinymce/tinymce-angular": "^6.0.1",
"tinymce": "^6.0.2",
Chrome 101
Ref: INT-2895
Seems to work ok in sandbox, will have to investigate what is different in my project.
https://codesandbox.io/s/entity-encoding-u8vj9h
Setting angularCompilerOptions.strictTemplates=false
makes it work but is far from ideal.
I managed to resolve this by using the type definition for EditorOptions from /src/main/ts/editor/editor.component.ts in my code as follows...
public tinymceInit: Parameters<TinyMCE['init']>[0] = {
entity_encoding: 'raw',
newline_behavior: 'linebreak'
};
As @digime99 stated, you should have your config
property typed using the correct options type. In TinyMCE 6 it's called TinyMCE.EditorOptions
.