tinymce / tinymce-angular

Official TinyMCE Angular Component
MIT License
320 stars 92 forks source link

Form control not updated with changes in the "code" plugin #343

Closed bfredo123 closed 1 year ago

bfredo123 commented 1 year ago

I am using TinyMCE 5.8.2 and Tinymce-angular 4.0.0 (Angular 12 app). In a reactive form, I have:

          <editor formControlName="body" [init]="tinyInit"></editor>

Everything works fine except when the user modifies the html code via the "<>" code plugin button: the changes appear in the TineMCE box, but the value is not updated in the Angular form (I could also observe via form.valueChanges.subscribe that the change is not seen by Angular).

However, the SetContent event is properly fired.

This seems to be a random behavious unfortunately. And more likely to happen when changing the section of the code (I have added the "fullpage" plugin, btw).

Any suggestion please to make this work?

Many thanks!

exalate-issue-sync[bot] commented 1 year ago

Ref: INT-3143

jscasca commented 1 year ago

You might have to change the model events used and add either setcontent or closewindow as <editor modelEvents="change input undo redo setcontent closewindow">.

Model events determine what triggers the editor value to propagate up the Angular chain so by default it only happens on change input undo redo. If you want a custom behaviour you can change this value.

bfredo123 commented 1 year ago

Thank you so much jscasa! It works! Actually I removed setcontent because it triggers some extra things in my case, closewindow is just fine.