[evolution/wip/webkit2] EHTMLEditorView - Plain text version of draft could lose formatting



commit d445d21da5550cf82034303ad348de4abd2cf1bc
Author: Tomas Popela <tpopela redhat com>
Date:   Thu Jun 30 12:01:10 2016 +0200

    EHTMLEditorView - Plain text version of draft could lose formatting
    
    When generating a plain text version of the HTML draft we can use just the
    simplified conversion.

 .../web-extension/e-editor-dom-functions.c         |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)
---
diff --git a/modules/webkit-editor/web-extension/e-editor-dom-functions.c 
b/modules/webkit-editor/web-extension/e-editor-dom-functions.c
index e8afb22..9c4a8da 100644
--- a/modules/webkit-editor/web-extension/e-editor-dom-functions.c
+++ b/modules/webkit-editor/web-extension/e-editor-dom-functions.c
@@ -7973,17 +7973,19 @@ process_content_for_mode_change (EEditorPage *editor_page)
 gchar *
 e_editor_dom_process_content_for_plain_text (EEditorPage *editor_page)
 {
+       EContentEditorContentFlags flags;
        WebKitDOMDocument *document;
        WebKitDOMNode *body, *source;
        WebKitDOMNodeList *paragraphs;
        gboolean wrap = FALSE, quote = FALSE, clean = FALSE;
-       gboolean converted, is_from_new_message;
+       gboolean converted, is_from_new_message, is_message_draft;
        gint length, ii;
        GString *plain_text;
 
        g_return_val_if_fail (E_IS_EDITOR_PAGE (editor_page), NULL);
 
        document = e_editor_page_get_document (editor_page);
+       flags = e_editor_page_get_current_content_flags (editor_page);
        plain_text = g_string_sized_new (1024);
 
        body = WEBKIT_DOM_NODE (webkit_dom_document_get_body (document));
@@ -7991,13 +7993,15 @@ e_editor_dom_process_content_for_plain_text (EEditorPage *editor_page)
                WEBKIT_DOM_ELEMENT (body), "data-converted");
        is_from_new_message = webkit_dom_element_has_attribute (
                WEBKIT_DOM_ELEMENT (body), "data-new-message");
+       is_message_draft = (flags & E_CONTENT_EDITOR_MESSAGE_DRAFT);
+
        source = webkit_dom_node_clone_node_with_error (WEBKIT_DOM_NODE (body), TRUE, NULL);
 
        e_editor_dom_selection_save (editor_page);
 
        /* If composer is in HTML mode we have to move the content to plain version */
        if (e_editor_page_get_html_mode (editor_page)) {
-               if (converted || is_from_new_message) {
+               if (converted || is_from_new_message || is_message_draft) {
                        toggle_paragraphs_style_in_element (
                                editor_page, WEBKIT_DOM_ELEMENT (source), FALSE);
                        remove_images_in_element (


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