如何在 Quill 的工具栏中添加对齐按钮?

问题描述:

我正在尝试向 Quill 编辑器工具栏添加对齐按钮.

I'm trying to add alignment buttons to the Quill editor toolbar.

工具栏文档 不是很详细.它显示了如何选择对齐选项,但我想要一组并排的切换按钮.这可能吗?

The toolbar documentation isn't very detailed. It shows how to have a select for the alignment options but I'd like a set of toggle buttons side-by-side. Is this possible?

可以做align:'center',类似于header:3中的例子a href="https://quilljs.com/docs/modules/toolbar/#container" rel="noreferrer">文档.这是一个工作示例:https://codepen.io/anon/pen/PKdEgN

You can do align: 'center', similar to the header: 3 example in the docs. Here's a working example: https://codepen.io/anon/pen/PKdEgN

var quill = new Quill('#editor-container', {
  modules: {
    toolbar: [
      [{ align: '' }, { align: 'center' }, { align: 'right' }, { align: 'justify' }]
    ]
  },
  placeholder: 'Compose an epic...',
  theme: 'snow'  // or 'bubble'
});