Quill JavaScript富文本编辑器限制标记

Quill JavaScript富文本编辑器限制标记,javascript,rich-text-editor,quill,Javascript,Rich Text Editor,Quill,我正在尝试使用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: {

我正在尝试使用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以使用所提到的受限标记集?不允许使用其他标记,如果存在,则必须自动删除。

Quill与和一起使用,而不是直接与HTML和标记一起使用。 您可以设置配置选项来限制允许的格式。

Quill使用和,而不是直接使用HTML和标记。
您可以设置配置选项来限制允许的格式。

定义
格式
在构造函数的参数中,您可以定义要支持的格式

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

定义
格式
在构造函数的参数中,可以定义要支持的格式

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

以下是所有格式的列表:

 formats = [
    // 'background',
    'bold',
    // 'color',
    // 'font',
    // 'code',
    'italic',
    // 'link',
    // 'size',
    // 'strike',
    // 'script',
    'underline',
    // 'blockquote',
    // 'header',
    // 'indent',
    'list',
    // 'align',
    // 'direction',
    // 'code-block',
    // 'formula'
    // 'image'
    // 'video'
  ];

您可以使用此选项来阻止某些格式。

以下是所有格式的列表:

 formats = [
    // 'background',
    'bold',
    // 'color',
    // 'font',
    // 'code',
    'italic',
    // 'link',
    // 'size',
    // 'strike',
    // 'script',
    'underline',
    // 'blockquote',
    // 'header',
    // 'indent',
    'list',
    // 'align',
    // 'direction',
    // 'code-block',
    // 'formula'
    // 'image'
    // 'video'
  ];

您可以使用它来阻止某些格式。

旁注:您仍然需要在服务器上清理或验证最终的HTML;只是Quill中的白/黑名单标签并不能保证任何东西。旁注:您仍然需要在服务器上清理或验证最终的HTML;仅仅在Quill中的白/黑标签并不能保证任何事情。复制粘贴word中的粗体文本不起作用。我有一些模块:{toolbar:false},因为我们不想让toolbarCopy从word粘贴粗体文本不起作用。我有模块:{toolbar:false},因为我们不需要工具栏