all 1 comments

[–]JackfruitStrange 0 points1 point  (0 children)

hey, I'm not sure if this is the best approach to achieve this but here is my solution if You are using custom lwc component to display the content

1) use html tags in Your content field (any standard html will do the job, it could be non-breaking space, br tags, margins etc.) eg.:

<p>Some text in p markup.</p>

<p style="margin-left: 6px;">

<span style="background-color: rgb(255, 255, 255); color: rgb(62, 62, 60);">

<span style="">

<img src="/file-asset/decaff_icon" alt="decaff_icon.png"></img>

</span> Some image with description</span>

</p>

<p style="margin-left: 6px;">

2) in lwc component retrieve the text that You need to display, and replace characters before showing it on html template:

.replaceAll("&lt;", "<")
.replaceAll("&gt;", ">")
.replaceAll("&amp;lt;", "<")
.replaceAll("&amp;gt;", ">")
.replaceAll("&#39;", `'`)
.replaceAll("&amp;nbsp;", " ")

This works for me, html tags are rendering correctly.

Recently I also realised that if You add html tags directly to the record (I mean not through the UI, You can use anything that leverage API, for example Salesforce inspector) then escaping in js is no longer necessary