[evolution] I#1403 - WebView: Automatically switch text direction according to the text



commit 558073ad8e06e1c54a7e9dbbc2daa2bf9126d442
Author: Milan Crha <mcrha redhat com>
Date:   Tue Mar 2 09:27:48 2021 +0100

    I#1403 - WebView: Automatically switch text direction according to the text
    
    Closes https://gitlab.gnome.org/GNOME/evolution/-/issues/1403

 data/webkit/webview-print.css               | 4 ++++
 data/webkit/webview.css                     | 4 ++++
 src/e-util/e-web-view.c                     | 7 +++++++
 src/modules/webkit-editor/e-webkit-editor.c | 8 +++++---
 4 files changed, 20 insertions(+), 3 deletions(-)
---
diff --git a/data/webkit/webview-print.css b/data/webkit/webview-print.css
index c215bc7323..1962e4c221 100644
--- a/data/webkit/webview-print.css
+++ b/data/webkit/webview-print.css
@@ -9,6 +9,10 @@ body {
         margin: 10px;
 }
 
+body, div, p, td {
+  unicode-bidi: plaintext;
+}
+
 h1,h2,h3 {
         color: #7f7f7f;
 }
diff --git a/data/webkit/webview.css b/data/webkit/webview.css
index a04154733c..4ad90c97f8 100644
--- a/data/webkit/webview.css
+++ b/data/webkit/webview.css
@@ -12,6 +12,10 @@ body {
   margin: 5px 10px 5px 10px;
 }
 
+body, div, p, td {
+  unicode-bidi: plaintext;
+}
+
 th {
   text-align: left;
   vertical-align: top;
diff --git a/src/e-util/e-web-view.c b/src/e-util/e-web-view.c
index 3903e1531d..07642978c0 100644
--- a/src/e-util/e-web-view.c
+++ b/src/e-util/e-web-view.c
@@ -829,6 +829,13 @@ e_web_view_update_styles (EWebView *web_view,
 
        g_free (color_value);
        g_free (style);
+
+       e_web_view_jsc_add_rule_into_style_sheet (webkit_web_view,
+               iframe_id,
+               "-e-web-view-style-sheet",
+               "body, div, p, td",
+               "unicode-bidi: plaintext;",
+               web_view->priv->cancellable);
 }
 
 static void
diff --git a/src/modules/webkit-editor/e-webkit-editor.c b/src/modules/webkit-editor/e-webkit-editor.c
index 85d4fe6de2..8847572bd0 100644
--- a/src/modules/webkit-editor/e-webkit-editor.c
+++ b/src/modules/webkit-editor/e-webkit-editor.c
@@ -1216,19 +1216,21 @@ webkit_editor_update_styles (EContentEditor *editor)
                "  font-size: %spt;\n"
                "  font-weight: %d;\n"
                "  font-style: %s;\n"
-               " -webkit-line-break: after-white-space;\n",
+               " -webkit-line-break: after-white-space;\n"
+               "}\n",
                pango_font_description_get_family (vw),
                fsbuff,
                pango_font_description_get_weight (vw),
                styles[pango_font_description_get_style (vw)]);
 
-       g_string_append (stylesheet, "}\n");
-
        g_ascii_dtostr (fsbuff, G_ASCII_DTOSTR_BUF_SIZE,
                ((gdouble) pango_font_description_get_size (ms)) / PANGO_SCALE);
 
        g_string_append_printf (
                stylesheet,
+               "body, div, p, td {\n"
+               "  unicode-bidi: plaintext;\n"
+               "}\n"
                "pre,code,.pre {\n"
                "  font-family: '%s';\n"
                "  font-size: %spt;\n"


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]