This is from #685146-29: Plugin to convert new lines to <br /> or <p> (cross posted with WYSIWYG). I create this new issue for better visibility.

Scenario:
- CKEditor can be turned on/off independant on input format. This is useful, for example for comment. When more than 95% users don't leave comment, loading CKEditor by default is a waste of resource and a reduction of user experience. In this case, CKEditor should be off by default, and user can switch it on if necessary.
- Not all commenters switch CKEditor on when they write comment, in most case the comment is just a few paragraphs of plain text. Turn off CKEditor by default leads to an inconsistance of markup.
- Result: mixed of input format stored in database. We need a "auto line break" filter, which is not needed when CKEditor is on.

Solution:
- Current behavior: even when CKEditor is off by default, the small ckeditor.util.js is loaded.
- We can add the functionality for this script to do the "auto line break" filter on the client side if CKEditor is not enabled. Therefore the submitted markup is consistent.

Briefly, we need a plugin that converts line breaks into BR and P
- when user click on "Switch to rich text editor" at the first time
- or, when the form is submitted and the editor is never enabled

The attached patch is taken from other issue.

CommentFileSizeAuthor
#4 convert-newlines.patch2.13 KBjcisio
convert-newlines.patch1.62 KBjcisio
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

geerlingguy’s picture

Also, please note that there's a new project that's an addon for the WYSIWYG project, that does just this (and works with CKEditor, as provided through WYSIWYG): WYSIWYG Force Linebreaks. I've been using it on a variety of sites, and it does exactly this.

jcisio’s picture

It indeed does the opposite ;) When we store the content with markups, we should not mix them with line breaks. That's why I propose this approach.

We can always convert all line breaks in "pre-historical" content in DB to BR and P to avoid any furthur incompatibility.

geerlingguy’s picture

I see what you mean (looking over description once more). I guess that's not a bad idea - approaches the problem from a different avenue.

jcisio’s picture

FileSize
2.13 KB

This new patch should work in every case. Don't forget to turn off your Line break converter filter (you don't need it on a format with CKEditor enabled, don't you?). Turn CKEditor off by default, then you can turn on when you're typing, or even don't turn it on at all, it should work.

jcisio’s picture

And if you're interested in Ajax so that comment submission is more easy, please try #784504-45: Support for CKEditor, too. It's much better if you use these two patches at the same time!

jcisio’s picture

Status: Needs work » Needs review

Forgot to change the status. Please review and commit ;)

dczepierga’s picture

Status: Needs review » Fixed

Everything seems to work. I commit it to CVS.

Please check the latest dev release and let me know if you notice any poblems with it. Remember to clear Drupal cache and browsers cache before testing.

@jcisio, again really thx for good work

Greetings

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

jcisio’s picture

Version: 6.x-1.x-dev » 7.x-1.x-dev
Status: Closed (fixed) » Patch (to be ported)

That patch was committed in the 6.x branch only.

mkesicki’s picture

Title: Consistent markup with CKEditor on/off (or "convert new lines to <br /> or <p>") » Converts line breaks into BR and P (when user click on "Switch to rich text editor" at the first time or when form is sub.)
mkesicki’s picture

Title: Converts line breaks into BR and P (when user click on "Switch to rich text editor" at the first time or when form is sub.) » Linebreaks converter for CKEditor toggle mode
dczepierga’s picture

Version: 7.x-1.x-dev » 6.x-1.x-dev
Status: Patch (to be ported) » Closed (fixed)

I create new issue for D7 version - #1084924: [D7] Linebreaks converter for CKEditor toggle mode. I closed this issue because it's fixed in D6 version.

Greetings

mkesicki’s picture

Title: Linebreaks converter for CKEditor toggle mode » Added better support for Line break converter. CKEditor is now able to load properly content where new line characters were used
crimsondryad’s picture

I think this patch is causing issues. There is an issue here that sounds similar http://drupal.org/node/1149474#comment-form. After updating to 6.x-1.3 fields that are supposed to be plain text (no CKEditor enabled) are converting line breaks to

and
tags. That's a problem in the "Pages" textarea where you set where you want pages included / excluded for Block visibility. We have *.edit-pages set to exclude in the Global profile, but it wasn't working in block fields.

I disabled CKEditor entirely and the issue disappeared. Then I re-enabled the module and added the following to the Global profile and it appears to be fixed for blocks.

admin/build/block/configure/block/*.edit-pages
admin/build/block/configure/block/*.edit-body

That seems to be working. But still... me = confused. Because the *.edit-pages setup has been working for months...not sure why it would require the entire admin path now to exclude.