Quill JavaScript Rich Text Editor 限制标签 [英] Quill JavaScript Rich Text Editor restrict tags

查看:76
本文介绍了Quill JavaScript Rich Text Editor 限制标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 Quill JavaScript Rich Text Editor.我需要将其配置为仅使用预定义的标签集:

I'm trying to use Quill JavaScript Rich Text Editor. I need to configure it to use only a predefined tag set:

b, i, pre, a, br + Emoji

现在我已按以下方式对其进行了配置:

Right now I have configured it in the following way:

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 以使用上述受限标签集?不允许有其他标签,如果存在,必须自动删除.

As you may see I already have changed the wrapper to PRE tag. How to also configure Quill to use the mentioned restricted tag set? No other tags can be allowed and must be automatically removed if present.

推荐答案

在构造函数的参数中定义formats,在那里你可以定义你想要支持的格式.

Define formats in the parameters of the constructor, there you can define which formats you want to support.

var quill = new Quill('#editor-container', {
  formats: ['bold', 'italic', 'code', 'code-block', 'link'],
  ...
});

这篇关于Quill JavaScript Rich Text Editor 限制标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆