quilljs
现在富文本编辑器轮子太多了,Github 上随便搜一下就有一堆,我需要实现的功能很简单,所以就佛系地选了 quilljs
,quilljs 是一个轻量级的富文本编辑器。
链接:
- 官网:quilljs.com/
- Github: github.com/quilljs/qui…
- React版本:github.com/zenoamaro/r…
- Vue版本:github.com/surmon-chin…
基础功能就不多说了,看文档就好。
主要是记录一下如何在 toolbar
上自定义一个按钮并实现自定义格式化。
toolbar
toolbar
相关文档:quilljs.com/docs/module…
基础用法
可以看到文档中有这么一段代码:
var toolbarOptions = [
['bold', 'italic', 'underline', 'strike'], // toggled buttons
['blockquote', 'code-block'],
[{ 'header': 1 }, { 'header': 2 }], // custom button values
[{ 'list': 'ordered'}, { 'list': 'bullet' }],
[{ 'script': 'sub'}, { 'script': 'super' }], // superscript/subscript
[{ 'indent': '-1'}, { 'indent': '+1' }], // outdent/indent
[{ 'direction': 'rtl' }], // text direction
[{ 'size'