@@ -5,6 +5,7 @@ import CryptoKit
55import ImageIO
66import UniformTypeIdentifiers
77import SwiftUI
8+ import GutenbergKitResources
89
910/// Renders HTML content to images using a pool of WKWebView instances.
1011///
@@ -52,7 +53,7 @@ public final class HTMLPreviewManager: ObservableObject {
5253 // MARK: - Initialization
5354
5455 public init ( themeStyles: String ? = nil ) {
55- let gutenbergCSS = Self . loadGutenbergCSS ( ) ?? " "
56+ let gutenbergCSS = GutenbergKitResources . loadGutenbergCSS ( ) ?? " "
5657 assert ( !gutenbergCSS. isEmpty, " Failed to load Gutenberg CSS from bundle. Previews will not render correctly. " )
5758
5859 self . editorStyles = gutenbergCSS
@@ -67,23 +68,6 @@ public final class HTMLPreviewManager: ObservableObject {
6768 self . urlCache = HTMLPreviewManager . makeCache ( )
6869 }
6970
70- /// Loads the Gutenberg CSS from the bundled assets
71- private static func loadGutenbergCSS( ) -> String ? {
72- guard let assetsURL = Bundle . module. url ( forResource: " Gutenberg " , withExtension: nil ) else {
73- assertionFailure ( " Gutenberg resource not found in bundle " )
74- return nil
75- }
76-
77- let assetsDirectory = assetsURL. appendingPathComponent ( " assets " )
78- guard let files = try ? FileManager . default. contentsOfDirectory ( at: assetsDirectory, includingPropertiesForKeys: nil ) ,
79- let cssURL = files. first ( where: { $0. lastPathComponent. hasPrefix ( " index- " ) && $0. lastPathComponent. hasSuffix ( " .css " ) } ) ,
80- let css = try ? String ( contentsOf: cssURL, encoding: . utf8) else {
81- assertionFailure ( " Failed to load Gutenberg CSS from bundle " )
82- return nil
83- }
84- return css
85- }
86-
8771 // MARK: - Public API
8872
8973 /// Renders HTML content to an image
0 commit comments