I'm using the following Wordpress Editor Framework to offer the User a Rich Text editor.
The resulting String is:
"<b>Bold is working </b><i>Italic as well</i>\n<blockquote>But sadly... blockquote is not\n<ul>\n\t<li>Lists are working</li>\n</ul>\n</blockquote>"
My idea, to display the final String in the same format was to use a UIWebView
.
let result = "<b>Bold is working </b><i>Italic as well</i>\n<blockquote>But sadly... blockquote is not\n<ul>\n\t<li>Lists are working</li>\n</ul>\n</blockquote>"
contentWebView.loadHTMLString("<html><body><font face='SourceSansPro' color='black'>\(result)</font></body></html>", baseURL: nil)
Pretty much everything is the way I want it to be, but the blockquote.
How can I apply the blue/grey background to the blockquote as in the first screen?
Help is very appreciated.
My workaround:
func getFormattedHTMLString(_ entryString: String) -> String {
let cssStyle = "<style>div {border: 0px solid black;background-color: #E1E8F2;padding-top: 10px;padding-right: 0px;padding-bottom: 10px;padding-left: 10px;}</style>"
let removedBlockquoteEntries = entryString.replacingOccurrences(of: "<blockquote>", with: "<div>")
let removedBlockquoteEndings = removedBlockquoteEntries.replacingOccurrences(of: "</blockquote>", with: "</div>")
let result = "<html><head>\(cssStyle)</head><body><font face='SourceSansPro' color='black' size='5'>\(removedBlockquoteEndings)</font></body></html>"
return result
}
I have added CSS Code to the String as well as HTML tags.
Then I have replaced <blockquote>
tags with <div>
tags.
Usage: webView.loadHTMLString(getFormattedHTMLString(txt), baseURL: nil)
Resul: