I have read Is it possible to add iFrame directly in Lightning Components, this is not a duplicate. I need to display an iframe, but I cannot supply a src
url.
Briefly, I need to display EmailMessage.htmlBody
within my component, but the emails are coming from Outlook (via 3rd party syncing tool), so the email content includes html
, head
, and style
tags. The client wants to keep the formatting, so I don't want to strip out the style
. Both lightning:formattedRichText
and ui:outputRichText
strip out a number of tags including html
, head
, and style
. Further, the way they strip them out leaves some of the xmlns:xxx
attributes from the html
tag present in the display, so they won't work.
I've looked at how the OOB EmailMessage view page in LEX works, and it's showing the email body inside an iframe... complete with all of the outlook-generated tags inside the iframe. But, there's no src
tag on the iframe, so I assume they are loading the iframe from JS.
I've tried the following:
- Direct setting, e.g.,
iframe[0].contentDocument.write(html)
. The wrapper object api doesn't expose contentDocument. data:
url, with the email body base64 encoded. CSP restriction doesn't allow Data urls. The CSP settings in SF allow for additional urls, but do not support thedata:
scheme (per the error message when I tried).blob:
url, creating the Blob in js using the email body. No CSP error, and if I debug theblob:
url and paste it in the browser, I see the email body. But when I set it in the iframe in the page, I get a blank iframe. Inspecting the iframe content in chrome dev tools shows a simple empty html doc that isn't the content I put in myblob:
url.
So I'm stuck. How can I render the full html which I have as an object property, but not as an url, inside an iframe, in a Ltng Component?