[evolution] EHTMLEditorSelection - Fix caret position when changing block format



commit e88d5106a1d4e2e83a48d893c16eb1c15b4e54a5
Author: Tomas Popela <tpopela redhat com>
Date:   Thu Jun 19 14:37:35 2014 +0200

    EHTMLEditorSelection - Fix caret position when changing block format

 e-util/e-html-editor-selection.c |   14 ++++++++++++++
 1 files changed, 14 insertions(+), 0 deletions(-)
---
diff --git a/e-util/e-html-editor-selection.c b/e-util/e-html-editor-selection.c
index 66977b4..a9ba9a7 100644
--- a/e-util/e-html-editor-selection.c
+++ b/e-util/e-html-editor-selection.c
@@ -1699,6 +1699,8 @@ format_change_block_to_block (EHTMLEditorSelection *selection,
        /* Process all blocks that are in the selection one by one */
        while (block) {
                gboolean quoted = FALSE;
+               gboolean empty = FALSE;
+               gchar *content;
                WebKitDOMNode *child;
 
                if (webkit_dom_element_query_selector (
@@ -1723,6 +1725,18 @@ format_change_block_to_block (EHTMLEditorSelection *selection,
                        element = webkit_dom_document_create_element (
                                document, value, NULL);
 
+               content = webkit_dom_node_get_text_content (block);
+
+               empty = !*content || (g_strcmp0 (content, UNICODE_ZERO_WIDTH_SPACE) == 0);
+               g_free (content);
+
+               if (empty) {
+                       webkit_dom_html_element_set_inner_html (
+                               WEBKIT_DOM_HTML_ELEMENT (element),
+                               UNICODE_ZERO_WIDTH_SPACE,
+                               NULL);
+               }
+
                while ((child = webkit_dom_node_get_first_child (block)))
                        webkit_dom_node_append_child (
                                WEBKIT_DOM_NODE (element), child, NULL);


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