122 lines
4.5 KiB
Diff
122 lines
4.5 KiB
Diff
From 410c434c48657ea49ac05dffc9f5d8c6a7d282bc Mon Sep 17 00:00:00 2001
|
|
From: Tomas Popela <tpopela@redhat.com>
|
|
Date: Thu, 16 Jul 2015 14:26:30 +0200
|
|
Subject: Bug 751225 - Spell check selection changes font settings to initial settings
|
|
|
|
Do the replace ourselves as the PasteAndmatchStyle function operates on clipboard's
|
|
content and doesn't accept the replacement that we pass to it.
|
|
|
|
From 27c003010fd4cc00ebdc458d3f10f206ef79f129 Mon Sep 17 00:00:00 2001
|
|
From: Tomas Popela <tpopela@redhat.com>
|
|
Date: Thu, 16 Jul 2015 14:22:19 +0200
|
|
Subject: EHTMLEditorSelection - Copy&pasting quoted content in plain text composer preserves formatting
|
|
|
|
From ca9718a86a90ad24adbfc14fc4dca0998c3f94c8 Mon Sep 17 00:00:00 2001
|
|
From: Tomas Popela <tpopela@redhat.com>
|
|
Date: Thu, 16 Jul 2015 14:21:30 +0200
|
|
Subject: EHTMLEditorView - Pasting content from message source into plain text composer preserves formatting
|
|
|
|
diff --git a/e-util/e-html-editor-selection.c b/e-util/e-html-editor-selection.c
|
|
index d410518..61d1079 100644
|
|
--- a/e-util/e-html-editor-selection.c
|
|
+++ b/e-util/e-html-editor-selection.c
|
|
@@ -996,8 +996,10 @@ e_html_editor_selection_replace_caret_word (EHTMLEditorSelection *selection,
|
|
EHTMLEditorView *view;
|
|
WebKitWebView *web_view;
|
|
WebKitDOMDocument *document;
|
|
+ WebKitDOMDocumentFragment *fragment;
|
|
WebKitDOMDOMWindow *dom_window;
|
|
WebKitDOMDOMSelection *dom_selection;
|
|
+ WebKitDOMNode *node;
|
|
WebKitDOMRange *range;
|
|
|
|
g_return_if_fail (E_IS_HTML_EDITOR_SELECTION (selection));
|
|
@@ -1015,14 +1017,40 @@ e_html_editor_selection_replace_caret_word (EHTMLEditorSelection *selection,
|
|
|
|
webkit_dom_range_expand (range, "word", NULL);
|
|
webkit_dom_dom_selection_add_range (dom_selection, range);
|
|
- g_object_unref (range);
|
|
- g_object_unref (dom_selection);
|
|
- g_object_unref (dom_window);
|
|
|
|
- e_html_editor_view_exec_command (
|
|
- view, E_HTML_EDITOR_VIEW_COMMAND_PASTE_AND_MATCH_STYLE, replacement);
|
|
+ fragment = webkit_dom_range_extract_contents (range, NULL);
|
|
+
|
|
+ /* Get the text node to replace and leave other formatting nodes
|
|
+ * untouched (font color, boldness, ...). */
|
|
+ webkit_dom_node_normalize (WEBKIT_DOM_NODE (fragment));
|
|
+ node = webkit_dom_node_get_first_child (WEBKIT_DOM_NODE (fragment));
|
|
+ if (!WEBKIT_DOM_IS_TEXT (node)) {
|
|
+ while (node && WEBKIT_DOM_IS_ELEMENT (node))
|
|
+ node = webkit_dom_node_get_first_child (node);
|
|
+ }
|
|
+
|
|
+ if (node && WEBKIT_DOM_IS_TEXT (node)) {
|
|
+ WebKitDOMText *text;
|
|
+
|
|
+ /* Replace the word */
|
|
+ text = webkit_dom_document_create_text_node (document, replacement);
|
|
+ webkit_dom_node_replace_child (
|
|
+ webkit_dom_node_get_parent_node (node),
|
|
+ WEBKIT_DOM_NODE (text),
|
|
+ node,
|
|
+ NULL);
|
|
+
|
|
+ /* Insert the word on current location. */
|
|
+ webkit_dom_range_insert_node (range, WEBKIT_DOM_NODE (fragment), NULL);
|
|
+
|
|
+ webkit_dom_dom_selection_collapse_to_end (dom_selection, NULL);
|
|
+ }
|
|
+
|
|
e_html_editor_view_force_spell_check_for_current_paragraph (view);
|
|
|
|
+ g_object_unref (range);
|
|
+ g_object_unref (dom_selection);
|
|
+ g_object_unref (dom_window);
|
|
g_object_unref (view);
|
|
}
|
|
|
|
@@ -5684,6 +5684,19 @@ e_html_editor_selection_insert_text (EHTMLEditorSelection *selection,
|
|
g_object_unref (view);
|
|
}
|
|
|
|
+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
|
|
@@ -5729,7 +5742,8 @@ e_html_editor_selection_insert_html (EHTMLEditorSelection *selection,
|
|
|
|
command = E_HTML_EDITOR_VIEW_COMMAND_INSERT_HTML;
|
|
if (e_html_editor_view_get_html_mode (view) ||
|
|
- e_html_editor_view_is_pasting_content_from_itself (view)) {
|
|
+ (e_html_editor_view_is_pasting_content_from_itself (view) &&
|
|
+ !pasting_quoted_content (html_text))) {
|
|
if (!e_html_editor_selection_is_collapsed (selection)) {
|
|
EHTMLEditorViewHistoryEvent *event;
|
|
WebKitDOMDocumentFragment *fragment;
|
|
diff --git a/e-util/e-html-editor-view.c b/e-util/e-html-editor-view.c
|
|
index 2751310..5e07c7f 100644
|
|
--- a/e-util/e-html-editor-view.c
|
|
+++ b/e-util/e-html-editor-view.c
|
|
@@ -10106,7 +10106,7 @@ html_editor_view_owner_change_primary_cb (GtkClipboard *clipboard,
|
|
if (!E_IS_HTML_EDITOR_VIEW (view))
|
|
return;
|
|
|
|
- if (!event->owner)
|
|
+ if (!event->owner || !view->priv->can_copy)
|
|
view->priv->copy_paste_primary_in_view = FALSE;
|
|
}
|
|
|