[evolution] EHTMLEditorView - When changing from html to plain text mode adjust composer's content



commit 5be727eeb41f8bb204784bf043b25373d723eff3
Author: Tomas Popela <tpopela redhat com>
Date:   Fri Jun 13 14:44:41 2014 +0200

    EHTMLEditorView - When changing from html to plain text mode adjust composer's content
    
    Apply width limits to paragraphs, remove images and replace smileys with its text version.

 e-util/e-html-editor-view.c |   19 +++++++++++--------
 1 files changed, 11 insertions(+), 8 deletions(-)
---
diff --git a/e-util/e-html-editor-view.c b/e-util/e-html-editor-view.c
index 02965c9..c843afd 100644
--- a/e-util/e-html-editor-view.c
+++ b/e-util/e-html-editor-view.c
@@ -4761,7 +4761,6 @@ toggle_paragraphs_style_in_element (EHTMLEditorView *view,
        gint ii, length;
        WebKitDOMNodeList *paragraphs;
 
-       html_mode = e_html_editor_view_get_html_mode (view);
        selection = e_html_editor_view_get_selection (view);
 
        paragraphs = webkit_dom_element_query_selector_all (
@@ -4799,22 +4798,22 @@ toggle_paragraphs_style_in_element (EHTMLEditorView *view,
                        /* If the paragraph is inside indented paragraph don't set
                         * the style as it will be inherited */
                        if (!element_has_class (WEBKIT_DOM_ELEMENT (parent), "-x-evo-indented")) {
+                               const gchar *style_to_add = "";
                                style = webkit_dom_element_get_attribute (
                                        WEBKIT_DOM_ELEMENT (node), "style");
 
                                if ((css_align = strstr (style, "text-align: "))) {
-                                       const gchar *style_to_add;
-
                                        style_to_add = g_str_has_prefix (
                                                css_align + 12, "center") ?
                                                        "text-align: center;" :
                                                        "text-align: right;";
-
-                                       /* In HTML mode the paragraphs have width limit */
-                                       e_html_editor_selection_set_paragraph_style (
-                                               selection, WEBKIT_DOM_ELEMENT (node),
-                                               -1, 0, style_to_add);
                                }
+
+                               /* In plain text mode the paragraphs have width limit */
+                               e_html_editor_selection_set_paragraph_style (
+                                       selection, WEBKIT_DOM_ELEMENT (node),
+                                       -1, 0, style_to_add);
+
                                g_free (style);
                        }
                }
@@ -5280,6 +5279,10 @@ convert_when_changing_composer_mode (EHTMLEditorView *view)
                e_html_editor_selection_restore_caret_position (selection);
        }
 
+       toggle_paragraphs_style (view);
+       toggle_smileys (view);
+       remove_images (view);
+
        clear_attributes (document);
 
        webkit_dom_element_set_attribute (


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