0

I am using lightning:inputRichText to show email template body. But it is displaying all the text in one single line. How can i put it in format?

Following is the code i am using in controller to set the body to lightning:inputRichText

component.set("v.body", data.Body);

Following is the component code

  <div class="slds-form-element">
               <label class="slds-form-element__label" for="textareaSample2">Mail Body</label>
               <div class="slds-form-element__control">
               <lightning:inputRichText aura:id="body" value="{!v.body}" />
               </div>
            </div>
1

Can you print the value in data.Body in console to see if it is valid and well formatted (with HTML tags)?

console.log('-------> ' + data.Body);

Also, have you tried hardcoding to see if it works? Like so:

<aura:attribute name="myHTMLFormattedText" type="String" default="&lt;b&gt;&lt;i&gt;&lt;u&gt;Hello World!&lt;/u&gt;&lt;/i&gt;&lt;/b&gt;"/> 
<lightning:inputRichText value="{!v.myHTMLFormattedText}" placeholder="Type something here"/>
| improve this answer | |
0

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.

Please mark this as an answer if it resolves your issue.

| improve this answer | |
-1

Using <pre></pre> tag resolved my issue. E.g. <pre><lightning:inputRichText aura:id="body" value="{!v.bodytext}" /></pre>

| improve this answer | |

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.