aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTomas Popela <tpopela@redhat.com>2014-08-01 16:16:38 +0800
committerTomas Popela <tpopela@redhat.com>2014-08-01 16:21:59 +0800
commitcb7ca5d0f46981302fb2ab1b9d75c233c7cd2b6a (patch)
tree4dedefcb131a47b8fbf5ec9cba253841c3fdce7f
parenta38c09b58fdd10f4b38abf874fbfd73fd10bbadc (diff)
downloadgsoc2013-evolution-cb7ca5d0f46981302fb2ab1b9d75c233c7cd2b6a.tar
gsoc2013-evolution-cb7ca5d0f46981302fb2ab1b9d75c233c7cd2b6a.tar.gz
gsoc2013-evolution-cb7ca5d0f46981302fb2ab1b9d75c233c7cd2b6a.tar.bz2
gsoc2013-evolution-cb7ca5d0f46981302fb2ab1b9d75c233c7cd2b6a.tar.lz
gsoc2013-evolution-cb7ca5d0f46981302fb2ab1b9d75c233c7cd2b6a.tar.xz
gsoc2013-evolution-cb7ca5d0f46981302fb2ab1b9d75c233c7cd2b6a.tar.zst
gsoc2013-evolution-cb7ca5d0f46981302fb2ab1b9d75c233c7cd2b6a.zip
EHTMLEditorView - Fix the HTML structure after pasting the multiline content that was copied from composer
-rw-r--r--e-util/e-html-editor-view.c58
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 5e20758ce6..34d59ad483 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)),