tinymce-angular icon indicating copy to clipboard operation
tinymce-angular copied to clipboard

Types of property 'entity_encoding' are incompatible.

Open ondrejchmelar opened this issue 2 years ago • 3 comments

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

ondrejchmelar avatar May 25 '22 09:05 ondrejchmelar

Ref: INT-2895

exalate-issue-sync[bot] avatar May 25 '22 09:05 exalate-issue-sync[bot]

Seems to work ok in sandbox, will have to investigate what is different in my project.

https://codesandbox.io/s/entity-encoding-u8vj9h

ondrejchmelar avatar Jun 06 '22 07:06 ondrejchmelar

Setting angularCompilerOptions.strictTemplates=false makes it work but is far from ideal.

ondrejchmelar avatar Jun 06 '22 14:06 ondrejchmelar

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'
};

digime99 avatar Oct 20 '23 04:10 digime99

As @digime99 stated, you should have your config property typed using the correct options type. In TinyMCE 6 it's called TinyMCE.EditorOptions.

danoaky-tiny avatar Nov 24 '23 05:11 danoaky-tiny