简体   繁体   中英

Redactor - How to implement stripTags API call?

I want to strip all HTML tags except the <a> tag from redactor. I found this handy API call called stripTags but I don't know how to use it with my current code. Any ideas?

API

var html = this.clean.stripTags(html, '<a>');

JS

  $(function()
    {
      $('.text-editor-strip').redactor();
  });

Attempt

If the stripTag is anywhere in the function then it stops Redactor from initialising as below.

 $(function()
   {
     var html = this.clean.stripTags(html, '<a>');
     $('.text-editor-strip').redactor();
 });

There is a paragraphize setting you can turn off to eliminate the <p> tags. You can enable it when you initialize redactor:

$('#redactor').redactor({
  paragraphize: false
});

This will use <br/> tags in place of paragraphs tags.

Here's a demo .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM