redactor-rails icon indicating copy to clipboard operation
redactor-rails copied to clipboard

Text outside of paragraph tags

Open chrishawk opened this issue 12 years ago • 5 comments

When a user begins typing into a redactor box, the first bit of text before the first return is not wrapped in p tags, just a div. All subsequent paragraphs are however. Has anyone else seen this issue?

chrishawk avatar Aug 13 '12 18:08 chrishawk

what's your redactor-rails gem venison ?

SammyLin avatar Aug 21 '12 11:08 SammyLin

I don't specify. In my gemifile it's just -

gem 'redactor-rails'

chrishawk avatar Aug 21 '12 15:08 chrishawk

I have actually seen this too, and just like you have not specified a gem version. I realize it's not the best solution, but a quick solution is to just use some jQuery to remove empty paragraphs, such as: $('p').each(function() { if( $(this).text() == "" ) { $(this).remove(); } });

Not a very elegant solution for sure, but it gets the job done.

thebrokencube avatar Aug 22 '12 17:08 thebrokencube

Oh the issue isn't empty p tags. It's if you start typing in the box, none of the text you enter will be in p tags until you hit enter. Starting there, all the text is in p tags. The first paragraph is in div tags. So your output looks like....

This is some text, then I hit

enter and the rest is in here

Note that the first bit of text will appear in p tags if you select paragraph from the dropdown. Is there a way to make that default?

chrishawk avatar Aug 22 '12 17:08 chrishawk

If someone ever finds a nice solution for this - the problem still persists - and for my purposes I can only think of fugly hacks with nokogiri manipulating the editor's HTML after saving.

ludwigschubert avatar Apr 20 '13 07:04 ludwigschubert