[evolution] When changing the composer mode from HTML to Plain Text avoid reloading of the web view
- From: Tomas Popela <tpopela src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution] When changing the composer mode from HTML to Plain Text avoid reloading of the web view
- Date: Wed, 27 Aug 2014 14:12:18 +0000 (UTC)
commit 94ac03022048a12b6a43c970ab6a95eef865e7b6
Author: Tomas Popela <tpopela redhat com>
Date: Wed Aug 27 15:53:30 2014 +0200
When changing the composer mode from HTML to Plain Text avoid reloading of the web view
Also preserve the selection (if it is possible) when changing the mode.
composer/e-composer-private.c | 12 --------
e-util/e-html-editor-view.c | 63 ++++++++++++++++++++++------------------
2 files changed, 35 insertions(+), 40 deletions(-)
---
diff --git a/composer/e-composer-private.c b/composer/e-composer-private.c
index 569cc4d..79bba3d 100644
--- a/composer/e-composer-private.c
+++ b/composer/e-composer-private.c
@@ -859,18 +859,6 @@ composer_move_caret (EMsgComposer *composer)
WEBKIT_DOM_ELEMENT (body), "data-message", "", NULL);
new_range = webkit_dom_document_create_range (document);
- element = webkit_dom_document_get_element_by_id (document, "-x-evo-caret-position");
- /* Caret position found => composer mode changed */
- if (element) {
- e_html_editor_selection_restore_caret_position (editor_selection);
- /* We want to force spellcheck just in case that we switched to plain
- * text mode (when switching to html mode, the underlined words are
- * preserved */
- if (!html_mode)
- e_html_editor_view_force_spell_check (view);
- return;
- }
-
/* If editing message as new don't handle with caret */
if (composer->priv->is_from_message || composer->priv->is_from_draft) {
if (composer->priv->is_from_message)
diff --git a/e-util/e-html-editor-view.c b/e-util/e-html-editor-view.c
index d5fcdc9..90a75de 100644
--- a/e-util/e-html-editor-view.c
+++ b/e-util/e-html-editor-view.c
@@ -5846,33 +5846,35 @@ process_elements (EHTMLEditorView *view,
}
/* Signature */
- if (WEBKIT_DOM_IS_HTML_DIV_ELEMENT (child)) {
+ if (WEBKIT_DOM_IS_HTML_DIV_ELEMENT (child) &&
+ element_has_class (WEBKIT_DOM_ELEMENT (child), "-x-evo-signature-wrapper")) {
WebKitDOMNode *first_child;
first_child = webkit_dom_node_get_first_child (child);
- if (WEBKIT_DOM_IS_ELEMENT (first_child)) {
- if (element_has_class (
- WEBKIT_DOM_ELEMENT (first_child),
- "-x-evo-signature")) {
-
- if (to_html) {
- remove_base_attributes (
- WEBKIT_DOM_ELEMENT (first_child));
- remove_evolution_attributes (
- WEBKIT_DOM_ELEMENT (first_child));
- }
- if (to_plain_text && !changing_mode) {
- g_string_append (buffer, "\n");
- content = webkit_dom_html_element_get_inner_text (
- WEBKIT_DOM_HTML_ELEMENT (first_child));
- g_string_append (buffer, content);
- g_free (content);
- skip_nl = TRUE;
- }
- skip_node = TRUE;
- goto next;
- }
+
+ if (to_html) {
+ remove_base_attributes (
+ WEBKIT_DOM_ELEMENT (first_child));
+ remove_evolution_attributes (
+ WEBKIT_DOM_ELEMENT (first_child));
+ }
+ if (to_plain_text && !changing_mode) {
+ g_string_append (buffer, "\n");
+ content = webkit_dom_html_element_get_inner_text (
+ WEBKIT_DOM_HTML_ELEMENT (first_child));
+ g_string_append (buffer, content);
+ g_free (content);
+ skip_nl = TRUE;
}
+ if (to_plain_text && changing_mode) {
+ content = webkit_dom_html_element_get_outer_html (
+ WEBKIT_DOM_HTML_ELEMENT (child));
+ g_string_append (buffer, content);
+ g_free (content);
+ skip_node = TRUE;
+ }
+ skip_node = TRUE;
+ goto next;
}
/* Replace smileys with their text representation */
@@ -6724,8 +6726,7 @@ e_html_editor_view_set_html_mode (EHTMLEditorView *view,
} else {
gchar *plain;
- /* Save caret position -> it will be restored in e-composer-private.c */
- e_html_editor_selection_save_caret_position (selection);
+ e_html_editor_selection_save (selection);
if (blockquote) {
e_html_editor_selection_wrap_paragraphs_in_document (
@@ -6739,9 +6740,15 @@ e_html_editor_view_set_html_mode (EHTMLEditorView *view,
plain = process_content_for_mode_change (view);
- if (*plain)
- webkit_web_view_load_string (
- WEBKIT_WEB_VIEW (view), plain, NULL, NULL, "file://");
+ if (*plain) {
+ webkit_dom_html_element_set_outer_html (
+ WEBKIT_DOM_HTML_ELEMENT (
+ webkit_dom_document_get_document_element (document)),
+ plain,
+ NULL);
+ e_html_editor_selection_restore (selection);
+ e_html_editor_view_force_spell_check (view);
+ }
g_free (plain);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]