aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--e-util/e-html-editor-view.c72
1 files changed, 51 insertions, 21 deletions
diff --git a/e-util/e-html-editor-view.c b/e-util/e-html-editor-view.c
index bac4e0ed47..d8fadac1a5 100644
--- a/e-util/e-html-editor-view.c
+++ b/e-util/e-html-editor-view.c
@@ -4415,13 +4415,15 @@ html_editor_view_insert_converted_html_into_selection (EHTMLEditorView *view,
WEBKIT_DOM_NODE (element));
node = webkit_dom_node_get_next_sibling (WEBKIT_DOM_NODE (parent));
- node = webkit_dom_node_get_first_child (node);
if (node) {
- inner_html = webkit_dom_node_get_text_content (node);
- if (g_str_has_prefix (inner_html, UNICODE_NBSP))
- webkit_dom_character_data_replace_data (
- WEBKIT_DOM_CHARACTER_DATA (node), 0, 1, "", NULL);
- g_free (inner_html);
+ node = webkit_dom_node_get_first_child (node);
+ if (node) {
+ inner_html = webkit_dom_node_get_text_content (node);
+ if (g_str_has_prefix (inner_html, UNICODE_NBSP))
+ webkit_dom_character_data_replace_data (
+ WEBKIT_DOM_CHARACTER_DATA (node), 0, 1, "", NULL);
+ g_free (inner_html);
+ }
}
selection_marker = webkit_dom_document_get_element_by_id (
@@ -4454,25 +4456,53 @@ html_editor_view_insert_converted_html_into_selection (EHTMLEditorView *view,
WEBKIT_DOM_NODE (selection_marker))),
NULL);
node = parent;
- } else
+ } else {
node = webkit_dom_node_get_next_sibling (parent);
+ if (!node) {
+ WebKitDOMNode *first_child, *tmp;
+
+ /* When pasting content that does not contain just the
+ * one line text WebKit inserts all the content after the
+ * first line into one element. So we have to take it out
+ * of this element and insert it after that element. */
+ tmp = webkit_dom_node_get_parent_node (parent);
+ first_child = webkit_dom_node_get_first_child (tmp);
+ while (first_child) {
+ WebKitDOMNode *next_child =
+ webkit_dom_node_get_next_sibling (first_child);
+ if (webkit_dom_node_has_child_nodes (first_child))
+ webkit_dom_node_insert_before (
+ webkit_dom_node_get_parent_node (tmp),
+ first_child,
+ tmp,
+ NULL);
+ first_child = next_child;
+ }
+ remove_node (tmp);
+ }
+ }
- /* Restore caret on the end of pasted text */
- webkit_dom_node_insert_before (
- node,
- WEBKIT_DOM_NODE (selection_marker),
- webkit_dom_node_get_first_child (node),
- NULL);
+ if (node) {
+ /* Restore caret on the end of pasted text */
+ webkit_dom_node_insert_before (
+ node,
+ WEBKIT_DOM_NODE (selection_marker),
+ webkit_dom_node_get_first_child (node),
+ NULL);
- selection_marker = webkit_dom_document_get_element_by_id (
- document, "-x-evo-selection-start-marker");
- webkit_dom_node_insert_before (
- node,
- WEBKIT_DOM_NODE (selection_marker),
- webkit_dom_node_get_first_child (node),
- NULL);
+ selection_marker = webkit_dom_document_get_element_by_id (
+ document, "-x-evo-selection-start-marker");
+ webkit_dom_node_insert_before (
+ node,
+ WEBKIT_DOM_NODE (selection_marker),
+ webkit_dom_node_get_first_child (node),
+ NULL);
+ }
+
+ if (element)
+ webkit_dom_element_remove_attribute (element, "class");
- if (!has_selection)
+ if (webkit_dom_node_get_next_sibling (WEBKIT_DOM_NODE (parent)) && !has_selection)
remove_node (parent);
} else {
/* When pasting the content that was copied from the composer, WebKit