4

I realize Craft 2.5 ships with Redactor II which has many changes.

With Redactor I a combination of

paragraphize: false,
replaceDivs: false,
linebreaks: true,
enterKey: false

kept text from being wrapped in p tags.

I want to give someone the ability to add simple formatting such as bold and italic, but not wrap it in any HTML.

Has anyone found how to continue doing this with Redactor II?

Thanks.

5
  • +1. Redactor 2 seems completely useless for copy/pasting in large bodies of text, mainly because it completely strips away paragraphs! If anyone has a fix for this I'd be very grateful.
    – Jamie Wade
    Dec 13, 2015 at 9:50
  • 1
    Not an answer, but I wrote a plugin which will at least enable you to easily remove the <p> tags when the field is output in Twig: {{ entry.body|retconUnwrap('p') }} Jan 3, 2016 at 19:39
  • I am having this same issue. I guess the plugin will work for now, but has anyone found a way to do it natively? Redactor 2 has definitely been a frustrating "upgrade" to say the least. :-/
    – Jacob Graf
    Jan 5, 2016 at 17:12
  • 1
    Had the same dilemma. I currently went with using Twigs striptags filter, which allows you to whitelist allowed tags. Example: heading|striptags('<strong>, <em>')|raw Jan 5, 2016 at 17:27
  • Another viable workaround: P&T released a plugin a while back which makes it possible to continue using Redactor I with Craft 2.5+: github.com/pixelandtonic/RedactorI Jan 5, 2016 at 22:03

1 Answer 1

4

I just found the following in the updated docs for the enterKey setting:

enterKey — This setting allows to prevent use of Return key. With this set to 'false' and pastePlainText is set to true, line breaks will be replaced by spaces.

So make sure you are on Craft 2.5.2757, as it includes Redactor II 1.2 which has got the new paste settings and try this Redactor config:

"enterKey": false,
"pastePlainText": true,

Redactor II deprecated the paragraphize setting, but as noted in the comments, it's easy to remove HTML tags with the striptags filter:

{{ asset.caption|striptags('<em><strong>')|raw }}

Every tag listed in the param string is whitelisted and won't get removed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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