Quill 编辑器教程 #1 - 常用操作

各种命令,quill.format('header', 0);

Quill 编辑器教程 #1 - 常用操作

本文写于 2018-8-5

为什么有这篇文章

因为官方文档没有按这个格式写。文档的确有提供这些信息。但没有用这种格式。

推荐

用官方提供的 playground 来试下面的命令(你就不用本地新建个 HTML 文件然后等等等等。麻烦)
https://quilljs.com/playground/#quill-playground

设置标题

quill.format('header', 2);

设置回正文

quill.format('header', 0);

经尝试,0到7都是可以的,0,1,2,3,4...。
0和7都是正文。1~6 看起来就是 h1 ~ h6 了。

背景颜色

quill.format('background', 'blue');

(选中一段文字后运行此命令)

文字颜色

quill.format('color', 'red');

关于背景颜色和文字颜色多说一句:默认 quill 会把 background 和 color 做成 inline 样式,就是直接把 style='' 写在 html 元素里。如果希望弄成 class。
请参考:https://quilljs.com/playground/#class-vs-inline-style

粗体

quill.format('bold', true);

(选中一段文字后运行此命令)

(文章未写完)