Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1dc76926 authored by João Henrique's avatar João Henrique
Browse files

feat: Add global CSS for word breaking and overflow wrap

This commit introduces a global CSS style to ensure proper word breaking (`word-break: break-word`) and overflow wrapping (`overflow-wrap: break-word`) for all elements. This helps prevent content overflow and horizontal scrolling caused by long text strings.

The `cssStyleGlobal()` function generates the `<style>` block which is then included in the HTML `<head>` when rendering messages.
parent 1e42f25a
Loading
Loading
Loading
Loading
+21 −0
Original line number Diff line number Diff line
@@ -7,6 +7,7 @@ class DisplayHtml(private val settings: HtmlSettings) : HtmlHeadProvider {
        get() {
            return """
                <meta name="viewport" content="width=device-width"/>
                ${cssStyleGlobal()}
                ${cssStylePre()}
                ${cssStyleSignature()}
            """.trimIndent()
@@ -34,6 +35,26 @@ class DisplayHtml(private val settings: HtmlSettings) : HtmlHeadProvider {
        """.trimIndent()
    }

    /**
     * Dynamically generates a CSS style block that applies global rules to all elements (`*` selector).
     *
     * The style enforces word-breaking and overflow wrapping to prevent content overflow
     * and ensures long text strings break correctly without causing horizontal scrolling.
     *
     * @return A `<style>` element string that can be dynamically injected into the HTML `<head>`
     * to apply these global styles when rendering messages.
     */
    private fun cssStyleGlobal(): String {
        return """
            <style type="text/css">
                * {
                    word-break: break-word;
                    overflow-wrap: break-word;
                }
            </style>
        """.trimIndent()
    }

    /**
     * Dynamically generate a CSS style for `<pre>` elements.
     *