[evolution] EHTMLEditor - Rework how the message text, signature and block with initial input are handled when o
- From: Tomas Popela <tpopela src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution] EHTMLEditor - Rework how the message text, signature and block with initial input are handled when o
- Date: Thu, 16 Oct 2014 06:29:25 +0000 (UTC)
commit 67ee9be5d2a6f01d3ae3fd58024762103a094271
Author: Tomas Popela <tpopela redhat com>
Date: Wed Oct 15 14:49:45 2014 +0200
EHTMLEditor - Rework how the message text, signature and block with initial input are handled when
opening composer
composer/e-composer-private.c | 231 +++++++++++------------------
e-util/e-html-editor-view.c | 325 +++++++++++++++++-----------------------
2 files changed, 227 insertions(+), 329 deletions(-)
---
diff --git a/composer/e-composer-private.c b/composer/e-composer-private.c
index 05d3cc9..5719675 100644
--- a/composer/e-composer-private.c
+++ b/composer/e-composer-private.c
@@ -796,24 +796,19 @@ composer_size_allocate_cb (GtkWidget *widget,
}
}
-static void
-insert_paragraph_with_input (WebKitDOMElement *paragraph,
- WebKitDOMElement *body)
+static WebKitDOMElement *
+prepare_paragraph (EHTMLEditorSelection *selection,
+ WebKitDOMDocument *document)
{
- WebKitDOMNode *node = webkit_dom_node_get_first_child (WEBKIT_DOM_NODE (body));
+ WebKitDOMElement *br, *paragraph;
- if (node) {
- webkit_dom_node_insert_before (
- WEBKIT_DOM_NODE (body),
- WEBKIT_DOM_NODE (paragraph),
- node,
- NULL);
- } else {
- webkit_dom_node_append_child (
- WEBKIT_DOM_NODE (body),
- WEBKIT_DOM_NODE (paragraph),
- NULL);
- }
+ paragraph = e_html_editor_selection_get_paragraph_element (
+ selection, document, -1, 0);
+ br = webkit_dom_document_create_element (document, "BR", NULL);
+ webkit_dom_node_append_child (
+ WEBKIT_DOM_NODE (paragraph), WEBKIT_DOM_NODE (br), NULL);
+
+ return paragraph;
}
static void
@@ -823,14 +818,14 @@ composer_move_caret (EMsgComposer *composer)
EHTMLEditorView *view;
EHTMLEditorSelection *editor_selection;
GSettings *settings;
- gboolean start_bottom, html_mode, top_signature, is_from_draft;
+ gboolean start_bottom, top_signature, is_from_draft;
gboolean has_paragraphs_in_body = TRUE;
WebKitDOMDocument *document;
WebKitDOMDOMWindow *window;
WebKitDOMDOMSelection *dom_selection;
- WebKitDOMElement *input_start, *element, *signature;
+ WebKitDOMElement *element, *signature;
WebKitDOMHTMLElement *body;
- WebKitDOMNodeList *list, *blockquotes;
+ WebKitDOMNodeList *list;
WebKitDOMRange *new_range;
/* When there is an option composer-reply-start-bottom set we have
@@ -847,7 +842,6 @@ composer_move_caret (EMsgComposer *composer)
editor = e_msg_composer_get_editor (composer);
view = e_html_editor_get_view (editor);
editor_selection = e_html_editor_view_get_selection (view);
- html_mode = e_html_editor_view_get_html_mode (view);
is_from_draft = e_html_editor_view_is_message_from_draft (view);
document = webkit_web_view_get_dom_document (WEBKIT_WEB_VIEW (view));
@@ -875,120 +869,92 @@ composer_move_caret (EMsgComposer *composer)
e_html_editor_selection_block_selection_changed (editor_selection);
/* When the new message is written from the beginning - note it into body */
- if (composer->priv->is_from_new_message) {
+ if (composer->priv->is_from_new_message)
webkit_dom_element_set_attribute (
WEBKIT_DOM_ELEMENT (body), "data-new-message", "", NULL);
- }
list = webkit_dom_document_get_elements_by_class_name (document, "-x-evo-paragraph");
- signature = webkit_dom_document_query_selector (document, ".-x-evo-signature", NULL);
+ signature = webkit_dom_document_query_selector (document, ".-x-evo-signature-wrapper", NULL);
/* Situation when wrapped paragraph is just in signature and not in message body */
- if (webkit_dom_node_list_get_length (list) == 1) {
+ if (webkit_dom_node_list_get_length (list) == 1)
if (signature && webkit_dom_element_query_selector (signature, ".-x-evo-paragraph", NULL))
has_paragraphs_in_body = FALSE;
+
+ if (signature && top_signature) {
+ element_add_class (signature, "-x-evo-top-signature");
+ element = prepare_paragraph (editor_selection, document);
+ webkit_dom_node_insert_before (
+ WEBKIT_DOM_NODE (body),
+ WEBKIT_DOM_NODE (element),
+ webkit_dom_node_get_next_sibling (WEBKIT_DOM_NODE (signature)),
+ NULL);
}
if (webkit_dom_node_list_get_length (list) == 0)
has_paragraphs_in_body = FALSE;
- blockquotes = webkit_dom_document_get_elements_by_tag_name (document, "blockquote");
-
if (!has_paragraphs_in_body) {
- element = e_html_editor_selection_get_paragraph_element (
- editor_selection, document, -1, 0);
- webkit_dom_element_set_id (element, "-x-evo-input-start");
- webkit_dom_html_element_set_inner_html (
- WEBKIT_DOM_HTML_ELEMENT (element), UNICODE_ZERO_WIDTH_SPACE, NULL);
- if (top_signature)
- element_add_class (element, "-x-evo-top-signature");
- }
-
- if (start_bottom) {
- if (webkit_dom_node_list_get_length (blockquotes) != 0) {
- if (!has_paragraphs_in_body) {
- if (!top_signature) {
- webkit_dom_node_insert_before (
- WEBKIT_DOM_NODE (body),
- WEBKIT_DOM_NODE (element),
- signature ?
- webkit_dom_node_get_parent_node (
- WEBKIT_DOM_NODE (signature)) :
- webkit_dom_node_get_next_sibling (
- webkit_dom_node_list_item (
- blockquotes, 0)),
- NULL);
- } else {
- webkit_dom_node_append_child (
- WEBKIT_DOM_NODE (body),
- WEBKIT_DOM_NODE (element),
- NULL);
- }
+ element = prepare_paragraph (editor_selection, document);
+ if (top_signature) {
+ if (start_bottom) {
+ webkit_dom_node_append_child (
+ WEBKIT_DOM_NODE (body),
+ WEBKIT_DOM_NODE (element),
+ NULL);
+ } else {
+ webkit_dom_node_insert_before (
+ WEBKIT_DOM_NODE (body),
+ WEBKIT_DOM_NODE (element),
+ webkit_dom_node_get_first_child (WEBKIT_DOM_NODE (body)),
+ NULL);
}
-
- e_html_editor_selection_restore_caret_position (editor_selection);
- if (!html_mode)
- e_html_editor_view_quote_plain_text (view);
-
- input_start = webkit_dom_document_get_element_by_id (
- document, "-x-evo-input-start");
- if (input_start)
- webkit_dom_range_select_node_contents (
- new_range, WEBKIT_DOM_NODE (input_start), NULL);
-
- webkit_dom_range_collapse (new_range, FALSE, NULL);
} else {
- if (!has_paragraphs_in_body)
- insert_paragraph_with_input (
- element, WEBKIT_DOM_ELEMENT (body));
-
- webkit_dom_range_select_node_contents (
- new_range,
- webkit_dom_node_get_first_child (
- WEBKIT_DOM_NODE (body)),
- NULL);
- webkit_dom_range_collapse (new_range, TRUE, NULL);
+ if (start_bottom) {
+ webkit_dom_node_insert_before (
+ WEBKIT_DOM_NODE (body),
+ WEBKIT_DOM_NODE (element),
+ WEBKIT_DOM_NODE (signature),
+ NULL);
+ } else {
+ webkit_dom_node_insert_before (
+ WEBKIT_DOM_NODE (body),
+ WEBKIT_DOM_NODE (element),
+ webkit_dom_node_get_first_child (WEBKIT_DOM_NODE (body)),
+ NULL);
+ }
}
-
- g_signal_connect (
- view, "size-allocate",
- G_CALLBACK (composer_size_allocate_cb), NULL);
} else {
- /* Move caret on the beginning of message */
- if (!has_paragraphs_in_body) {
- insert_paragraph_with_input (
- element, WEBKIT_DOM_ELEMENT (body));
-
- if (webkit_dom_node_list_get_length (blockquotes) != 0) {
- if (!html_mode) {
- WebKitDOMNode *blockquote;
-
- blockquote = webkit_dom_node_list_item (blockquotes, 0);
-
- /* FIXME determine when we can skip this */
- e_html_editor_selection_wrap_paragraph (
- editor_selection,
- WEBKIT_DOM_ELEMENT (blockquote));
-
- e_html_editor_selection_restore_caret_position (editor_selection);
- e_html_editor_view_quote_plain_text (view);
- body = webkit_dom_document_get_body (document);
- }
+ element = webkit_dom_document_get_element_by_id (document, "-x-evo-input-start");
+ if (!element && top_signature) {
+ element = prepare_paragraph (editor_selection, document);
+ if (start_bottom) {
+ webkit_dom_node_append_child (
+ WEBKIT_DOM_NODE (body),
+ WEBKIT_DOM_NODE (element),
+ NULL);
+ } else {
+ webkit_dom_node_insert_before (
+ WEBKIT_DOM_NODE (body),
+ WEBKIT_DOM_NODE (element),
+ WEBKIT_DOM_NODE (signature),
+ NULL);
}
}
-
- webkit_dom_range_select_node_contents (
- new_range,
- WEBKIT_DOM_NODE (
- webkit_dom_node_get_first_child (WEBKIT_DOM_NODE (body))),
- NULL);
- webkit_dom_range_collapse (new_range, TRUE, NULL);
}
+ webkit_dom_range_select_node_contents (
+ new_range, WEBKIT_DOM_NODE (element), NULL);
+ webkit_dom_range_collapse (new_range, TRUE, NULL);
+
+ if (start_bottom)
+ g_signal_connect (
+ view, "size-allocate",
+ G_CALLBACK (composer_size_allocate_cb), NULL);
+
webkit_dom_dom_selection_remove_all_ranges (dom_selection);
webkit_dom_dom_selection_add_range (dom_selection, new_range);
g_object_unref (list);
- g_object_unref (blockquotes);
e_html_editor_view_force_spell_check (view);
@@ -1108,43 +1074,33 @@ insert:
document = webkit_web_view_get_dom_document (WEBKIT_WEB_VIEW (view));
signatures = webkit_dom_document_get_elements_by_class_name (
- document, "-x-evo-signature");
+ document, "-x-evo-signature-wrapper");
list_length = webkit_dom_node_list_get_length (signatures);
for (ii = 0; ii < list_length; ii++) {
- WebKitDOMNode *node;
+ WebKitDOMNode *wrapper, *signature;
gchar *id;
- node = webkit_dom_node_list_item (signatures, ii);
- id = webkit_dom_element_get_id (WEBKIT_DOM_ELEMENT (node));
+ wrapper = webkit_dom_node_list_item (signatures, ii);
+ signature = webkit_dom_node_get_first_child (wrapper);
+ id = webkit_dom_element_get_id (WEBKIT_DOM_ELEMENT (signature));
/* When we are editing a message with signature we need to set active
* signature id in signature combo box otherwise no signature will be
* added but we have to do it just once when the composer opens */
if (composer->priv->is_from_message && composer->priv->set_signature_from_message) {
- gchar *name = webkit_dom_element_get_attribute (WEBKIT_DOM_ELEMENT (node), "name");
+ gchar *name = webkit_dom_element_get_attribute (WEBKIT_DOM_ELEMENT (signature),
"name");
gtk_combo_box_set_active_id (GTK_COMBO_BOX (combo_box), name);
g_free (name);
composer->priv->set_signature_from_message = FALSE;
}
if (id && (strlen (id) == 1) && (*id == '1')) {
+ /* If the top signature was set we have to remove the NL
+ * that was inserted after it */
+ if (top_signature)
+ remove_node (webkit_dom_node_get_next_sibling (wrapper));
/* We have to remove the div containing the span with signature */
- WebKitDOMNode *next_sibling;
- WebKitDOMNode *parent;
-
- parent = webkit_dom_node_get_parent_node (node);
- next_sibling = webkit_dom_node_get_next_sibling (parent);
-
- if (WEBKIT_DOM_IS_HTMLBR_ELEMENT (next_sibling))
- webkit_dom_node_remove_child (
- webkit_dom_node_get_parent_node (next_sibling),
- next_sibling,
- NULL);
-
- webkit_dom_node_remove_child (
- webkit_dom_node_get_parent_node (parent),
- parent,
- NULL);
+ remove_node (wrapper);
g_free (id);
break;
@@ -1152,6 +1108,7 @@ insert:
g_free (id);
}
+ g_object_unref (signatures);
if (html_buffer != NULL) {
if (*html_buffer->str) {
@@ -1166,15 +1123,11 @@ insert:
WEBKIT_DOM_HTML_ELEMENT (element), html_buffer->str, NULL);
if (top_signature) {
- WebKitDOMNode *signature_inserted;
WebKitDOMNode *child =
webkit_dom_node_get_first_child (WEBKIT_DOM_NODE (body));
- WebKitDOMElement *br =
- webkit_dom_document_create_element (
- document, "br", NULL);
if (start_bottom) {
- signature_inserted = webkit_dom_node_insert_before (
+ webkit_dom_node_insert_before (
WEBKIT_DOM_NODE (body),
WEBKIT_DOM_NODE (element),
child,
@@ -1185,7 +1138,7 @@ insert:
document, "-x-evo-input-start");
/* When we are using signature on top the caret
* should be before the signature */
- signature_inserted = webkit_dom_node_insert_before (
+ webkit_dom_node_insert_before (
WEBKIT_DOM_NODE (body),
WEBKIT_DOM_NODE (element),
input_start ?
@@ -1194,12 +1147,6 @@ insert:
child,
NULL);
}
-
- webkit_dom_node_insert_before (
- WEBKIT_DOM_NODE (body),
- WEBKIT_DOM_NODE (br),
- webkit_dom_node_get_next_sibling (signature_inserted),
- NULL);
} else {
webkit_dom_node_append_child (
WEBKIT_DOM_NODE (body),
diff --git a/e-util/e-html-editor-view.c b/e-util/e-html-editor-view.c
index 0d22ae0..68f7a96 100644
--- a/e-util/e-html-editor-view.c
+++ b/e-util/e-html-editor-view.c
@@ -4211,17 +4211,52 @@ create_text_markers_for_citations_in_element (WebKitDOMElement *element)
return count;
}
+static WebKitDOMElement *
+prepare_paragraph (EHTMLEditorSelection *selection,
+ WebKitDOMDocument *document,
+ gboolean with_selection)
+{
+ WebKitDOMElement *element, *paragraph;
+
+ paragraph = e_html_editor_selection_get_paragraph_element (
+ selection, document, -1, 0);
+ webkit_dom_element_set_id (paragraph, "-x-evo-input-start");
+
+ if (with_selection) {
+ element = webkit_dom_document_create_element (
+ document, "SPAN", NULL);
+ webkit_dom_element_set_id (
+ element, "-x-evo-selection-start-marker");
+ webkit_dom_node_append_child (
+ WEBKIT_DOM_NODE (paragraph), WEBKIT_DOM_NODE (element), NULL);
+
+ element = webkit_dom_document_create_element (
+ document, "SPAN", NULL);
+ webkit_dom_element_set_id (
+ element, "-x-evo-selection-end-marker");
+ webkit_dom_node_append_child (
+ WEBKIT_DOM_NODE (paragraph), WEBKIT_DOM_NODE (element), NULL);
+ }
+
+ element = webkit_dom_document_create_element (document, "BR", NULL);
+
+ webkit_dom_node_append_child (
+ WEBKIT_DOM_NODE (paragraph), WEBKIT_DOM_NODE (element), NULL);
+
+ return paragraph;
+}
+
static void
html_editor_view_process_document_from_convertor (EHTMLEditorView *view,
WebKitDOMDocument *document_convertor)
{
EHTMLEditorSelection *selection = e_html_editor_view_get_selection (view);
- gboolean start_bottom;
+ gboolean start_bottom, empty;
gchar *inner_text, *inner_html;
- gint ii;
+ gint ii, length;
GSettings *settings;
WebKitDOMDocument *document;
- WebKitDOMElement *paragraph, *new_blockquote, *top_signature;
+ WebKitDOMElement *paragraph, *wrapper, *top_signature;
WebKitDOMElement *cite_body, *signature;
WebKitDOMHTMLElement *body, *body_convertor;
WebKitDOMNodeList *list;
@@ -4237,35 +4272,84 @@ html_editor_view_process_document_from_convertor (EHTMLEditorView *view,
webkit_dom_element_set_attribute (
WEBKIT_DOM_ELEMENT (body), "data-converted", "", NULL);
- paragraph = webkit_dom_document_get_element_by_id (document, "-x-evo-input-start");
- if (!paragraph) {
- paragraph = e_html_editor_selection_get_paragraph_element (
- selection, document, -1, 0);
- webkit_dom_element_set_id (paragraph, "-x-evo-input-start");
- webkit_dom_html_element_set_inner_text (
- WEBKIT_DOM_HTML_ELEMENT (paragraph), UNICODE_ZERO_WIDTH_SPACE, NULL);
- webkit_dom_node_append_child (
- WEBKIT_DOM_NODE (webkit_dom_document_get_body (document)),
- WEBKIT_DOM_NODE (paragraph),
- NULL);
+ cite_body = webkit_dom_document_query_selector (
+ document_convertor, "span.-x-evo-cite-body", NULL);
+
+ /* Wrapper when the processed text will be placed. */
+ wrapper = webkit_dom_document_create_element (
+ document, cite_body ? "blockquote" : "div", NULL);
+ if (cite_body) {
+ webkit_dom_element_set_attribute (wrapper, "type", "cite", NULL);
+ webkit_dom_element_set_attribute (wrapper, "id", "-x-evo-main-cite", NULL);
}
+ webkit_dom_node_append_child (
+ WEBKIT_DOM_NODE (body), WEBKIT_DOM_NODE (wrapper), NULL);
+
+ /* Remove all previously inserted paragraphs. */
+ list = webkit_dom_document_query_selector_all (
+ document, ".-x-evo-paragraph", NULL);
+ length = webkit_dom_node_list_get_length (list);
+ for (ii = 0; ii < length; ii++)
+ remove_node (webkit_dom_node_list_item (list, ii));
+ g_object_unref (list);
+
+ /* Insert the paragraph where the caret will be. */
+ paragraph = prepare_paragraph (selection, document, TRUE);
+ webkit_dom_node_insert_before (
+ WEBKIT_DOM_NODE (body),
+ WEBKIT_DOM_NODE (paragraph),
+ start_bottom ?
+ webkit_dom_node_get_next_sibling (WEBKIT_DOM_NODE (wrapper)) :
+ WEBKIT_DOM_NODE (wrapper),
+ NULL);
+
+ /* Insert signature (if presented) to the right position. */
+ top_signature = webkit_dom_document_query_selector (
+ document, ".-x-evo-top-signature", NULL);
+ signature = webkit_dom_document_query_selector (
+ document, ".-x-evo-signature-wrapper", NULL);
+ if (signature) {
+ if (top_signature) {
+ webkit_dom_node_insert_before (
+ WEBKIT_DOM_NODE (body),
+ WEBKIT_DOM_NODE (signature),
+ start_bottom ?
+ WEBKIT_DOM_NODE (wrapper) :
+ webkit_dom_node_get_next_sibling (
+ WEBKIT_DOM_NODE (paragraph)),
+ NULL);
+ /* Insert NL after the signature */
+ webkit_dom_node_insert_before (
+ WEBKIT_DOM_NODE (body),
+ WEBKIT_DOM_NODE (prepare_paragraph (
+ selection, document, FALSE)),
+ webkit_dom_node_get_next_sibling (
+ WEBKIT_DOM_NODE (signature)),
+ NULL);
+ } else {
+ webkit_dom_node_insert_before (
+ WEBKIT_DOM_NODE (body),
+ WEBKIT_DOM_NODE (signature),
+ webkit_dom_node_get_next_sibling (WEBKIT_DOM_NODE (
+ start_bottom ? paragraph : wrapper)),
+ NULL);
+ }
+ }
+
+ /* Move elements to body */
list = webkit_dom_document_query_selector_all (
document_convertor, "span.-x-evo-to-body", NULL);
for (ii = webkit_dom_node_list_get_length (list) - 1; ii >= 0; ii--) {
- WebKitDOMNode *node;
+ WebKitDOMNode *node, *child;
node = webkit_dom_node_list_item (list, ii);
- while (webkit_dom_node_has_child_nodes (node)) {
+ while ((child = webkit_dom_node_get_first_child (node))) {
webkit_dom_node_insert_before (
WEBKIT_DOM_NODE (body),
- webkit_dom_node_clone_node (
- webkit_dom_node_get_first_child (node), TRUE),
- webkit_dom_node_get_next_sibling (
- WEBKIT_DOM_NODE (paragraph)),
+ child,
+ WEBKIT_DOM_NODE (wrapper),
NULL);
-
- remove_node (webkit_dom_node_get_first_child (node));
}
remove_node (node);
@@ -4273,181 +4357,37 @@ html_editor_view_process_document_from_convertor (EHTMLEditorView *view,
g_object_unref (list);
repair_gmail_blockquotes (document_convertor);
-
create_text_markers_for_citations_in_document (document_convertor);
/* Get innertText from convertor */
inner_text = webkit_dom_html_element_get_inner_text (body_convertor);
-
- cite_body = webkit_dom_document_query_selector (
- document_convertor, "span.-x-evo-cite-body", NULL);
-
- top_signature = webkit_dom_document_query_selector (
- document, ".-x-evo-top-signature", NULL);
- signature = webkit_dom_document_query_selector (
- document, "span.-x-evo-signature", NULL);
-
- if (cite_body) {
- if (!(top_signature && start_bottom))
- e_html_editor_selection_save_caret_position (selection);
- } else {
- webkit_dom_node_append_child (
- WEBKIT_DOM_NODE (paragraph),
- WEBKIT_DOM_NODE (
- e_html_editor_selection_get_caret_position_node (
- document)),
- NULL);
- }
-
- new_blockquote = webkit_dom_document_create_element (
- document, "blockquote", NULL);
- webkit_dom_element_set_attribute (
- new_blockquote, "type", "cite", NULL);
-
webkit_dom_html_element_set_inner_text (
- WEBKIT_DOM_HTML_ELEMENT (new_blockquote), inner_text, NULL);
+ WEBKIT_DOM_HTML_ELEMENT (wrapper), inner_text, NULL);
inner_html = webkit_dom_html_element_get_inner_html (
- WEBKIT_DOM_HTML_ELEMENT (new_blockquote));
-
- if (cite_body) {
- webkit_dom_element_set_attribute (
- new_blockquote, "id", "-x-evo-main-cite", NULL);
+ WEBKIT_DOM_HTML_ELEMENT (wrapper));
- parse_html_into_paragraphs (
- view, document, new_blockquote, inner_html, FALSE);
-
- if (start_bottom) {
- if (signature) {
- WebKitDOMNode *parent =
- webkit_dom_node_get_parent_node (
- WEBKIT_DOM_NODE (signature));
- if (top_signature) {
- webkit_dom_node_append_child (
- WEBKIT_DOM_NODE (body),
- WEBKIT_DOM_NODE (new_blockquote),
- NULL);
- webkit_dom_node_append_child (
- WEBKIT_DOM_NODE (body),
- WEBKIT_DOM_NODE (paragraph),
- NULL);
- webkit_dom_node_append_child (
- WEBKIT_DOM_NODE (paragraph),
- e_html_editor_selection_get_caret_position_node (
- document),
- NULL);
- } else {
- webkit_dom_node_insert_before (
- WEBKIT_DOM_NODE (body),
- WEBKIT_DOM_NODE (new_blockquote),
- WEBKIT_DOM_NODE (parent),
- NULL);
- webkit_dom_node_insert_before (
- WEBKIT_DOM_NODE (body),
- WEBKIT_DOM_NODE (paragraph),
- webkit_dom_node_get_next_sibling (
- WEBKIT_DOM_NODE (new_blockquote)),
- NULL);
- }
- } else {
- webkit_dom_node_append_child (
- WEBKIT_DOM_NODE (body),
- WEBKIT_DOM_NODE (new_blockquote),
- NULL);
- webkit_dom_node_insert_before (
- WEBKIT_DOM_NODE (body),
- WEBKIT_DOM_NODE (paragraph),
- webkit_dom_node_get_next_sibling (
- WEBKIT_DOM_NODE (new_blockquote)),
- NULL);
- }
- } else {
- if (signature) {
- WebKitDOMNode *parent =
- webkit_dom_node_get_parent_node (
- WEBKIT_DOM_NODE (signature));
+ empty = (webkit_dom_element_get_child_element_count (
+ WEBKIT_DOM_ELEMENT (body_convertor)) == 1);
+ empty &= WEBKIT_DOM_IS_HTMLBR_ELEMENT (
+ webkit_dom_node_get_first_child (WEBKIT_DOM_NODE (body_convertor)));
- if (top_signature) {
- WebKitDOMElement *br;
+ if (!empty)
+ parse_html_into_paragraphs (view, document, wrapper, inner_html, FALSE);
- br = webkit_dom_document_create_element (
- document, "BR", NULL);
+ if (!cite_body) {
+ if (!empty) {
+ WebKitDOMNode *child;
- webkit_dom_node_append_child (
- WEBKIT_DOM_NODE (body),
- WEBKIT_DOM_NODE (new_blockquote),
- NULL);
- /* Insert NL after signature */
- webkit_dom_node_insert_before (
- WEBKIT_DOM_NODE (body),
- WEBKIT_DOM_NODE (br),
- webkit_dom_node_get_next_sibling (
- WEBKIT_DOM_NODE (paragraph)),
- NULL);
- webkit_dom_node_insert_before (
- WEBKIT_DOM_NODE (body),
- WEBKIT_DOM_NODE (parent),
- WEBKIT_DOM_NODE (br),
- NULL);
- } else
- webkit_dom_node_insert_before (
- WEBKIT_DOM_NODE (body),
- WEBKIT_DOM_NODE (new_blockquote),
- WEBKIT_DOM_NODE (parent),
- NULL);
- } else {
- webkit_dom_node_append_child (
- WEBKIT_DOM_NODE (body),
- WEBKIT_DOM_NODE (new_blockquote),
- NULL);
- }
- }
- } else {
- WebKitDOMNode *signature_clone, *first_child;
-
- if (signature) {
- signature_clone = webkit_dom_node_clone_node (
- webkit_dom_node_get_parent_node (
- WEBKIT_DOM_NODE (signature)),
- TRUE);
- }
-
- parse_html_into_paragraphs (
- view, document, WEBKIT_DOM_ELEMENT (body),
- inner_html, FALSE);
-
- if (signature) {
- if (!top_signature) {
- signature_clone = webkit_dom_node_append_child (
- WEBKIT_DOM_NODE (body),
- signature_clone,
- NULL);
- } else {
+ while ((child = webkit_dom_node_get_first_child (WEBKIT_DOM_NODE (wrapper)))) {
webkit_dom_node_insert_before (
- WEBKIT_DOM_NODE (body),
- signature_clone,
- webkit_dom_node_get_first_child (
- WEBKIT_DOM_NODE (body)),
+ webkit_dom_node_get_parent_node (WEBKIT_DOM_NODE (wrapper)),
+ child,
+ WEBKIT_DOM_NODE (wrapper),
NULL);
}
}
- first_child = webkit_dom_node_get_first_child (
- WEBKIT_DOM_NODE (body));
- if (!first_child) {
- paragraph = e_html_editor_selection_get_paragraph_element (
- selection, document, -1, 0);
- first_child = webkit_dom_node_append_child (
- WEBKIT_DOM_NODE (body),
- WEBKIT_DOM_NODE (paragraph),
- NULL);
- }
-
- webkit_dom_node_insert_before (
- first_child,
- e_html_editor_selection_get_caret_position_node (
- document),
- webkit_dom_node_get_first_child (first_child),
- NULL);
+ remove_node (WEBKIT_DOM_NODE (wrapper));
}
paragraph = webkit_dom_document_query_selector (document, "br.-x-evo-last-br", NULL);
@@ -4457,14 +4397,25 @@ html_editor_view_process_document_from_convertor (EHTMLEditorView *view,
if (paragraph)
webkit_dom_element_remove_attribute (paragraph, "class");
- if (!e_html_editor_view_get_html_mode (view))
+ if (!e_html_editor_view_get_html_mode (view)) {
e_html_editor_selection_wrap_paragraphs_in_document (
selection, document);
- if (webkit_dom_document_query_selector (document, "blockquote[type=cite]", NULL))
- body = WEBKIT_DOM_HTML_ELEMENT (
- e_html_editor_view_quote_plain_text (view));
- e_html_editor_selection_restore_caret_position (selection);
+ list = webkit_dom_document_query_selector_all (
+ document, "body > blockquote[type=cite]", NULL);
+
+ length = webkit_dom_node_list_get_length (list);
+
+ for (ii = 0; ii < length; ii++) {
+ e_html_editor_view_quote_plain_text_element (
+ view,
+ WEBKIT_DOM_ELEMENT (
+ webkit_dom_node_list_item (list, ii)));
+ }
+ g_object_unref (list);
+ }
+
+ e_html_editor_selection_restore (selection);
e_html_editor_view_force_spell_check (view);
/* Register on input event that is called when the content (body) is modified */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]