You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on May 6, 2023. It is now read-only.
First of all, thanks for this SwiftUI multi-line TextView implementation, that's great to be able to use it as easy as it was under UIKit ;)
I've a question, and maybe I've missed something... but when I use this Textview with an NSAttributedString containing some HTML, style is not updated but Markups are gone...
Maybe I'm doing something wrong...
Do you know if this has already worked for you ?
I mean something like:
// and then in my view
structMyView:View{varcontent:String="This is a <b>bold</b> text."varbody:someView{
if let contentHtml = content.htmlAttributedString {TextView(.constant(contentHtml)).isEditable(false).isSelectable(false).allowsRichText(true)}}}
When View is displayed, I would expect the word bold to be in bold but here, <b> and </b> markups are removed but no bold anywhere...
Have any idea about that ?
Thank for your answer and have a nice weekend
Jérémie
// somewhere in my code (in a viewModel and in a String extension for example)
extensionString{func htmlAttributedString()->NSAttributedString?{
guard let data =self.data(using:.utf8)else{returnnil}returntry?NSAttributedString(
data: data,
options:[.documentType:NSAttributedString.DocumentType.html],
documentAttributes:nil)}}
The text was updated successfully, but these errors were encountered:
Yeah I don’t believe this view currently supports AttributedString’s actually. I have seen several issues related to this.
I have a complete re-writ in-progress atm and that should resolve these kinds of issues.
That being said HTML support with attributed string’s is extremely slow.
Rather, I’d suggest you checkout my shaps80/MarkdownText package which enables almost full markdown spec support using only native SwiftUI so its extremely performant, animatable, etc…
It also provides a full styling API (using modifiers) so you have full control over the rendered output 👍🏻
If the text you have is in HTML, I’d recommend using some kind of converter to get it into Markdown, will honestly be far more performant than UITextView, since that uses a webview to do its rendering.
Hi !
First of all, thanks for this SwiftUI multi-line TextView implementation, that's great to be able to use it as easy as it was under UIKit ;)
I've a question, and maybe I've missed something... but when I use this Textview with an NSAttributedString containing some HTML, style is not updated but Markups are gone...
Maybe I'm doing something wrong...
Do you know if this has already worked for you ?
I mean something like:
// and then in my view
When View is displayed, I would expect the word
bold
to be in bold but here,<b>
and</b>
markups are removed but no bold anywhere...Have any idea about that ?
Thank for your answer and have a nice weekend
Jérémie
// somewhere in my code (in a viewModel and in a String extension for example)
The text was updated successfully, but these errors were encountered: