Redactor Can't Apply Anything to Heading Tags

Permalink
I noticed that Redactor is preventing me from doing the following:
1. Create a heading such as an H1 or H2 with two or more words
2. Select only one/whole of the words in the heading
3. Attempt to apply styling, such as bold, italic, or custom style to that word

This should result in some simple markup such as:
<h1>My list of <strong>words</strong></h1>

But it does not apply this styling.

I try on demo site from softaculous, it's works.
But not on mine.

Is this a bug with redactor or c5?

Also, can anyone tell me how to apply `cleanOnPaste` option for redactor ?

My C5 version is 5.7.5.1
Theme: Plain Bootstrap.

goesredy
View Replies:
MrKDilkington replied on at Permalink Reply
MrKDilkington
Hi goesredy,

"Create a heading such as an H1 or H2 with two or more words"
"Select only one/whole of the words in the heading"

I am afraid I don't understand what you are describing.

"Attempt to apply styling, such as bold, italic, or custom style to that word"

It appears that you can apply block custom styles to H1-H5, but cannot apply inline custom styles, bold, italic, spans, etc..

This isn't a bug in concrete5, this is the Redactor default behavior. You can see the same behavior in the Redactor and Softaculous demos -http://imperavi.com/redactor/ .

The cleanOnPaste option is set to true in Redactor by default.
goesredy replied on at Permalink Reply
goesredy
Hi MrKDilkington,
Thanks for replies :)

I already read your post herehttps://www.concrete5.org/community/forums/5-7-discussion/redactor-i...

Also read the last comment explaining forceBlock thing.

Thanks for that, So I can apply some for heading element.

After apply block custom style, now I can apply any style for inline element.
Switch to source view, heading text wrapped by 'undefined' tag, and that make any style can apply to the text inline.

Again, thanks for that suggestion post :)
madesimplemedia replied on at Permalink Reply
madesimplemedia
In C5 v5.7.5.1, it's also add this when you press return:

<p><br>
</p>

Typing is very slow too, I type some characters and there is major lag. Pretty awful experience compared to 5.7.4 where it was fine by default.
MrKDilkington replied on at Permalink Reply
MrKDilkington
@madesimplemedia

The line break tag wrapped in a paragraph tag on return is default Redactor behavior.
<p><br>
</p>

I think this behavior could be changed by setting "linebreaks" to true.
http://imperavi.com/redactor/docs/settings/special/#setting-linebre...
http://imperavi.com/redactor/examples/linebreaks/...

I am not sure why linebreaks isn't true by default or if it affects anything else. If it doesn't, changing it to true in the core version of redactor.js might be useful.

In the meantime, I believe you can use this approach to set linebreaks mode to true:
https://gist.github.com/hissy/8da3e9ffe9f3935d1be8...

I don't have any issues with lag when I type.
madesimplemedia replied on at Permalink Reply
madesimplemedia
Thanks but how do you start a new paragraph in that case?

I've added that code. Now when I add an h1, then press return to go back to paragraph mode type something, then return again and I get this markup:

<h1>About </h1>
<br>
<br><br>hhhh<br><br>dffd

Not ideal, need to get p tags in there without it adding br's as well
MrKDilkington replied on at Permalink Reply
MrKDilkington
Now we know why linebreak is set to false by default, setting it to true keeps text from being wrapped in paragraph tags.
madesimplemedia replied on at Permalink Reply
madesimplemedia
Yep true. In 5.4 it worked perfectly, i would just start a new paragraph tag if you pressed return and render a br tag if you pressed shift and return.

So something has been messed up.
andrew replied on at Permalink Reply
andrew
Redactor in 5.7.5 still honors the default behavior (wrapping lines in paragraph tags, as opposed to line breaks.) Just tested on 5.7.5.1
madesimplemedia replied on at Permalink Reply
madesimplemedia
Thanks for checking. Also to confirm your point, I have rolled back to 5.7.4.2 and it's still playing up, unlike my other 5.7.4.2 sites! Something weird going on in this site.
Also, backspace is deleting 2 characters instead of one, it's almost like it's doing everything twice!
madesimplemedia replied on at Permalink Reply
madesimplemedia
Update: This seems to be some issue with my install of Firefox. Seems ok in other browsers.
JeffPaetkau replied on at Permalink Reply
JeffPaetkau
Hi Everybody,

I know it has been a year since this post but I believe I have found the solution here:
http://blog.justinleveck.com/2015/12/21/patch-redactor-to-allow-hea...

You have to patch concrete/js/redactor.js on line 3 column 11689 to remove
||this.utils.isCurrentOrParentHeader()