SammyLin / redactor-rails

This repo is deprecated. Please check out official gem for Redactor 2. https://github.com/Redactor2/redactor2_rails
MIT License
389 stars 253 forks source link

Text outside of paragraph tags #14

Open chrishawk opened 12 years ago

chrishawk commented 12 years ago

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?

SammyLin commented 12 years ago

what's your redactor-rails gem venison ?

chrishawk commented 12 years ago

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

gem 'redactor-rails'

thebrokencube commented 12 years ago

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.

chrishawk commented 12 years ago

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?
ludwigschubert commented 11 years ago

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.