[evolution] EHTMLEditorView - When pasting text with space on end ends with space lost
- From: Tomas Popela <tpopela src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution] EHTMLEditorView - When pasting text with space on end ends with space lost
- Date: Fri, 27 Feb 2015 10:34:03 +0000 (UTC)
commit c0b4036c828e253e500108b86b7d6e73b0a91d84
Author: Tomas Popela <tpopela redhat com>
Date: Fri Feb 27 10:57:40 2015 +0100
EHTMLEditorView - When pasting text with space on end ends with space lost
e-util/e-html-editor-view.c | 38 +++++++++++++++++++++++++++-----------
1 files changed, 27 insertions(+), 11 deletions(-)
---
diff --git a/e-util/e-html-editor-view.c b/e-util/e-html-editor-view.c
index c092783..43da38e 100644
--- a/e-util/e-html-editor-view.c
+++ b/e-util/e-html-editor-view.c
@@ -4528,7 +4528,6 @@ parse_html_into_paragraphs (EHTMLEditorView *view,
gchar *truncated = g_strdup (rest);
gchar *rest_to_insert;
- g_strchomp (truncated);
empty = !*truncated && strlen (rest) > 0;
if (strchr (" +- *=\t;#", *rest))
@@ -4696,8 +4695,6 @@ parse_html_into_paragraphs (EHTMLEditorView *view,
goto end;
}
- g_strchomp (truncated);
-
rest_to_insert = g_regex_replace_eval (
regex_nbsp,
truncated,
@@ -5336,7 +5333,7 @@ html_editor_view_insert_converted_html_into_selection (EHTMLEditorView *view,
remove_node (child);
parent = get_parent_block_node_from_child (
- WEBKIT_DOM_NODE (selection_end_marker)),
+ WEBKIT_DOM_NODE (selection_end_marker));
child = webkit_dom_node_get_next_sibling (
WEBKIT_DOM_NODE (selection_end_marker));
@@ -5353,7 +5350,12 @@ html_editor_view_insert_converted_html_into_selection (EHTMLEditorView *view,
/* Caret will be restored on the end of pasted text */
webkit_dom_node_append_child (
last_paragraph,
- e_html_editor_selection_get_caret_position_node (document),
+ WEBKIT_DOM_NODE (create_selection_marker (document, TRUE)),
+ NULL);
+
+ webkit_dom_node_append_child (
+ last_paragraph,
+ WEBKIT_DOM_NODE (create_selection_marker (document, FALSE)),
NULL);
/* Insert the paragraph with the end of the pasted text after
@@ -5423,7 +5425,6 @@ html_editor_view_insert_converted_html_into_selection (EHTMLEditorView *view,
e_html_editor_view_exec_command (
view, E_HTML_EDITOR_VIEW_COMMAND_DELETE, NULL);
- e_html_editor_selection_restore_caret_position (selection);
g_object_unref (element);
goto out;
}
@@ -5431,11 +5432,26 @@ html_editor_view_insert_converted_html_into_selection (EHTMLEditorView *view,
remove_node (WEBKIT_DOM_NODE (selection_start_marker));
remove_node (WEBKIT_DOM_NODE (selection_end_marker));
- inner_html = webkit_dom_html_element_get_inner_html (
- WEBKIT_DOM_HTML_ELEMENT (element));
- e_html_editor_view_exec_command (
- view, E_HTML_EDITOR_VIEW_COMMAND_INSERT_HTML, inner_html);
- g_free (inner_html);
+ if (!is_html && webkit_dom_element_get_child_element_count (element) == 1) {
+ inner_html = webkit_dom_html_element_get_inner_text (
+ WEBKIT_DOM_HTML_ELEMENT (element));
+ e_html_editor_view_exec_command (
+ view, E_HTML_EDITOR_VIEW_COMMAND_INSERT_TEXT, inner_html);
+ g_free (inner_html);
+ } else {
+ inner_html = webkit_dom_html_element_get_inner_html (
+ WEBKIT_DOM_HTML_ELEMENT (element));
+ e_html_editor_view_exec_command (
+ view, E_HTML_EDITOR_VIEW_COMMAND_INSERT_HTML, inner_html);
+ g_free (inner_html);
+ inner_html = webkit_dom_html_element_get_inner_text (
+ WEBKIT_DOM_HTML_ELEMENT (element));
+ if (g_str_has_suffix (inner_html, " ")) {
+ e_html_editor_view_exec_command (
+ view, E_HTML_EDITOR_VIEW_COMMAND_INSERT_TEXT, " ");
+ }
+ g_free (inner_html);
+ }
g_object_unref (element);
e_html_editor_selection_save (selection);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]