Quill JavaScript Rich Text Editor restrict tags

隐身守侯 提交于 2020-01-25 07:03:12

问题


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'
});

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.


回答1:


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'],
  ...
});



回答2:


Quill works with Delta and formats, not directly with HTML and tags. You can set the formats config option to limit the allowed formats.




回答3:


Here is the list of all formats:

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

You can use this to prevent some formats.



来源:https://stackoverflow.com/questions/52223982/quill-javascript-rich-text-editor-restrict-tags

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!