KillerCodeMonkey / ngx-quill

Angular (>=2) components for the Quill Rich Text Editor
MIT License
1.79k stars 264 forks source link

dangerouslyPasteHTML does not update ngModel value immediately #1581

Closed OhEmQ closed 2 years ago

OhEmQ commented 2 years ago

So in my code, I have a function that uses dangerouslyPasteHTML to append an autocomplete suggestion text to the quill text editor. The problem is that the ngModel variable does not update its value until the next time a character is added to the editor using dangerouslyPasteHTML. So essentially the ngModel variable for the editor contents is one step behind. How do I refresh it to update the ngModel value without reloading the ngx-editor or adding more characters?

I am using (input) = "addSuggestion($event)" to call the function that adds the character to the editor. Is the problem using input or is it a ngModel issue? I have to use (input) because I use (keydown.Space), (keydown.Enter) for other things so using (keydown) in general is out of the question because of the conflict. Plus, I want to add pasted characters too

How do I solve this? I have searched the documentation and forums for an answer with no success.

KillerCodeMonkey commented 2 years ago

check the readme. there is "hint" area at the beginning of the "quillEditorComponent" section.

In general you should change your model or control to change the editor content. If you are using the api and it should be recognized as "user" changes, just pass the source "user" as second parameter to the dangerouslyPasteHTML method.

https://quilljs.com/docs/modules/clipboard/#dangerouslypastehtml