Quill reload content !!! #4667
Replies: 3 comments
-
I know this is an old thread, but others will find it in the future, so for them, here's a solution to #1, assuming I understand your problem correctly. (If I don't, then this still solves a different problem.) To update the editor with new HTML contents and have that content be interpreted and editable, I haven't found a built-in way to do that. Here's the workaround I figured out: (1) Remove the "const" from initializing Quill, b/c we'll need to initialize it again, and const items can't be re-initialized or deleted.
(2) Remove the toolbar, b/c once I re-initialize it, a new toolbar will be created.
(4) Make a new editor to act on the conents.
|
Beta Was this translation helpful? Give feedback.
-
There is a much easier option available, it's just not the easiest to find in the documentation / examples. If you have your defaultHtml saved to a variable, let's call it const delta = my_quill.clipboard.convert({html: defaultHtml});
my_quill.setContents(delta, 'silent'); I just did this with a project last night, and it works beautifully, thought I wish there was a simple |
Beta Was this translation helpful? Give feedback.
-
Thank you, codeWonderland, that worked like a charm. I don't know how you found it in the docs. I just looked again, and even knowing what to look for, I still can't find it. Seems like such a common need that it would be explained front and center. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
From index.php
Text is appearing fine all correctly formated
Example
All is working fine, user makes some text modifications such as
4.eeee
and all is good.From js (process function)
I get the new text that can be processed. GOOD LORD all is perfect.
Now suppose user has made garbage. We need to reset text to its original not by reloading index.php but with a reset js function.
1: From js (reset function)
quill.setText("<?=$textFlashInfo?>");
Here text does not get formatted. I get
<p>a</p><ol><li>b</li><li>cc</li><li>ddd</li></ol>
like if html tags were not interpreted.What is wrong ? How to re-initialize div area ?
2: From js (reset function)
document.getElementById("editor").innerHTML = <?=$textFlashInfo?>;
It does replace the text and in the Quill window , it shows original text perfectly formatted.
However when user enter a new text such as
4.zzzzzzz
,getText return the previous one with
4.eeee
that should have been cleared !!! and not the new one4.zzzzzzz
What is wrong ? How to re-initialize div area ?
Any idea ? thanks
Beta Was this translation helpful? Give feedback.
All reactions