I have a record that stores text with HTML formatting from a Styled Text Editor Field. In one of my interfaces I pull that text from the record and display it with a rich text display field.
Is there a way for me to put the text in such that it keeps the styling? I've been using stripHTML() on the text but that just removes everything which is not what I need.
Discussion posts and replies are publicly visible
You cannot use Rich Text Display Field to show HTML-formatted text with styling. The solution is to use a read-only Styled Text Editor component. This way preserve the HTML formatting from your Styled Text Editor Field.See below working example
a!localVariables( local!htmlText:"<b>Bold Text</b><br/><em>Italic Text</em><br/><u>Underlined</u><ul><li>Bullet 1</li><li>Bullet 2</li></ul>", a!sectionLayout( label: "HTML Text Display Comparison", contents: { a!textField( label: "Raw HTML (stored value)", value: local!htmlText, readOnly: true ), a!textField( label: "Using stripHtml() - loses all formatting", value: stripHtml(local!htmlText), readOnly: true ), a!styledTextEditorField( label: "Using Read-Only Styled Text Editor - preserves formatting", value: local!htmlText, readOnly: true, sizeLimit: 1000 ) } ) )
I used styled text editor, but it's not preserving the html formatting, however it's enabling the links. I used a plugin richtexteditor, this is preserving the format as it is but disabling the links when used in readonly format. I want both the formatting and the links. How to resolve this?
What kind of formatting are you talking about. The styled text editor will render all the formatting it supports when editing.
It doesn't support the exact formatting. This one is using styled text editor, It is rending the links
And this is using Vuram's plugin richtexteditor. This supports formatting but is not rending links in readOnly
The input to both these functions is the same html code
Sure. What I wanted to say is, that both options, styled text and richtexteditor, are meant to only display HTML created using the same method. They are not meant to display any random HTML from other sources.
But how to I achieve the richtexteditor's formatting and also include the hyperlinks? Is there any alternative approach?