-
-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Provide better support for SwiftUI and AttributedString. #12
Comments
Hi, @makhocheung thank you for using and providing feedback. From the content of your issue, I have identified three problems that need to be resolved:
I'll resolve it as soon as possible. Thank you again for your feedback, I have not fully tested on macOS or using SwiftUI yet. |
After conducting research, I have concluded that AttributedString and NSAttributedString are not small objects and do not share the same inheritance. Unfortunately, it may not be implemented quickly. A temporary dirty solution would be to find ZNSTextAttachment for each AttributedString and manually trigger startDownload() and handle delegate for it. content.compactMap({ $0.attachment as? ZNSTextAttachment }).forEach { attachment in
attachment.delegate = self
attachment.startDownlaod()
})
// handler delegate
func zNSTextAttachment(didLoad textAttachment: ZNSTextAttachment, to: ZResizableNSTextAttachment) {
//
replace textAttachment to to in AttributedString
} I know it's very dirty, but as I mentioned earlier, it's not recommended to use it in SwiftUI currently. |
Please let me know if there is anything I have misunderstood, as I am not very familiar with SwiftUI. |
Currently,AttributedString supports markdown natively except
This is a good idea. Developers may hope ZMarkupParser supports SwiftUI. Actually, I'm appreciate that you have added support of h1~h6. ZMarkupParser currently satisfies my project. I will give more feedback later. Thank you. |
I'll add on here that this is really more of a failing of a failing of SwiftUI's let nsAttr = parser.render(html)
let attr = AttributedString(nsAttr) The real issue is that For my own projects I use a |
Here is the example.
Here is the error printed by console.
The text was updated successfully, but these errors were encountered: