I’m using quill editor in my template and the editor’s content is bound via [(ngModel)] to a variable in my component which is basically a text with some html tags in it. What I discovered is that if I change the variable’s value the quill editor formats its text and replaces all occurrences of the <div>
tag with <p>
. In my case this turned out to be very useful and I’d like to understand how this works and how to emulate this behavior in my Angular component to use it for formatting other text values? Is there a way to dynamically pass text to Quill and then get back the formatted value, e. g. via a method call on the editor?
Asked
Active
Viewed 526 times
0

bigb055
- 198
- 3
- 14
-
I think it will be easier to make build the custom method of what you need, You can use strings replace method with regular expressions to replace all occurrences with other values – Owen Kelvin Mar 31 '21 at 03:54
-
What are you after exactly? You can already pass a model to your editor, which will be modified by Quill – David Apr 01 '21 at 10:15
-
I need to understand how to instantiate Quill inside my component and pass some html text to it, and then get the processed value back. Is that possible at all? – bigb055 Apr 01 '21 at 20:28
-
Do you mean instantiate quill without the angular wrapper? – David Apr 02 '21 at 15:02
-
I mean: 1) Create Quill object, i.e. `let myQuillObj = new Quill(...)` 2) Pass some text value to `myQuillObj` instance's editor, i.e. `myQuillObj.setHtmlValue()` or whatever the right function call would be. 3) Get the processed text back, e.g. via a function call on the quill instance, i.e. `myQuillObj.getProcessedHtmlValue()`. I actually tried with invoking `setValue()` and `getValue()` methods but this only sets and returns the same values. No html tags are replaced.... Whereas doing it with `onContentChanged()` event handler returns the processed html values. – bigb055 Apr 02 '21 at 16:48
-
Hi there, you said you want to use that behavior in other Angular components. Did you mean to use it with Quill in each component, or you mean to use another inputs and convert that to html through Quill? – NeNaD Apr 05 '21 at 19:14