How do I add “show html” button in Quill like in Wysiwyg?

生来就可爱ヽ(ⅴ<●) 提交于 2021-02-18 21:52:43

问题


I recently found out about Quill text editor and since I am playing with new stuff in php and javascript I decided to use it in my app instead of Wysiwyg.

Quill documentation is really minimalistic though. How do I add a button that allows user to show and edit current html?

Do I have to extend Quill and make one of my own?


回答1:


If you check the following link, you will see that they don't add the option for an HTML button to the configuration list keys. Probably, you have to extend the library. http://quilljs.com/docs/configuration/ is the link to the configuration page.

In the API calls list I saw that you can do a function call to get HTML from the plugin. You can find it in the following link. The function name is called getHTML(). So you might have to extend the library by creating your own button and a display area.




回答2:


Well this was still an issue 3 years later.

So I made a little module to accomplish this.

https://github.com/benwinding/quill-html-edit-button

Demo




回答3:


I am using quill in an Angular App so all I had to do is wrap the content of the quill editor in a "pre" tag using [(ngModel)] with an addition to ngx-highlightjs module to add some syntax colors:

<pre><code [highlight]="content"></code></pre>

If you're using plain javascript, you can create a simple button that will populate a "pre" tag with the content from your editor.



来源:https://stackoverflow.com/questions/38064457/how-do-i-add-show-html-button-in-quill-like-in-wysiwyg

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!