查看文档,似乎忽略了:
toolbar : { container : containerOptions, handlers : handlerOptions }
做的只是:
toolbar : containerOptions
只是一条捷径
container
选择是如此普遍。因此,您必须使用第一个表单来指定处理程序选项。
var toolbarOptions = {
container: [
[{ 'font': [] }],
[{ 'header': [1, 2, 3, 4, 5, 6, false] }],
[{ 'align': [] }],
['bold', 'italic', 'underline', 'strike'], // toggled buttons
[{ 'color': [] }, { 'background': [] }], // dropdown with defaults from theme
['blockquote', 'code-block'],
[{ 'list': 'ordered'}, { 'list': 'bullet' }],
[{ 'script': 'sub'}, { 'script': 'super' }], // superscript/subscript
[{ 'indent': '-1'}, { 'indent': '+1' }], // outdent/indent
[ 'link', 'video', 'formula' ],
['clean'] // remove formatting button
],
handlers: {
// handlers object will be merged with default handlers object
'link': function(value) {
if (value) {
var href = prompt('Enter the URL');
this.quill.format('link', href);
} else {
this.quill.format('link', false);
}
}
}
}