NuPlay / RichText

Easily show RichText(html) in SwiftUI
MIT License
209 stars 36 forks source link

Modify css access level to public #44

Open gewill opened 8 months ago

gewill commented 8 months ago

Modify the access level of css to public in order to customize the WebView. This change allows users to apply their own styles to the WebView.

NuPlay commented 7 months ago

I understand that our library already has a customCSS option. Are you seeking to completely exclude the default provided CSS for a specific purpose? 🤔

Modifying the CSS function alone does not result in a complete change of styles. As shown in the code snippet:

case .auto:
    return """
    <style type='text/css'>
    @media (prefers-color-scheme: light) {
        \(conf.css(isLight: true, alignment: alignment))
    }
    @media (prefers-color-scheme: dark) {
        \(conf.css(isLight: false, alignment: alignment))
    }
    \(conf.customCSS)
    body {
        margin: 0;
        padding: 0;
    }
    </style>
    <BODY>
    """

Additional CSS is applied here. If you're looking to completely edit the styling, we might need to consider adding an option to accommodate this.

gewill commented 7 months ago

I understand that our library already has a customCSS option. Are you seeking to completely exclude the default provided CSS for a specific purpose? 🤔

Modifying the CSS function alone does not result in a complete change of styles. As shown in the code snippet:

case .auto:
    return """
    <style type='text/css'>
    @media (prefers-color-scheme: light) {
        \(conf.css(isLight: true, alignment: alignment))
    }
    @media (prefers-color-scheme: dark) {
        \(conf.css(isLight: false, alignment: alignment))
    }
    \(conf.customCSS)
    body {
        margin: 0;
        padding: 0;
    }
    </style>
    <BODY>
    """

Additional CSS is applied here. If you're looking to completely edit the styling, we might need to consider adding an option to accommodate this.

Actually, I used WKNavigationDelegate from WKWebView and needed to customize business requirements, which is why I customized WebView. But I prefer using default css in RichText.