I am having text EmailTemplates in my org where body contains new lines but when I copy the EmailTemplate body to lightning:inputRichText, lightning:formattedRichText either it is displaying it in one line.

    <lightning:formattedRichText aura:id="richText1" value="{!v.templateText}"/>
    <lightning:inputRichText aura:id="richText2" value="{!v.templateText}"/>
    <aura:unescapedHtml aura:id="richText3" value="{!v.templateText}"/>

Is there any way to achieve this?

enter image description here

  • Are you using \n for line breaks? If so try with its HTML counterpart: <p> or <br>. Also read about 'Supported HTML Tags' in lightning:inputRichText documentation
    – Raul
    Dec 12 '18 at 6:58
  • I am just fetching EmailTemplate body and showing it to the above input elements. Even its a Text type EmailTemplate still user can enter text with line breaks. Dec 12 '18 at 7:08
  • I finally found a solution for the above problem. Wrap the above tags in <pre> html tag it will work properly. Dec 12 '18 at 9:43
  • great, you could answer your own question. It may help others facing similar issue.
    – Raul
    Dec 12 '18 at 10:06

There is some tweaks in this scenario it is not possible with lightning tag alone I just wrapped lightning:inputRichText inside pre html tag and it worked.

<pre><lightning:formattedRichText aura:id="richText1" value="{!v.templateText}"/></pre>
<pre><lightning:inputRichText aura:id="richText2" value="{!v.templateText}"/></pre>
<pre><aura:unescapedHtml aura:id="richText3" value="{!v.templateText}"/></pre>

It can work with other lightning tag as well.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.