2

I'm trying to insert a clip <div class="my-class">my text</div>. But when I insert the clip, the DIV tags are removed.

I have this setting in my Redactor config json: replaceDivs: false

2
  • That is really cryptic question. Can you clarify? Dec 17 '14 at 4:10
  • I write in plugin <div class="my-class">my text</div>, but when I insert the clip div tags are cut enter code here Dec 17 '14 at 9:14
3

Edit:

There's other problems / bugs with the Redactor API going on that lead to unexpected behavior on formatting the inserted HTML. The solution provided below does allow to insert HTML with DIV tags only if inserted in a new paragraph, otherwise it strips the tags. Another issue I came across is that I get empty SPAN tags added and I don't know where these come from?!

--

The plugin uses Redactor API's insert.html function. Which by default cleans the HTML before inserting it. But there's a parameter to prevent it from doing so.

You can hack / fork the plugin and set the parameter in redactorclips/resources/clips.js (line 63):

this.insert.html(html, false);

I will create a Github issue for this, because it definitely makes sense to have HTML cleaning disabled by default or at least have a setting for it. (Edit: makes no sense as long as there's all the other issues with the API!)

1
  • This still seems to be an issue with the clips plugin, as Redactor was insisting on stripping <br> tags in a clip that I created. The API seems to have changed slightly now - you need to change this.insert.html() to this.insert.raw() if you want the clip markup to be added unmolested.
    – Dom Stubbs
    Jan 22 '18 at 17:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.