我正在尝试使用Quill JavaScript富文本编辑器。我需要将其配置为仅使用预定义的标签集:
b, i, pre, a, br + Emoji
现在我以以下方式配置了它:
var Block = Quill.import('blots/block');
Block.tagName = 'PRE';
Quill.register(Block, true);
var quill = new Quill('#editor-container', {
modules: {
toolbar: true
},
theme: 'snow'
});
正如您可能看到的,我已经将包装器更改为PRE
标签。如何配置Quill以使用提到的受限标签集?不能允许其他标签,如果存在,必须自动删除。
以下是所有格式的列表:
formats = [
// 'background',
'bold',
// 'color',
// 'font',
// 'code',
'italic',
// 'link',
// 'size',
// 'strike',
// 'script',
'underline',
// 'blockquote',
// 'header',
// 'indent',
'list',
// 'align',
// 'direction',
// 'code-block',
// 'formula'
// 'image'
// 'video'
];
您可以使用它来防止某些格式。
在构造函数的参数中定义格式
,您可以在其中定义要支持的格式。
var quill = new Quill('#editor-container', {
formats: ['bold', 'italic', 'code', 'code-block', 'link'],
...
});
Quill使用Delta和格式,而不是直接使用超文本标记语言和标签。您可以设置格式配置选项来限制允许的格式。