[evolution] EHTMLEditorView - 'Paste Quotation' action in HTML mode is not setting the caret to the right positi



commit a8992969abcba9cd9479d787f28b67387b3e59bf
Author: Tomas Popela <tpopela redhat com>
Date:   Sun Dec 6 14:58:32 2015 +0100

    EHTMLEditorView - 'Paste Quotation' action in HTML mode is not setting the caret to the right position

 e-util/e-html-editor-view.c |   29 ++++++++++++++++-------------
 1 files changed, 16 insertions(+), 13 deletions(-)
---
diff --git a/e-util/e-html-editor-view.c b/e-util/e-html-editor-view.c
index cb4e2c5..9f67b0c 100644
--- a/e-util/e-html-editor-view.c
+++ b/e-util/e-html-editor-view.c
@@ -7515,7 +7515,7 @@ e_html_editor_view_insert_quoted_text (EHTMLEditorView *view,
        gchar *escaped_text, *inner_html;
        WebKitDOMDocument *document;
        WebKitDOMElement *blockquote, *element, *selection_start;
-       WebKitDOMNode *sibling;
+       WebKitDOMNode *node;
 
        if (!text || !*text)
                return;
@@ -7560,14 +7560,14 @@ e_html_editor_view_insert_quoted_text (EHTMLEditorView *view,
 
        selection_start = webkit_dom_document_get_element_by_id (
                document, "-x-evo-selection-start-marker");
-       sibling = webkit_dom_node_get_previous_sibling (WEBKIT_DOM_NODE (selection_start));
+       node = webkit_dom_node_get_previous_sibling (WEBKIT_DOM_NODE (selection_start));
        /* Check if block is empty. If so, replace it otherwise insert the quoted
         * content after current block. */
-       if (!sibling || WEBKIT_DOM_IS_HTMLBR_ELEMENT (sibling)) {
-               sibling = webkit_dom_node_get_next_sibling (
+       if (!node || WEBKIT_DOM_IS_HTMLBR_ELEMENT (node)) {
+               node = webkit_dom_node_get_next_sibling (
                        WEBKIT_DOM_NODE (selection_start));
-               sibling = webkit_dom_node_get_next_sibling (sibling);
-               if (!sibling || WEBKIT_DOM_IS_HTMLBR_ELEMENT (sibling)) {
+               node = webkit_dom_node_get_next_sibling (node);
+               if (!node || WEBKIT_DOM_IS_HTMLBR_ELEMENT (node)) {
                        webkit_dom_node_replace_child (
                                webkit_dom_node_get_parent_node (
                                        webkit_dom_node_get_parent_node (
@@ -7588,12 +7588,12 @@ e_html_editor_view_insert_quoted_text (EHTMLEditorView *view,
 
        parse_html_into_blocks (view, document, blockquote, NULL, inner_html);
 
-       if (!e_html_editor_view_get_html_mode (view)) {
-               WebKitDOMNode *node;
+       if (e_html_editor_view_get_html_mode (view)) {
+               node = webkit_dom_node_get_last_child (WEBKIT_DOM_NODE (blockquote));
+       } else {
                gint word_wrap_length;
 
                element_add_class (blockquote, "-x-evo-plaintext-quoted");
-
                word_wrap_length = e_html_editor_selection_get_word_wrap_length (selection);
                node = webkit_dom_node_get_first_child (WEBKIT_DOM_NODE (blockquote));
                while (node) {
@@ -7608,12 +7608,17 @@ e_html_editor_view_insert_quoted_text (EHTMLEditorView *view,
 
                        next_sibling = webkit_dom_node_get_next_sibling (node);
                        if (!next_sibling)
-                               add_selection_markers_into_element_end (
-                                       document, WEBKIT_DOM_ELEMENT (node), NULL, NULL);
+                               break;
+
                        node = next_sibling;
                }
        }
 
+       add_selection_markers_into_element_end (
+               document, WEBKIT_DOM_ELEMENT (node), NULL, NULL);
+
+       e_html_editor_selection_restore (selection);
+
        if (ev) {
                e_html_editor_selection_get_selection_coordinates (
                        selection,
@@ -7624,8 +7629,6 @@ e_html_editor_view_insert_quoted_text (EHTMLEditorView *view,
                e_html_editor_view_insert_new_history_event (view, ev);
        }
 
-       e_html_editor_selection_restore (selection);
-
        e_html_editor_view_force_spell_check_in_viewport (view);
 
        e_html_editor_view_set_changed (view, TRUE);


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