Comments

MegaChriz’s picture

I have made a port of the patch posted in #1050118-4: Added better support for Line break converter. CKEditor is now able to load properly content where new line characters were used with one difference: the convert happens in Drupal.ckeditorOn() instead of Drupal.ckeditorToggle(), because then the convert also happens when the editor is enabled by default.

I see the code in the Drupal 6 version has changed along the way where an enterMode has been added. As I'm not yet familiar with the code I'm leaving it to someone else to add support for enterMode.

mkesicki’s picture

@ MegaChriz,
thank you for patch. We try check this as soon as possible.

SebCorbin’s picture

Patch worked well here

milesw’s picture

milesw’s picture

Hmm, looks like there's an issue with this behavior remaining bound even after CKeditor has been disabled. When I select the "Plain text" format CKeditor disappears, but line breaks still end up being converted to paragraph tags.

Ronino’s picture

Patch works for me, nice!

siramsay’s picture

patch#4 confirmed to work by adding <p> and <br /> tags for linebreaks on opening node edit form. ckeditor 7.x - 1.16 and 7.x-1.16+9-dev

as per #5 converting to plain text doesn't remove tags

SpaghettiBolognese’s picture

Status: Needs work » Needs review
FileSize
2.8 KB

I think this patch should fix the issues stated in #5 by @milesw. Please test!

Status: Needs review » Needs work

The last submitted patch, 8: d7_linebreaks-1084924-8.patch, failed testing.

SpaghettiBolognese’s picture

Status: Needs work » Needs review

The last submitted patch, 1: ckeditor-line-break-converter-1084924-1.patch, failed testing.

The last submitted patch, 1: ckeditor-line-break-converter-1084924-1.patch, failed testing.

The last submitted patch, 1: ckeditor-line-break-converter-1084924-1.patch, failed testing.

The last submitted patch, 1: ckeditor-line-break-converter-1084924-1.patch, failed testing.

donquixote’s picture

I am confused, what exactly is the intended behavior with this patch? The issue summary is not very detailed.

I found a lot of issues talking about line breaks.
https://www.drupal.org/project/issues/ckeditor?text=line+breaks&status=All
But I am still confused. I did not find the answers I was looking for.

The main conflict is this:

  • The "Convert line breaks into HTML (i.e. <br> and <p>)" filter is designed for source text without explicit <br> or <p> (paragraph) tags.
  • The CKEditor generates source text with such html tags.

When is this relevant?

  • Sometimes users want to switch between the two editing modes.
  • If a text was written without CKEditor initially, and then is loaded by CKEditor, CKEditor removes the line breaks.
  • If a text is written with CKEditor first, and a user wants to edit it manually, they have to deal with the html tags.
  • In the database and for revisioning it can be preferable to have source text without unnecessary html tags.
  • Similar conflict would occur with markdown or gfm, which also has linebreak conversion. Not sure this is relevant here.

I imagine the ideal behavior would be if CKEditor would produce source text WITHOUT these html tags.
For this, a two-way solution is needed:

  • All the time, the text in the original textarea should be WITHOUT the tags. This is what will be sent on form submission.
  • Internally, CKEditor wants to process source text WITH the tags.
  • On page load, and whenever the original textarea changes, CKEditor needs to read from the original textarea and add the linebreak tags for its internal processing.
  • Whenever the html in CKEditor is modified, CKEditor needs to convert the html tags back into source linebreaks, and write to the original textarea.

Yes, this means there are two versions of the text at each time, and a realtime conversion needs to happen in both directions.

From the issue summary, I do not understand if this is the intended behavior we are trying to implement with this issue.

donquixote’s picture

Btw once we have this, we could also have other two-way conversions, e.g. for markdown-style bullet lists.

donquixote’s picture

Ok I tested the patch from #8.
The behavior of the patch, as I experience it, is not a two-way conversion as in #15, but only a one-way conversion.

When editing content where the source has plain linebreaks instead of html tags, after saving, the source text in the database gets the html tags added.

Also, the tags stay there when switching to "Plain text" text format.

Still, this is better than the original behavior, where the tagless line breaks were just gone.