When pressing “enter/return” in an Rich Text Field, the data being stored in the model and SFDC field upon save contains Carriage Return/Line Feed characters. The surrounding HTML contains appropriate
tags around the paragraphs but the carriage return/line feeds should not be stored in the data. If anything a the “return/enter” should translate to a
but if
tags are going to be applied, not sure its even necessary.
Steps to Reproduce:
Add a Rich Text Field to any SObject
Create a stock “detail” page for that SObject
Add rich text field to field editor
Preview page
Edit the Rich Text Field by typing a few characters, hitting return/enter and typing some more
Inspect the model data
Expected Behavior
Model field data should not contain the CR/LF character(s)
Actual Behavior
Model data contains CR/LF characters
That said, I think having the
is going to cause issues in another area of our app that has yet to be developed. In short, it will do document merging (Conga) so I think the
will end up resulting in an extra line break. I’ll try to throw together a POC to verify but ideally, there would be a way to avoid this.
If I use standard layout and edit the RTF field, I end up with:
"Skuid is cool!
Everyone should use it!
Have you started?"
If I use Skuid, I end up with:
"<p>Skuid is cool!</p>
<p>Everyone should use it!</p>
<p>Have you started?</p>"
The HTML is completely different and the carriage returns are in there. The challenge here is that depending on which way a user edits the value (Standard layout or Skuid), the resulting document will be different after merge since the value of the field has changed (with different markup that could be styled differently).
To be honest, I’m not sure there really is a one size fits all here. Possibly provide a way to override the CKEditor config settings?
I had not seen that post, thanks for the link! This is inline with my where I was heading with a way to override the CKEditor settings. Ideally there would be a way to do this more globally but a custom field renderer works.
I threw together a test that overrides “Enter” behvior and sure enough, it uses a
instead of
tag.
Unfortunately, an extra carriage return character is still inside the model data field value which I would not expect.
Using the standard rendered, you get two carriage return characters, Using the overridden ckEditor properties with enterMode of CKEDITOR.ENTER_BR, you end up with a single carriage return character.
I’ve updated the sample page two contain two RTF fields. If you modify the “Test Rich Text” field, you’ll get standard render, if you modify “Test Rich Text (With CK Renderer)” you’ll get modified enterMode.
Steps to reproduce:
Use sample page below
Preview page
Clear out “Test RIch Text” field then type hello, hit enter, type goodbye
Inspect model data and you’ll see Image #1 below
Clear out "Test Rich Text (With CK Renderer) field then type hello, hit enter, type goodbye
Inspect model data and you’ll see Image #2 below
The question is, why are the extra carriage returns getting in there? In either case (Standard or Custom Renderer), there shouldn’t be any at all.