Releases: NuPlay/RichText
Releases · NuPlay/RichText
2.4.1
2.4.0
⭐ What's Changed
- #46 LinkOpenType Custom Handling for All URL Schemes by @NuPlay in #47
- Allow setting the WebKit baseURL for requests to something other than the Bundle by @ohmantics in #48
🐛 Bug fix
- Fixed sometime dynamic height not correct by @sk-chanch in #45
👍 New Contributors
- @sk-chanch made their first contribution in #45
- @ohmantics made their first contribution in #48
Full Changelog: 2.3.1...2.4.0
V.2.3.1
⭐ What's Changed
✨ [Feature]: Add custom type to LinkOpenType by @vidalhara in #42
public enum LinkOpenType {
#if canImport(UIKit)
case SFSafariView(configuration: SFSafariViewController.Configuration = .init(), isReaderActivated: Bool? = nil, isAnimated: Bool = true)
#endif
case Safari
case custom((URL) -> Void)
case none
}
🐛 [Fix] Always call decisionHandler on webview navigationAction by @filip-zielinski in #43
👍 New Contributors
- @vidalhara made their first contribution in #42
- @filip-zielinski made their first contribution in #43
Full Changelog: 2.3.0...2.3.1
v2.3.0
✨ Support macOS
Now available for iOS 13 and macOS 10.15 and later.
let package = Package(
name: "RichText",
platforms: [
.iOS("13.0"),
.macOS("10.15")
],
...
)
This update resolves the issue mentioned in #34 and has been implemented through PR #36
♻️ linkOpenType Default Value is Changed
- Default value for linkOpenType is changed to .Safari.
- Previous: .SFSafariView()
- Reason: SFSafariView is not possible on macOS.
//previous
linkOpenType: LinkOpenType = .SFSafariView()
//now
linkOpenType: LinkOpenType = .Safari
public enum LinkOpenType {
#if canImport(UIKit)
case SFSafariView(configuration: SFSafariViewController.Configuration = .init(), isReaderActivated: Bool? = nil, isAnimated: Bool = true)
#endif
case Safari
case none
}
👍 Contributors
Thanks to @studiogaram
v2.2.1
✨ Improvements
Safely handle nil value in dynamic height update for WKWebView
- Updated webView(_:didFinish:navigation:) method to use optional binding for safely extracting height value.
- Set dynamicHeight to 0 if height is nil.
public func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) {
webView.evaluateJavaScript("document.getElementById(\"NuPlay_RichText\").offsetHeight", completionHandler: { (height, _) in
DispatchQueue.main.async {
if let height = height as? CGFloat {
withAnimation(self.parent.conf.transition) {
self.parent.dynamicHeight = height
}
} else {
self.parent.dynamicHeight = 0
}
}
})
}
This update resolves the issue mentioned in #32 and has been implemented through PR #33.
v2.2.0
✨ Dynamic height evaluation
struct MyHtmlView: View {
let longHTML: String = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed est est, mattis vel ante sit amet, porttitor interdum dui. Nunc cursus lobortis ex, ut faucibus felis malesuada id. Vivamus in risus nec dolor ullamcorper tincidunt in at velit. Vestibulum nec mollis ipsum. Phasellus volutpat augue odio, ultricies accumsan magna eleifend tristique. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Pellentesque efficitur sem non dui ultricies sollicitudin eu eu sapien."
let shortHTML: String = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed est est, mattis vel ante sit amet, porttitor interdum dui. Nunc cursus lobortis ex, ut faucibus felis malesuada id."
@State private var isExpanded: Bool = false
var body: some View {
VStack {
RichText(html: isExpanded ? longHTML : shortHTML)
.lineHeight(120)
.colorScheme(.auto)
.transition(.easeOut)
.background(Color.red)
Button {
isExpanded.toggle()
} label: {
Text("Show more/less")
}
}
}
}
📝 Reanme of id
<div id ="element">\(html)</div> // before
<div id="NuPlay_RichText">\(html)</div> // after
Contributors
Thanks to @mirko-milovanovic-vidiemme