[evolution/wip/webkit2] EHTMLEditorSelection - Copy&pasting quoted content in plain text composer preserves formatting



commit f9bdbb15c180da4856dc7e986dbf0ce0db62b06f
Author: Tomas Popela <tpopela redhat com>
Date:   Fri Feb 26 11:39:55 2016 +0100

    EHTMLEditorSelection - Copy&pasting quoted content in plain text composer preserves formatting

 .../composer/e-html-editor-view-dom-functions.c    |   16 +++++++++++++++-
 1 files changed, 15 insertions(+), 1 deletions(-)
---
diff --git a/web-extensions/composer/e-html-editor-view-dom-functions.c 
b/web-extensions/composer/e-html-editor-view-dom-functions.c
index 04ac8af..fbada06 100644
--- a/web-extensions/composer/e-html-editor-view-dom-functions.c
+++ b/web-extensions/composer/e-html-editor-view-dom-functions.c
@@ -7227,6 +7227,19 @@ dom_get_inline_images_data (WebKitDOMDocument *document,
        return result;
 }
 
+static gboolean
+pasting_quoted_content (const gchar *content)
+{
+       /* Check if the content we are pasting is a quoted content from composer.
+        * If it is, we can't use WebKit to paste it as it would leave the formatting
+        * on the content. */
+       return g_str_has_prefix (
+               content,
+               "<meta http-equiv=\"content-type\" content=\"text/html; "
+               "charset=utf-8\"><blockquote type=\"cite\"") &&
+               strstr (content, "\"-x-evo-");
+}
+
 /**
  * e_html_editor_selection_insert_html:
  * @selection: an #EHTMLEditorSelection
@@ -7270,7 +7283,8 @@ dom_insert_html (WebKitDOMDocument *document,
        }
 
        if (e_html_editor_web_extension_get_html_mode (extension) ||
-           e_html_editor_web_extension_is_pasting_content_from_itself (extension)) {
+           (e_html_editor_web_extension_is_pasting_content_from_itself (extension) &&
+           !pasting_quoted_content (html_text))) {
                if (!dom_selection_is_collapsed (document)) {
                        EHTMLEditorHistoryEvent *event;
                        WebKitDOMDocumentFragment *fragment;


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