diff --git a/CHANGELOG.md b/CHANGELOG.md index c78e6e1..c83532a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,41 @@ All notable changes to RichText are documented here. --- +## 3.1.1 + +Two regressions from 3.1.0. + +**macOS backgrounds were no longer transparent.** + +3.1.0 guarded the `drawsBackground` KVC call with `responds(to:)`. +KVC does not need that selector, it falls back to the `_drawsBackground` ivar. +So the guard always failed: the background stayed opaque, and every macOS launch +emitted a spurious `webViewConfigurationFailed`. + +Now uses `underPageBackgroundColor`, public API on iOS 15 and macOS 12. + +**`cssGenerationFailed` fired during a SwiftUI view update.** + +The handler ran synchronously from `makeUIView` and `updateUIView`. +Mutating state inside it produced "Modifying state during view update" — the +warning #72 had already fixed. + +Errors are now delivered on the next main-queue turn. + +Both are covered by regression tests. +macOS transparency is asserted against a real hosted `WKWebView` rather than a +string comparison, which is why 3.1.0 shipped without catching it. + +**Docs.** + +Fixed examples that did not compile: ambiguous `.blue` and `.cyan` color +literals, a redeclared `let css`, and `fullScreenCover(item:)` bound to a +non-`Identifiable` `String`. + +Removed 18 trailing-whitespace errors. + +--- + ## 3.1.0 A correctness release. Every change below is source-compatible - nothing public was removed. @@ -30,7 +65,7 @@ RichText(html: html) switch error { case .cssGenerationFailed: // fontColor or linkColor holds an invalid hex value, so the browser - // is dropping the declaration and the colour falls back to default + // is dropping the declaration and the color falls back to default break case .webViewConfigurationFailed: // macOS: the web view background could not be made transparent @@ -75,7 +110,7 @@ Nothing is removed; all of these still compile and behave as before. | `RichTextConstants.bodyCSS` | nothing - it was never applied | | `Configuration.isColorsImportant` | `.colorPreference(forceColor:)`, or `ColorSet(light:dark:isImportant:)` | -`Configuration.isColorsImportant` deserves a note: it was recorded but never read during CSS generation, so `Configuration(isColorsImportant: .all)` silently did nothing. `!important` comes from the colour sets alone. +`Configuration.isColorsImportant` deserves a note: it was recorded but never read during CSS generation, so `Configuration(isColorsImportant: .all)` silently did nothing. `!important` comes from the color sets alone. ```swift // ❌ had no effect @@ -129,7 +164,7 @@ Configuration(fontColor: ColorSet(light: "000000", dark: "FFFFFF", isImportant: Version 3.0.0 maintains **100% backward compatibility** for v2.x users while providing a clear path to modern APIs: - ✅ **Zero Breaking Changes**: All existing v2.x code works unchanged -- ✅ **Automatic Performance**: Better async/await performance and font rendering without code changes +- ✅ **Automatic Performance**: Better async/await performance and font rendering without code changes - ✅ **Guided Migration**: Helpful deprecation warnings with clear modern API alternatives - ✅ **Additive Enhancement**: New features are optional and don't affect existing functionality - ✅ **Future-Proof**: Modern architecture ready for Swift 6+ and future iOS/macOS versions diff --git a/README.md b/README.md index 6d04709..13fb01a 100644 --- a/README.md +++ b/README.md @@ -42,7 +42,7 @@ Styling, light and dark theming, custom fonts, media callbacks and typed errors - **Cross-platform** — iOS 15.0+ and macOS 12.0+, Swift 5.9+ - **Automatic sizing** — the view resizes itself as the content lays out, including late images, web fonts and `
` toggles -- **Theming** — automatic light/dark mode, custom colour sets, transparent or custom backgrounds +- **Theming** — automatic light/dark mode, custom color sets, transparent or custom backgrounds - **Typography** — system, monospaced, italic, custom and bundled fonts, with Dynamic Type support - **Interactive media** — click callbacks for images and videos - **Link handling** — Safari, `SFSafariViewController`, or your own handler @@ -94,7 +94,7 @@ See [the API reference](docs/API.md) for every modifier, and [advanced usage](do ``` https://github.com/NuPlay/RichText.git ``` -3. Select version rule: **"Up to Next Major Version"** from **"3.1.0"** +3. Select version rule: **"Up to Next Major Version"** from **"3.1.1"** 4. Click **Add Package** ### Manual Package.swift @@ -103,7 +103,7 @@ Add RichText to your `Package.swift`: ```swift dependencies: [ - .package(url: "https://github.com/NuPlay/RichText.git", .upToNextMajor(from: "3.1.0")) + .package(url: "https://github.com/NuPlay/RichText.git", .upToNextMajor(from: "3.1.1")) ], targets: [ .target( diff --git a/Sources/RichText/Models/ColorSet.swift b/Sources/RichText/Models/ColorSet.swift index ccc0ece..fe2f18c 100644 --- a/Sources/RichText/Models/ColorSet.swift +++ b/Sources/RichText/Models/ColorSet.swift @@ -97,7 +97,7 @@ public struct ColorSet: Equatable { } private func isValidHexColor(_ hex: String) -> Bool { - // `#RGB`, `#RGBA`, `#RRGGBB` and `#RRGGBBAA` are all valid CSS colours. The previous + // `#RGB`, `#RGBA`, `#RRGGBB` and `#RRGGBBAA` are all valid CSS colors. The previous // 6-or-8 rule rejected the two shorthand forms as invalid even though they render // fine, and disagreed with `BackgroundColor.isHexColorLiteral`, which already // accepted all four lengths. diff --git a/Sources/RichText/Models/Configuration.swift b/Sources/RichText/Models/Configuration.swift index 2730d8b..c769bde 100644 --- a/Sources/RichText/Models/Configuration.swift +++ b/Sources/RichText/Models/Configuration.swift @@ -38,12 +38,12 @@ public struct Configuration { /// deprecation warning. var storedColorPreference: ColorPreference - /// The requested colour enforcement preference. + /// The requested color enforcement preference. /// /// - Warning: Assigning this does not change the generated CSS. `!important` is driven /// entirely by ``ColorSet/isImportant`` on ``fontColor`` and ``linkColor``, and this /// property has never been read during CSS generation. Use - /// ``RichText/colorPreference(forceColor:)``, which sets both colour sets, or pass + /// ``RichText/colorPreference(forceColor:)``, which sets both color sets, or pass /// `ColorSet(light:dark:isImportant:)` directly. @available(*, deprecated, message: "Has no effect on the generated CSS. Use .colorPreference(forceColor:) on the view, or pass ColorSet(light:dark:isImportant:) for fontColor/linkColor.") public var isColorsImportant: ColorPreference { diff --git a/Sources/RichText/Models/RichTextConstants.swift b/Sources/RichText/Models/RichTextConstants.swift index e07e4b1..2abb250 100644 --- a/Sources/RichText/Models/RichTextConstants.swift +++ b/Sources/RichText/Models/RichTextConstants.swift @@ -48,7 +48,7 @@ public struct RichTextConstants { // // The percentage `min-height`/`max-height` that used to sit here resolved against a // containing block of `auto` height, so both were no-ops and neither did anything for - // the responsive behaviour. `min-height: 100%` in particular would have stretched every + // the responsive behavior. `min-height: 100%` in particular would have stretched every // image to the full container height the moment a definite height appeared. // // `loading: lazy` was also dropped: `loading` is an HTML attribute, not a CSS property, @@ -268,12 +268,12 @@ extension RichTextConstants { "iframe{width:100%; height:\(height)px; border: none;}" } - /// Link colouring. + /// Link coloring. public static func linkCSS(color: String) -> String { "a:link {color: \(color); transition: color 0.2s ease;}" } - /// A `