[evolution] EHTMLEditorView - Pasting HTML content with new lines between elements inserts these lines into com



commit 148bc7fc0050c76bf39540c28868e12d31f6963a
Author: Tomas Popela <tpopela redhat com>
Date:   Fri Oct 16 14:47:39 2015 +0200

    EHTMLEditorView  - Pasting HTML content with new lines between elements inserts these lines into composer
    
    Before processing the HTML we need to remove the new lines between elements otherwise
    they will be inserted to the composer as well.

 e-util/e-html-editor-view.c |   19 +++++++++++++++++--
 1 files changed, 17 insertions(+), 2 deletions(-)
---
diff --git a/e-util/e-html-editor-view.c b/e-util/e-html-editor-view.c
index 868982d..0cf1efa 100644
--- a/e-util/e-html-editor-view.c
+++ b/e-util/e-html-editor-view.c
@@ -7926,8 +7926,23 @@ html_editor_view_insert_converted_html_into_selection (EHTMLEditorView *view,
        if (is_html) {
                gchar *inner_text;
 
-               webkit_dom_html_element_set_inner_html (
-                       WEBKIT_DOM_HTML_ELEMENT (element), html, NULL);
+               if (strstr (html, "\n")) {
+                       GRegex *regex;
+                       gchar *tmp;
+
+                       /* Strip new lines between tags to avoid unwanted line breaks. */
+                       regex = g_regex_new ("\\>[\\s]+\\<", 0, 0, NULL);
+                       tmp = g_regex_replace (
+                               regex, html, -1, 0, "> <", 0, NULL);
+                       webkit_dom_html_element_set_inner_html (
+                               WEBKIT_DOM_HTML_ELEMENT (element), tmp, NULL);
+                       g_free (tmp);
+                       g_regex_unref (regex);
+               } else {
+                       webkit_dom_html_element_set_inner_html (
+                               WEBKIT_DOM_HTML_ELEMENT (element), html, NULL);
+               }
+
                inner_text = webkit_dom_html_element_get_inner_text (
                        WEBKIT_DOM_HTML_ELEMENT (element));
                webkit_dom_html_element_set_inner_text (


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