aboutsummaryrefslogtreecommitdiffstats
path: root/e-util
diff options
context:
space:
mode:
authorTomas Popela <tpopela@redhat.com>2014-06-10 19:02:20 +0800
committerTomas Popela <tpopela@redhat.com>2014-06-10 19:02:20 +0800
commit3cdb643ec2d4e87eb3508043915b5f7b18a04cdb (patch)
tree8e455a0a9c5cec733561a0df63962b99b0324c46 /e-util
parent1ab3eeec5ddc03584dbac05c6f4a0b8879faa000 (diff)
downloadgsoc2013-evolution-3cdb643ec2d4e87eb3508043915b5f7b18a04cdb.tar
gsoc2013-evolution-3cdb643ec2d4e87eb3508043915b5f7b18a04cdb.tar.gz
gsoc2013-evolution-3cdb643ec2d4e87eb3508043915b5f7b18a04cdb.tar.bz2
gsoc2013-evolution-3cdb643ec2d4e87eb3508043915b5f7b18a04cdb.tar.lz
gsoc2013-evolution-3cdb643ec2d4e87eb3508043915b5f7b18a04cdb.tar.xz
gsoc2013-evolution-3cdb643ec2d4e87eb3508043915b5f7b18a04cdb.tar.zst
gsoc2013-evolution-3cdb643ec2d4e87eb3508043915b5f7b18a04cdb.zip
EHTMLEditor: Fix various bugs in block in/undent
Fix the wrong position of caret when in/undenting empty block and don't lose spell checked words when in/undenting. Also don't insert unnecessary empty lines into plain text version of message when processing indented block.
Diffstat (limited to 'e-util')
-rw-r--r--e-util/e-html-editor-selection.c32
-rw-r--r--e-util/e-html-editor-view.c6
2 files changed, 24 insertions, 14 deletions
diff --git a/e-util/e-html-editor-selection.c b/e-util/e-html-editor-selection.c
index 131fc86ead..a9d856eea5 100644
--- a/e-util/e-html-editor-selection.c
+++ b/e-util/e-html-editor-selection.c
@@ -2486,10 +2486,10 @@ e_html_editor_selection_indent (EHTMLEditorSelection *selection)
source_list, WEBKIT_DOM_NODE (list), node, NULL);
webkit_dom_node_append_child (
WEBKIT_DOM_NODE (list), node, NULL);
- if (!webkit_dom_node_contains (node, WEBKIT_DOM_NODE (caret_position))) {
+
+ if (!webkit_dom_node_contains (node, WEBKIT_DOM_NODE (caret_position)))
webkit_dom_node_append_child (
node, WEBKIT_DOM_NODE (caret_position), NULL);
- }
merge_lists_if_possible (WEBKIT_DOM_NODE (list));
@@ -2519,6 +2519,22 @@ e_html_editor_selection_indent (EHTMLEditorSelection *selection)
element = e_html_editor_selection_get_indented_element (
selection, document, final_width);
+ /* Reinsert caret position node if the node is missing it */
+ if (!webkit_dom_node_contains (clone, WEBKIT_DOM_NODE (caret_position))) {
+ gchar *text_content = webkit_dom_node_get_text_content (clone);
+ if (!*text_content) {
+ webkit_dom_html_element_set_inner_html (
+ WEBKIT_DOM_HTML_ELEMENT (clone),
+ UNICODE_ZERO_WIDTH_SPACE,
+ NULL);
+ }
+ g_free (text_content);
+ webkit_dom_node_append_child (
+ clone,
+ WEBKIT_DOM_NODE (caret_position),
+ NULL);
+ }
+
webkit_dom_node_append_child (
WEBKIT_DOM_NODE (element),
clone,
@@ -2537,7 +2553,7 @@ e_html_editor_selection_indent (EHTMLEditorSelection *selection)
e_html_editor_view_exec_command (view, command, NULL);
}
- e_html_editor_view_force_spell_check_for_current_paragraph (view);
+ e_html_editor_view_force_spell_check (view);
if (has_selection)
e_html_editor_selection_restore (selection);
@@ -2686,6 +2702,7 @@ e_html_editor_selection_unindent (EHTMLEditorSelection *selection)
e_html_editor_selection_clear_caret_position_marker (selection);
unindent_list (selection, document);
+ e_html_editor_view_force_spell_check (view);
e_html_editor_selection_restore (selection);
g_object_unref (view);
return;
@@ -2698,7 +2715,7 @@ e_html_editor_selection_unindent (EHTMLEditorSelection *selection)
level = get_indentation_level (element);
width = word_wrap_length - SPACES_PER_INDENTATION * level;
- clone = WEBKIT_DOM_NODE (webkit_dom_node_clone_node (WEBKIT_DOM_NODE (element), TRUE));
+ clone = webkit_dom_node_clone_node (WEBKIT_DOM_NODE (element), TRUE);
/* Look if we have previous siblings, if so, we have to
* create new blockquote that will include them */
@@ -2738,8 +2755,6 @@ e_html_editor_selection_unindent (EHTMLEditorSelection *selection)
WEBKIT_DOM_NODE (next_blockquote),
child,
NULL);
-
- remove_node (child);
}
element_remove_class (WEBKIT_DOM_ELEMENT (node_clone), "-x-evo-to-unindent");
@@ -2757,10 +2772,9 @@ e_html_editor_selection_unindent (EHTMLEditorSelection *selection)
/* Reinsert the caret position */
if (reinsert_caret_position) {
- webkit_dom_node_insert_before (
+ webkit_dom_node_append_child (
node_clone,
caret_node,
- webkit_dom_node_get_first_child (node_clone),
NULL);
}
@@ -2796,7 +2810,7 @@ e_html_editor_selection_unindent (EHTMLEditorSelection *selection)
e_html_editor_view_exec_command (view, command, NULL);
}
- e_html_editor_view_force_spell_check_for_current_paragraph (view);
+ e_html_editor_view_force_spell_check (view);
if (has_selection)
e_html_editor_selection_restore (selection);
diff --git a/e-util/e-html-editor-view.c b/e-util/e-html-editor-view.c
index 4ad98b2fd9..b2b51cf9e6 100644
--- a/e-util/e-html-editor-view.c
+++ b/e-util/e-html-editor-view.c
@@ -4602,11 +4602,7 @@ process_elements (EHTMLEditorView *view,
* signature we are not adding the BR element */
if (!next_sibling)
add_br = FALSE;
-
- if (element_has_class (webkit_dom_node_get_parent_element (node), "-x-evo-indented"))
- add_br = FALSE;
-
- if (next_sibling && WEBKIT_DOM_IS_HTML_DIV_ELEMENT (next_sibling)) {
+ else if (next_sibling && WEBKIT_DOM_IS_HTML_DIV_ELEMENT (next_sibling)) {
if (webkit_dom_element_query_selector (
WEBKIT_DOM_ELEMENT (next_sibling),
"span.-x-evo-signature", NULL)) {