The markdown parsing is broken/disabled for release notes. Sorry about that, I'm chasing the source of a crash that's been bringing this website down for the last couple of days.
## ⭐ What's Changed
* feat: Add `PrivacyInfo.xcprivacy` file for issue #50 by @NuPlay in https://github.com/NuPlay/RichText/pull/51
**Full Changelog**: https://github.com/NuPlay/RichText/compare/2.4.0...2.4.1
# ⭐ What's Changed
* #46 LinkOpenType Custom Handling for All URL Schemes by @NuPlay in https://github.com/NuPlay/RichText/pull/47
* Allow setting the WebKit baseURL for requests to something other than the Bundle by @ohmantics in https://github.com/NuPlay/RichText/pull/48
### 🐛 Bug fix
* Fixed sometime dynamic height not correct by @sk-chanch in https://github.com/NuPlay/RichText/pull/45
## 👍 New Contributors
* @sk-chanch made their first contribution in https://github.com/NuPlay/RichText/pull/45
* @ohmantics made their first contribution in https://github.com/NuPlay/RichText/pull/48
**Full Changelog**: https://github.com/NuPlay/RichText/compare/2.3.1...2.4.0
# :star: What's Changed
### ✨ [Feature]: Add custom type to LinkOpenType by @vidalhara in https://github.com/NuPlay/RichText/pull/42
```swift
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 https://github.com/NuPlay/RichText/pull/43
## 👍 New Contributors
* @vidalhara made their first contribution in https://github.com/NuPlay/RichText/pull/42
* @filip-zielinski made their first contribution in https://github.com/NuPlay/RichText/pull/43
**Full Changelog**: https://github.com/NuPlay/RichText/compare/2.3.0...2.3.1
## ✨ Support macOS
### Now available for iOS 13 and macOS 10.15 and later.
```swift
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.
```swift
//previous
linkOpenType: LinkOpenType = .SFSafariView()
//now
linkOpenType: LinkOpenType = .Safari
```
```swift
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
## ✨ 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.
```swift
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.
# ✨ Dynamic height evaluation
- #29 #30
```swift
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
```html
<div id ="element">\(html)</div> // before
<div id="NuPlay_RichText">\(html)</div> // after
```
### Contributors
Thanks to @mirko-milovanovic-vidiemme
## :bug: Deep linking bug and crash fix
- Change to open links(Deeplink) that don't start with http or https
Also, fix a bug that caused a crash when trying to open a deep link
- #25
## :sparkles: Add placeholder transition option
- Now you can add a transition between placeholder and contents
- #26
## 🐛 Custom fonts bug fix
- #21
## ✨ New Functions:
- Handle mailto: and tel:
- Make configuration public
## 📝 Update README
- Modified to match the changed code
- Add modifier description
### Contributors
Thanks to @ChaosCoder #20