Skip to main content

I recently created custom email component in LWC, this looked fine, but recently I received feedback that the templates which were sent from my component do not look the same as the templates they created.

So what I did is: I icluded an option to choose an Email template which current user would like to inject into lightning-input-rich-text, what I did is a renderStoredEmailTemplate().getHtmlBody() also tried renderEmailTemplate().getMergedBody() in controller of the component, so it basically retrieved proper HTML body, inspected it, checked on some online html editor, all looked the same, no issues so far. Then I passed that value to lightning-input-rich-text (the same issue in Aura), inspected the value of this field, these looked totaly different, read bit more documentation: "Pasting text enclosed in div and span tags convert those tags to p tags", ok cool but it looks like the behaviour is not as expected, also having triple spans received from HTMLValue in template made it much worse, issues I encounter so far:

- <br /> tags are also changed to p tags, so afterwards it gave me double breaks instead of single

 

- I had a span before <ul>, for some reason richTextField included it inside <ul>

 

- If I had a wrapper span and breaks inside, child spans were getting on a separate line and the styling got completelly different after break

The only option I can see right now is to show lightning-formatted-rich-text instead, but then users will not have access to modify the body of email, only to choose a template, but leaving as it is also makes this component worthless since this will not look good for our customers.

I am expecting that once I retrieve HTML body from email template and pass it to the lightning-input-rich-text I will receive the same result. Did anybody encounter the same? Cannot see anything regarding this in SF issues, nor I can find a workaround for it.

1 件の回答
0/9000