[evolution] EHTMLEditorView - Fix the HTML structure after pasting the multiline content that was copied from co
- From: Tomas Popela <tpopela src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution] EHTMLEditorView - Fix the HTML structure after pasting the multiline content that was copied from co
- Date: Fri, 1 Aug 2014 08:22:15 +0000 (UTC)
commit cb7ca5d0f46981302fb2ab1b9d75c233c7cd2b6a
Author: Tomas Popela <tpopela redhat com>
Date: Fri Aug 1 10:16:38 2014 +0200
EHTMLEditorView - Fix the HTML structure after pasting the multiline content that was copied from composer
e-util/e-html-editor-view.c | 58 ++++++++++++++++++++++++++----------------
1 files changed, 36 insertions(+), 22 deletions(-)
---
diff --git a/e-util/e-html-editor-view.c b/e-util/e-html-editor-view.c
index 5e20758..34d59ad 100644
--- a/e-util/e-html-editor-view.c
+++ b/e-util/e-html-editor-view.c
@@ -4309,6 +4309,31 @@ html_editor_view_process_document_from_convertor (EHTMLEditorView *view,
}
static void
+fix_structure_after_pasting_multiline_content (WebKitDOMNode *node)
+{
+ WebKitDOMNode *first_child, *parent;
+
+ /* 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. */
+ parent = webkit_dom_node_get_parent_node (node);
+ first_child = webkit_dom_node_get_first_child (parent);
+ 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 (parent),
+ first_child,
+ parent,
+ NULL);
+ first_child = next_child;
+ }
+ remove_node (parent);
+}
+
+static void
html_editor_view_insert_converted_html_into_selection (EHTMLEditorView *view,
WebKitDOMDocument *document_convertor)
{
@@ -4586,28 +4611,8 @@ html_editor_view_insert_converted_html_into_selection (EHTMLEditorView *view,
node = parent;
} 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);
- }
+ if (!node)
+ fix_structure_after_pasting_multiline_content (parent);
}
if (node) {
@@ -4637,11 +4642,20 @@ html_editor_view_insert_converted_html_into_selection (EHTMLEditorView *view,
* restores the selection wrongly, thus is saved wrongly and we have
* to fix it */
WebKitDOMElement *selection_start_marker, *selection_end_marker;
+ WebKitDOMNode *paragraph, *parent;
selection_start_marker = webkit_dom_document_get_element_by_id (
document, "-x-evo-selection-start-marker");
selection_end_marker = webkit_dom_document_get_element_by_id (
document, "-x-evo-selection-end-marker");
+
+ paragraph = webkit_dom_node_get_parent_node (
+ WEBKIT_DOM_NODE (selection_start_marker));
+ parent = webkit_dom_node_get_parent_node (paragraph);
+ if (element_has_class (WEBKIT_DOM_ELEMENT (paragraph), "-x-evo-paragraph") &&
+ element_has_class (WEBKIT_DOM_ELEMENT (parent), "-x-evo-paragraph"))
+ fix_structure_after_pasting_multiline_content (paragraph);
+
webkit_dom_node_insert_before (
webkit_dom_node_get_parent_node (
WEBKIT_DOM_NODE (selection_start_marker)),
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]