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.
Comment | File | Size | Author |
---|---|---|---|
#4 | convert-newlines.patch | 2.13 KB | jcisio |
convert-newlines.patch | 1.62 KB | jcisio | |
Comments
Comment #1
geerlingguy CreditAttribution: geerlingguy commentedAlso, 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.
Comment #2
jcisio CreditAttribution: jcisio commentedIt 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.
Comment #3
geerlingguy CreditAttribution: geerlingguy commentedI see what you mean (looking over description once more). I guess that's not a bad idea - approaches the problem from a different avenue.
Comment #4
jcisio CreditAttribution: jcisio commentedThis 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.
Comment #5
jcisio CreditAttribution: jcisio commentedAnd 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!
Comment #6
jcisio CreditAttribution: jcisio commentedForgot to change the status. Please review and commit ;)
Comment #7
dczepierga CreditAttribution: dczepierga commentedEverything 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
Comment #9
jcisio CreditAttribution: jcisio commentedThat patch was committed in the 6.x branch only.
Comment #10
mkesicki CreditAttribution: mkesicki commentedComment #11
mkesicki CreditAttribution: mkesicki commentedComment #12
dczepierga CreditAttribution: dczepierga commentedI 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
Comment #13
mkesicki CreditAttribution: mkesicki commentedComment #14
crimsondryad CreditAttribution: crimsondryad commentedI 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.