[evolution/wip/webkit2] EHTMLEditorView - New line from the beginning of pasted text lost when pasting
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution/wip/webkit2] EHTMLEditorView - New line from the beginning of pasted text lost when pasting
- Date: Thu, 25 Feb 2016 09:53:29 +0000 (UTC)
commit 7c9edb225cacfa9809fb24b86cc2ec51c9948262
Author: Tomas Popela <tpopela redhat com>
Date: Thu Feb 25 10:53:30 2016 +0100
EHTMLEditorView - New line from the beginning of pasted text lost when pasting
.../composer/e-html-editor-view-dom-functions.c | 42 +++++++++++++------
1 files changed, 29 insertions(+), 13 deletions(-)
---
diff --git a/web-extensions/composer/e-html-editor-view-dom-functions.c
b/web-extensions/composer/e-html-editor-view-dom-functions.c
index af7bd76..f1403a2 100644
--- a/web-extensions/composer/e-html-editor-view-dom-functions.c
+++ b/web-extensions/composer/e-html-editor-view-dom-functions.c
@@ -3951,6 +3951,13 @@ parse_html_into_paragraphs (WebKitDOMDocument *document,
"<br class=\"-x-evo-first-br\">");
} else
preserve_next_line = FALSE;
+ } else if (first_element) {
+ paragraph = create_and_append_new_paragraph (
+ document,
+ extension,
+ blockquote,
+ block,
+ "<br class=\"-x-evo-first-br\">");
} else
preserve_next_line = FALSE;
next:
@@ -3978,9 +3985,12 @@ parse_html_into_paragraphs (WebKitDOMDocument *document,
if (child) {
child = webkit_dom_node_get_first_child (child);
if (child && WEBKIT_DOM_IS_HTML_BR_ELEMENT (child)) {
- element_add_class (
- WEBKIT_DOM_ELEMENT (child),
- "-x-evo-last-br");
+ /* If the processed HTML contained just
+ * the BR don't overwrite its class. */
+ if (!element_has_class (WEBKIT_DOM_ELEMENT (child),
"-x-evo-first-br"))
+ element_add_class (
+ WEBKIT_DOM_ELEMENT (child),
+ "-x-evo-last-br");
} else if (!e_html_editor_web_extension_is_editting_message (extension))
create_and_append_new_paragraph (
document, extension, blockquote, block, "<br>");
@@ -4920,14 +4930,14 @@ dom_convert_and_insert_html_into_selection (WebKitDOMDocument *document,
element = webkit_dom_document_query_selector (
document, "* > br.-x-evo-first-br", NULL);
if (element) {
- WebKitDOMNode *next_sibling;
+ WebKitDOMNode *sibling;
WebKitDOMNode *parent;
parent = webkit_dom_node_get_parent_node (
WEBKIT_DOM_NODE (element));
- next_sibling = webkit_dom_node_get_next_sibling (parent);
- if (next_sibling)
+ sibling = webkit_dom_node_get_previous_sibling (parent);
+ if (sibling)
remove_node (WEBKIT_DOM_NODE (parent));
else
webkit_dom_element_remove_attribute (element, "class");
@@ -5035,14 +5045,20 @@ dom_convert_and_insert_html_into_selection (WebKitDOMDocument *document,
clone2 = webkit_dom_node_clone_node (WEBKIT_DOM_NODE (parent), FALSE);
if (webkit_dom_node_is_equal_node (clone1, clone2)) {
fix_structure_after_pasting_multiline_content (paragraph);
- if (*html != '\n')
- remove_node (parent);
+ if (g_strcmp0 (html, "\n") == 0) {
+ WebKitDOMElement *br;
- webkit_dom_node_insert_before (
- parent,
- WEBKIT_DOM_NODE (selection_start_marker),
- webkit_dom_node_get_last_child (parent),
- NULL);
+ br = webkit_dom_document_create_element (document, "br", NULL);
+ webkit_dom_node_append_child (
+ parent, WEBKIT_DOM_NODE (br), NULL);
+
+ webkit_dom_node_insert_before (
+ parent,
+ WEBKIT_DOM_NODE (selection_start_marker),
+ webkit_dom_node_get_last_child (parent),
+ NULL);
+ } else
+ remove_node (parent);
}
webkit_dom_node_insert_before (
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]